How can I override a single route in Symfony2?
I have a bundle that comes with a bundle_routing.yml file.
In a bundle that extends this parent bundle i also have routing file:
routing.xml
Note that the files are named different.
In this routing file I like to override a single parent route.
I tried to simple redeclare it and change the pattern.
But it’s not applied.
parent:
MyParentBundle_detailpage:
pattern: /detail
defaults: { _controller: "MyParentBundle:Item:detail" }
child:
<route id="MyParentBundle_detailpage" pattern="/itemDetails">
<default key="_controller">MyParentBundle:Item:detail</default>
</route>
Found the reason myself:
Its because of the import order in the main routing file.
The parent routing must be imported first and the routing of the child bundle must be imported second.