-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle] Fix twig loader registered twice #20712
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
[TwigBundle] Fix twig loader registered twice #20712
Conversation
a better solution would be to use an alias rather than a child service |
@stof : That's what I meant by (and the first solution I implemented):
|
(By this I mean someone may use |
I'm using |
I am not sure if this is something that is part of our BC promise. Using |
@xabbuh is true. Definitions can be replaced by aliases in many cases (for instance when using |
Fair enough. Reverted to the private alias solution 😄 |
Thank you @ogizanagi. |
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Fix twig loader registered twice | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20665 | License | MIT | Doc PR | N/A Generated code: ### Before ```php protected function getTwig_LoaderService() { $a = new \Twig_Loader_Filesystem(array(), $this->targetDirs[3]); $a->addPath(...); // ... $this->services['twig.loader'] = $instance = new \Twig_Loader_Chain(); $instance->addLoader($a); $instance->addLoader($a); return $instance; } ``` ### After ```php protected function getTwig_LoaderService() { $this->services['twig.loader'] = $instance = new \Twig_Loader_Filesystem(array(), $this->targetDirs[3]); $instance->addPath(...); // ... return $instance; } ``` ~~Another solution is to simply create a private alias. But I don't know if we should care or not about the case people may rely on the fact both services exist as definition, and not as an alias, in a compiler pass.~~ (Has been preferred over of using a child definition) For reference, this issue was introduced in #13354. Commits ------- 2c81819 [TwigBundle] Fix twig loader registered twice
Generated code:
Before
After
Another solution is to simply create a private alias. But I don't know if we should care or not about the case people may rely on the fact both services exist as definition, and not as an alias, in a compiler pass.(Has been preferred over of using a child definition)For reference, this issue was introduced in #13354.