I have a plugin and i need to load a different routing.yml file based on a variable in the query string.
Example:
if($request->getParameter('page'){
// use routingPage.yml
}
else{
// use another routing.yml
}
So, If the page parameter in url the url_for('@route1'), will return one url, else the same url_for('@route1') would return other url.
How can override the rouing.yml loading mechanism to do what I want?
Every application can have only one
routing.yml(of course it can be overrided by other plugins).The reason for this is quite simple: If you want to use multiple routing files (say
routing1.ymlandrouting2.yml), and they both have a route calledroute1, which redirects tocontroller1/actionandcontroller2/actionrespectively. Maybe you would be able to switch it in the view, and go tocontroller1/actionin the one case andcontroller2/actionin the other. But then: when a new request arrives, and the front controller is determining which controller / action to execute: how does it now whichrouting.ymlto use?So I don't know exactly what you're trying to achieve, but I would go for two routes in your
routing.yml, and select the route based on your view parameters.