-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] make the service container builder register its own self referencing definition #21627
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
[DependencyInjection] make the service container builder register its own self referencing definition #21627
Conversation
hhamon
commented
Feb 16, 2017
•
edited
Loading
edited
Q | A |
---|---|
Branch? | master |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | ~ |
License | MIT |
Doc PR | ~ |
This PR fixes a bug in Symfony 3.3 that prevents autowiring compiler passes to autowire the service container in a service. The bug mostly occurs when you use services:
AppBundle\Controller\:
resource: '../../src/AppBundle/Controller'
autowire: ['get*', 'set*'] If the controller class still extends the base Symfony controller class (or implements the |
a370b3f
to
fc66b28
Compare
Looks like fabbot.io violations is a false positive due to a fixtures file, |
c028471
to
df7ce28
Compare
@nicolas-grekas can you review please. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Just wondering: should we also add these three aliases to the defaults also? <service id="Psr\Container\ContainerInterface" alias="service_container" public="false" />
<service id="Symfony\Component\DependencyInjection\ContainerInterface" alias="service_container" public="false" />
<service id="Symfony\Component\DependencyInjection\Container" alias="service_container" public="false" /> |
What do you mean? |
I mean add three calls after the new one, to |
f59ab88
to
457ffde
Compare
I'm on it. |
@nicolas-grekas better? |
yes! you can also clean |
Shall we use autowire in |
I think you're talking about the |
@nicolas-grekas done ;) |
Missing test case fix: |
8575394
to
ba7e331
Compare
e61f4b8
to
ffcd3c8
Compare
Review from Symfony Core Team member is welcome. |
👍 for the added aliases too |
@@ -30,6 +30,11 @@ public function __construct() | |||
$this->parameters = $this->getDefaultParameters(); | |||
|
|||
$this->services = array(); | |||
$this->normalizedIds = array( | |||
'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicolas-grekas should we really dump normalized ids for services which got removed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dunno :) do we really care? if someone wants to try fixing that, please do :) should be done while dumping - ie in PhpDumper I'd say.
ffcd3c8
to
0d80817
Compare
… definition of its related service container service (and aliases) in order to make compiler passes be able to reference the special service_container service.
0d80817
to
9c97496
Compare
Thank you @hhamon. |
…egister its own self referencing definition (hhamon) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] make the service container builder register its own self referencing definition | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | ~ | License | MIT | Doc PR | ~ Commits ------- 9c97496 [DependencyInjection] make the service container builder register the definition of its related service container service (and aliases) in order to make compiler passes be able to reference the special service_container service.
This PR was merged into the 3.3 branch. Discussion ---------- [DI] Remove dead service_container checks | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> Since #21627 Commits ------- 9a8ea93 [DI] Remove dead service_container checks