function RouteSubscriber::alterRoutes
Same name in other branches
- 8.x-1.x menu_example/src/Routing/RouteSubscriber.php \Drupal\menu_example\Routing\RouteSubscriber::alterRoutes()
- 4.0.x modules/menu_example/src/Routing/RouteSubscriber.php \Drupal\menu_example\Routing\RouteSubscriber::alterRoutes()
Overrides RouteSubscriberBase::alterRoutes
File
-
modules/
menu_example/ src/ Routing/ RouteSubscriber.php, line 23
Class
- RouteSubscriber
- Listens to the dynamic route events.
Namespace
Drupal\menu_example\RoutingCode
public function alterRoutes(RouteCollection $collection) {
// Get the path from RouteCollection.
$route = $collection->get('example.menu_example.path_override');
// Set the new path.
$route->setPath('/examples/menu-example/menu-altered-path');
// Change title to indicate changes.
$route->setDefault('_title', 'Menu item altered by RouteSubscriber::alterRoutes');
}