-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Keeping routes priorities after add a name prefix to the collection #37176
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
yceruto
commented
Jun 9, 2020
Q | A |
---|---|
Branch? | 5.1 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #37089 |
License | MIT |
Doc PR | - |
@@ -179,8 +179,8 @@ public function addNamePrefix(string $prefix) | |||
|
|||
foreach ($this->routes as $name => $route) { | |||
$prefixedRoutes[$prefix.$name] = $route; | |||
if (null !== $name = $route->getDefault('_canonical_route')) { | |||
$route->setDefault('_canonical_route', $prefix.$name); | |||
if (null !== $canonicalName = $route->getDefault('_canonical_route')) { |
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.
Fixed name collision
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.
Cool thanks for having a look
This is called here for instance: symfony/src/Symfony/Component/Routing/Loader/YamlFileLoader.php Lines 217 to 219 in 6d6d989
even if the name prefix is not defined, due to:
I wonder if we should compare with empty string instead or change to |
@yceruto that'd make sense yes |
@@ -171,7 +171,7 @@ protected function parseImport(RouteCollection $collection, array $config, strin | |||
$schemes = isset($config['schemes']) ? $config['schemes'] : null; | |||
$methods = isset($config['methods']) ? $config['methods'] : null; | |||
$trailingSlashOnRoot = $config['trailing_slash_on_root'] ?? true; | |||
$namePrefix = $config['name_prefix'] ?? ''; | |||
$namePrefix = $config['name_prefix'] ?? null; |
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.
consistent with Xml loader:
$namePrefix = $node->getAttribute('name-prefix') ?: null; |
2a294fe
to
1010526
Compare
Thank you @yceruto. |