-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Fix adding name prefix to canonical route names #27270
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.
LGTM, with minor suggestion.
@@ -161,6 +161,11 @@ public function addNamePrefix(string $prefix) | |||
$prefixedRoutes = array(); | |||
|
|||
foreach ($this->routes as $name => $route) { | |||
if (null !== $route->getDefault('_canonical_route')) { | |||
$prefixedRouteName = $prefix.$route->getDefault('_canonical_route'); | |||
$route->setDefault('_canonical_route', $prefixedRouteName); |
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'd propose to move the added block after the line blow, doing this:
if (null !== $name = $route->getDefault('_canonical_route')) {
$route->setDefault('_canonical_route', $prefix.$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.
Thanks for your review, I updated code following your advice
Thank you @ismail1432. |
…(ismail1432) This PR was merged into the 4.1 branch. Discussion ---------- [Routing] Fix adding name prefix to canonical route names | Q | A | ------------- | --- | Branch? | 4.1 for bug fixes <!-- see below --> | Bug fix? | yes | New feature? |no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #27244 <!-- #-prefixed issue number(s), if any --> | License | MIT This PR resolve the [bug](#27244) in the [prefix imported routes name](https://symfony.com/blog/new-in-symfony-4-1-prefix-imported-route-names) feature. Reviews are always welcomed moreover as I touch a key element ( the `_canonical_route` attribute ). I need an expert in the Routing component to avoid side effect Thanks Commits ------- cb5ce8f fix bug when imported routes are prefixed
This PR resolve the bug in the prefix imported routes name feature. Reviews are always welcomed moreover as I touch a key element ( the
_canonical_route
attribute ). I need an expert in the Routing component to avoid side effectThanks