php - Can I dynamicaly generate routes from MyBundle/Resources/config/routing.yml file in Symfony2? -
as in question above. how can access route names mybundle/resources/config/routing.yml file , stick them array. want use regular expresions pull array values patern , use them generate navigation menu. clues ?
the easiest way use router
instance. has method called getroutecollection
returns, well, routecollection
. object has information need every route application makes.
$router = $this->get('router'); // service name $collection = $router->getroutecollection(); // routes foreach ( $collection->all() $name => $route ) { // route instance // regular expression matching here }
for further information can source @ symfony\component\routing
.
if want create routes depending on other routes, replace , extend router
class, override above method.
Comments
Post a Comment