public function RouteTestSubscriber::alterRoutes

Alters an existing test route.

Parameters

\Drupal\Core\Routing\RouteBuildEvent $event: The route building event.

Return value

\Symfony\Component\Routing\RouteCollection The altered route collection.

File

drupal/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/RouteTestSubscriber.php, line 53

Class

RouteTestSubscriber
Listens to the dynamic route event and add a test route.

Namespace

Drupal\router_test

Code

public function alterRoutes(RouteBuildEvent $event) {
  if ($event
    ->getModule() == 'router_test') {
    $collection = $event
      ->getRouteCollection();
    $route = $collection
      ->get('router_test_6');

    // Change controller method from test1 to test5.
    $route
      ->setDefault('_controller', '\\Drupal\\router_test\\TestControllers::test5');
  }
}