-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Moves default and user-configured overridden bundle path registration to a CompilerPass #30360
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
Conversation
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.
Are you sure this is only for 4.2
and no bugfix for 3.4
branch which is also maintained?
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/DefaultOverridenBundlePathPass.php
Outdated
Show resolved
Hide resolved
} | ||
} | ||
|
||
private function normalizeBundleName($name) |
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.
private function normalizeBundleName($name) | |
private function normalizeBundleName(string $name): string |
but substr() could also return false... what do do here then @nicolas-grekas ?
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.
@OskarStark @nicolas-grekas I just copied the method from TwigExtension. Then I don't like copying the logic... Any suggestion on this ?
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/DefaultOverridenBundlePathPass.php
Outdated
Show resolved
Hide resolved
And btw there are two typos in the PR title: - Moves default overriden bnudle path registration to a CompilerPass
+ Moves default overridden bundle path registration to a CompilerPass |
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/DefaultOverridenBundlePathPass.php
Outdated
Show resolved
Hide resolved
@OskarStark At least 4.x and master. For 3.4, I have to check. Should i list target branches in the head Q/A section ? |
src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/DefaultOverriddenBundlePathPass.php
Outdated
Show resolved
Hide resolved
@yceruto @OskarStark Any update on this one ? |
$bundleHierarchy[$name][] = $defaultOverrideBundlePath; | ||
} | ||
$container->addResource(new FileExistenceResource($defaultOverrideBundlePath)); | ||
|
||
if (file_exists($dir = $bundle['path'].'/Resources/views')) { |
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.
Hi @alterphp, re-thinking this in another way... instead, what about moving this registration (as late as possible) into the compiler pass and call to addPath
always?
I mean, G1 and G2 as before in the same place, and only G3 into the compiler pass, thus other bundles would addPath
before G3 keeping the priority/order and also less changes than now.
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.
It took me some minutes to understand ... and it sounds far better than what I have done until now. I'm gonna take the time to refactor this.
Thanks for review !
I also think this is more a new feature ( |
Closed in favor or #30527 |
If #30359 is indeed considered as bug or problem, this PR is a solution to solve it.
TwigBundle default overriden bundle paths are defined too early in the bundle definition process. They are now configured in a CompilerPass that allows 3rd party bundles to override any Twig namespace and let the user have its own project overrides.
According to @yceruto request, I also moved the user-configured paths to the compiler pass.