You are here

protected function RouteTestSubscriber::alterRoutes in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php \Drupal\router_test\RouteTestSubscriber::alterRoutes()
  2. 9 core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php \Drupal\router_test\RouteTestSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.

Overrides RouteSubscriberBase::alterRoutes

File

core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php, line 16

Class

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

Namespace

Drupal\router_test

Code

protected function alterRoutes(RouteCollection $collection) {
  $route = $collection
    ->get('router_test.6');

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