Skip to content
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

[Routing] Keeping routes priorities after add a name prefix to the collection #37176

Merged
merged 1 commit into from Jun 10, 2020

Conversation

yceruto
Copy link
Member

@yceruto 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')) {
Copy link
Member Author

@yceruto yceruto Jun 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed name collision

Copy link
Member

@nicolas-grekas nicolas-grekas left a 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

@yceruto
Copy link
Member Author

yceruto commented Jun 9, 2020

This is called here for instance:

if (null !== $namePrefix) {
$subCollection->addNamePrefix($namePrefix);
}

even if the name prefix is not defined, due to:

$namePrefix = $config['name_prefix'] ?? '';

I wonder if we should compare with empty string instead or change to $config['name_prefix'] ?? null and save some ticks.

@nicolas-grekas
Copy link
Member

@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;
Copy link
Member Author

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;

@yceruto yceruto force-pushed the route_priority_with_prefix branch from 2a294fe to 1010526 Compare June 10, 2020 11:52
@fabpot
Copy link
Member

fabpot commented Jun 10, 2020

Thank you @yceruto.

@fabpot fabpot merged commit 7c892ee into symfony:5.1 Jun 10, 2020
@yceruto yceruto deleted the route_priority_with_prefix branch June 10, 2020 16:02
@fabpot fabpot mentioned this pull request Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants