Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register the default services from a Provider. #1745

Merged
merged 2 commits into from
Feb 11, 2016
Merged

Conversation

mducharme
Copy link
Contributor

By splitting the default Slim Container in 2 (The Container and its associated Service Provider to register services) this allows one to use a custom (Pimple-based) container and still auto-register all required service for Slim.

It does not solve the more generic problem of having a reusable provider (because container-interop does not have a "setter" method to register service) but it is, I believe, one step in the right direction. In other words, this won't work more for general-purpose container, but it at least allows any Pimple container to register Slim services without having to have a bridge to the SlimContainer.

@vlakoff
Copy link
Contributor

vlakoff commented Feb 8, 2016

I agree having the services registered in the container class looked very strange at first glance.

@akrabat akrabat added this to the 3.2.0 milestone Feb 8, 2016
*
* @param Container $container
*/
public function register(PimpleContainer $container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the type hint. Any DIC that uses array access with closures would in theory work with this...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to code against ContainerInterface instead

Additionally check for services with that interface instead of ArrayAccess?

if (!$container->has('environment')) {
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliangut I ported the service code exactly as it was previously in the container.

I don't disagree with the idea; I just think that it's a bit outside the scope of that PR.

@akrabat akrabat merged commit b3a5ddd into slimphp:3.x Feb 11, 2016
@akrabat
Copy link
Member

akrabat commented Feb 11, 2016

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants