Skip to content

[HttpKernel][DI] Enable Kernel to implement CompilerPassInterface #24257

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 2 commits into from

Conversation

nicolas-grekas
Copy link
Member

@nicolas-grekas nicolas-grekas commented Sep 19, 2017

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

In the same spirit as #13761 that allowed DI exts to be also compiler passes, and as #23812 that allowed the kernel to listen to events, in our new bundle-less world, should we allow the kernel to register itself as a compiler pass? That would make some scenario possible (like having a TestKernel that turns some services public.)

@@ -767,6 +768,9 @@ protected function getContainerBuilder()
$container = new ContainerBuilder();
$container->getParameterBag()->add($this->getKernelParameters());

if ($this instanceof CompilerPassInterface) {
$container->setKernelPass($this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need to set the kernel pass in the container builder (which is a bit weird to me) rather than simply adding it through $container->getCompilerPassConfig()->addPass(...) or $container->addCompilerPass(...)? Is processing the pass right after the extensions (in ExtensionCompilerPass) the best option? I think it probably is, but I'd like to get the full reasoning behind :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question :)
The reason is as you said that this pass should be run last after bundle passes, and before optimization passes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, I now changed the implementation so that no new method is needed. Using priorities should be good enough and better in fact. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Much better to me 👍
It can be a small BC break for people already relying on priorities though. So should we mention this somewhere?
Also the CHANGELOG.md entry is missing :)

@nicolas-grekas
Copy link
Member Author

@ogizanagi comments addressed.

@@ -4,6 +4,7 @@ CHANGELOG
3.4.0
-----

* moved the `ExtensionCompilerPass` to before-optimization passes with priority -1000
Copy link
Member

Choose a reason for hiding this comment

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

may be worth adding this to the upgrade file too

Copy link
Member Author

Choose a reason for hiding this comment

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

done

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