-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Routing] Overriding route puts route on end of collection. #24748
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
Comments
I just want to show simple example. Of course I could do it how you suggest, but it will require to copy more than one hundred routes. - I think it can be solved by creating some custom route loader. Maybe just by adding an 'replace' as route option will be enough? Similar like |
Sure a custom route loader can solve that. I don't know how you create the routes with annotation, yaml, php generated. But can't you identify your catch-all routes and import them last? So after you overwrote the others. |
I m using dynamic loader (which dynamically read yaml files). I think it would be possible (There should be few catch-all routes). However its not the best solution, so I will try add What do You think about making this option available in Route? If I am the first one with such problem I guess it will not be good idea, Do you know anybody else with similar problem? |
@nicolas-grekas PR that you mention 'works' only for To illustrate it I will give more complex example.
Because of different features set for each of country: applications read So in routing.yml (common) repository_details:
path: /{repositoryId}/details
defaults: { _controller: AppBundle:Default:index }
methods: ['GET']
requirements:
repositoryId: \d+
repository_slug:
path: /{repositoryId}/{slug}
defaults: { _controller: AppBundle:Default:catchAll }
methods: ['GET']
requirements:
repositoryId: \d+ However only for France repository_details:
path: /{repositoryId}/détails --Notice é instead of e
defaults: { _controller: AppBundle:Default:index }
methods: ['GET']
requirements:
repositoryId: \d+ Of course I can define all // I am aware that it can be done by 'generating' from template separate routing file (using Ansible / any other tool) -so there will not be any 'common' routing. I just was not sure why while overriding route definition new route does not keep 'previous position'. |
I'm closing as I think the current ongoing PRs have the potential to provide an alternative solution for this, and because changing the current logic would be a BC break anyway. |
I am working on application which define different route parameters depending on subdomain (for simplicity lets call them languages)
For example there are
en
,pl
,gb
sub domains. Which may override some global routes (defined in domain routing)Because of priority of sub domain routes it has to be imported last (To override
app_default_index
fromrouting_domain.yaml
)Problem with this approach is that it puts
app_default_index
on the bottom of routes priority, causing thatapp_default_catch_all
is beforeapp_default_index
.It there any way that I am able to override
app_default_index
route, but keep its initial position?I've found an place where this logic is set
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Routing/RouteCollection.php#L125
What is an reason that route should be put on end of array? How can I solve this problem, without using dynamic route loader and keep everything as simple as possible?
The text was updated successfully, but these errors were encountered: