Skip to content

[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

Merged
merged 1 commit into from
May 17, 2018
Merged

[Routing] Fix adding name prefix to canonical route names #27270

merged 1 commit into from
May 17, 2018

Conversation

ismail1432
Copy link
Contributor

@ismail1432 ismail1432 commented May 14, 2018

Q A
Branch? 4.1 for bug fixes
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #27244
License MIT

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 effect
Thanks

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.

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

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);
            }

Copy link
Contributor Author

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

@nicolas-grekas nicolas-grekas changed the title Fix bug Feature 4.1 add prefix for imported routes [Routing] Fix adding name prefix to canonical route names May 15, 2018
@fabpot
Copy link
Member

fabpot commented May 17, 2018

Thank you @ismail1432.

@fabpot fabpot merged commit cb5ce8f into symfony:4.1 May 17, 2018
fabpot added a commit that referenced this pull request May 17, 2018
…(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
@fabpot fabpot mentioned this pull request May 21, 2018
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.

4 participants