Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Inject defaults and instanceof conditionals in anonymous services#21999
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
182665a to200ae5dCompare| $configuratorService =$this->getChildren($configurator,'service'); | ||
| if (isset($configuratorService[0])) { | ||
| $class =$this->parseDefinition($configuratorService[0],$file); |
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.
I fixed another bug at the same time, the fact that the factories/configurators were inline meant for prototypes/instanceof conditionals that different instances could be created for one anonymous service which wasn't consistent with how other anonymous services are created.
Note that it wasn't an issue before 3.3 as a service was never cloned.
nicolas-grekas commentedMar 15, 2017
rebase needed |
GuilhemN commentedMar 15, 2017
@nicolas-grekas done |
98ddc3f toec5b923Comparenicolas-grekas commentedApr 4, 2017
Thinking again about that, what about going the other way around: have defaults and instanceof apply only to root level definitions, and not to nested (inline) ones? |
GuilhemN commentedApr 4, 2017
That's the current behavior.
I agree, thinking about it again I don't think this change is worth it. Let's close it and open a different PR for#21999 (comment). |
This PR was squashed before being merged into the 3.3-dev branch (closes#22279).Discussion----------[DI] Fix anonymous factories/configurators support| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks? | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass? | yes| Fixed tickets |#21999 (comment)| License | MIT| Doc PR |Using prototypes / instanceof conditionals, anonymous factories are inlined using `Definition`, so a new instance will be created for every service created from the prototype / conditional which is inconsistent with the way other anonymous services are managed.Commits-------dda43ed [DI] Fix anonymous factories/configurators support
This PR was squashed before being merged into the 3.3-dev branch (closes #22279).Discussion----------[DI] Fix anonymous factories/configurators support| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no <!-- don't forget updating src/**/CHANGELOG.md files -->| BC breaks? | no| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->| Tests pass? | yes| Fixed tickets |symfony/symfony#21999 (comment)| License | MIT| Doc PR |Using prototypes / instanceof conditionals, anonymous factories are inlined using `Definition`, so a new instance will be created for every service created from the prototype / conditional which is inconsistent with the way other anonymous services are managed.Commits-------dda43ed8ce [DI] Fix anonymous factories/configurators support
This PR injects defaults and instanceof conditionals in anonymous services to be consistent for all services.
In this example,
Barand the anonymous service will be autowired.One special case: instanceof conditionals aren't injected in anonymous services used in instanceof conditionals.