function RouteSubscriber::alterRoutes

Same name in other branches
  1. 3.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\Routing

Code

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');
}