3 namespace Drupal\router_test;
5 use Drupal\Core\Routing\RouteSubscriberBase;
6 use Symfony\Component\Routing\RouteCollection;
9 * Listens to the dynamic route event and add a test route.
11 class RouteTestSubscriber extends RouteSubscriberBase {
16 protected function alterRoutes(RouteCollection $collection) {
17 $route = $collection->get('router_test.6');
18 // Change controller method from test1 to test5.
19 $route->setDefault('_controller', '\Drupal\router_test\TestControllers::test5');