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] Add locale requirement for localized routes #35735

Merged
merged 1 commit into from Feb 20, 2020

Conversation

mtarld
Copy link
Contributor

@mtarld mtarld commented Feb 15, 2020

Q A
Branch? 4.4
Bug fix? yes
New feature? no
Deprecations? no
License MIT

4.4 version of #35692

If you're using localized routes, you expect to have these kind of routes available:

  • /fr/accueil
  • /en/home

But nowadays, these routes are unexpectedly available:

  • /en/accueil
  • /fr/home

When importing routes like that:

  • prefix: "/{_locale}"
  • @Route({"en": "/home", "fr": "/accueil"}, name="home")

This PR proposes to add a strict locale requirement for localized so that the above routes won't be available.

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.
For the future, we could have a smart RouteCompiler that knows how to turn static requirements into actual static routes.
But that's for another PR :)

@fabpot
Copy link
Member

fabpot commented Feb 20, 2020

Thank you @mtarld.

@fabpot fabpot merged commit 88b89c9 into symfony:4.4 Feb 20, 2020
@mtarld mtarld deleted the fix/localized-routes-requirements-4.4 branch February 20, 2020 08:15
nicolas-grekas added a commit that referenced this pull request Feb 25, 2020
This PR was merged into the 4.4 branch.

Discussion
----------

[Routing] Improve localized routes performances

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| License       | MIT

Implementation of the following idea: #35735 (review)

Improve route matching performances by turning dynamic routes with fixed `_locale` to actual static routes.

Commits
-------

8e9eafe [Routing] Improve localized routes performances
This was referenced Feb 29, 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

5 participants