Skip to content

[HttpKernel] Add entry point to more easily create/configure the DI extension #13616

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

Closed
wants to merge 1 commit into from

Conversation

egeloen
Copy link

@egeloen egeloen commented Feb 6, 2015

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets ~
License MIT
Doc PR ~

Hey!

I would like to pass some dependencies to the DI extension through the bundle. In the current implementation, I need to duplicate the whole getContainerExtension in order to keep the extension alias check. This PR proposes to introduce an entry point for more easily do it.

What do you think?

*/
protected function createContainerExtension()
{
if (class_exists($class = $this->getContainerExtension())) {
Copy link
Member

Choose a reason for hiding this comment

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

Looks wrong to me, should be getContainerExtensionClass, no? Can you add some tests as well?

@egeloen egeloen force-pushed the bundle-di-extension branch from 697ac87 to b5bc26d Compare February 8, 2015 10:14
@egeloen egeloen force-pushed the bundle-di-extension branch from b5bc26d to f4493e6 Compare February 8, 2015 10:16
@egeloen
Copy link
Author

egeloen commented Feb 8, 2015

@fabpot Indeed, fixed + tests added.

@fabpot
Copy link
Member

fabpot commented Feb 8, 2015

So, I would deprecate getContainerExtensionClass in 2.7 and remove it in 3.0 as your new extension point does more than the old one.

@egeloen
Copy link
Author

egeloen commented Feb 8, 2015

@fabpot IMO, the two methods have different topics and so, the one which resolves the DI extension class name (getContainerExtensionClass) should not be deprecated otherwise, I will still need to resolve the DI extension class by myself because it will become part of the instantiation.

I can obviously bring the two lines of code which resolves the DI extension class but if I can avoid it, I would follow this method.

My point is I build a generic bundle implementation on top of the Symfony one, so, the DI extension class resolution is a feature I need but having it decouplated from the DI extension instanciation would be even better for passing dependencies :)

@egeloen
Copy link
Author

egeloen commented Feb 8, 2015

An other way to do it would be to move the DI extension class resolution in the getContainerExtension method and then pass the resolved class as parameter to the new createContainerExtension. Then, developers can choose to use it or not. What do you think?

@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

👍

1 similar comment
@nicolas-grekas
Copy link
Member

👍

@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

Thank you @egeloen.

@fabpot fabpot closed this in 95ccd3b Sep 14, 2015
@egeloen egeloen deleted the bundle-di-extension branch September 14, 2015 08:32
@craue
Copy link
Contributor

craue commented Sep 14, 2015

I'm now getting LogicException: Extension Symfony\Component\HttpKernel\Bundle\Bundle must implement Symfony\Component\DependencyInjection\Extension\ExtensionInterface when running tests. Might be just a merging issue since the code merged differs from the PR.

@fabpot
Copy link
Member

fabpot commented Sep 14, 2015

Indeed, merge issue. Fixed now.

@fabpot fabpot mentioned this pull request Nov 16, 2015
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.

5 participants