RouteTestSubscriber.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php
  2. 10 core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php
  3. 11.x core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php

Namespace

Drupal\router_test

File

core/modules/system/tests/modules/router_test_directory/src/RouteTestSubscriber.php

View source
<?php

namespace Drupal\router_test;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route event and add a test route.
 */
class RouteTestSubscriber extends RouteSubscriberBase {
    
    /**
     * {@inheritdoc}
     */
    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');
    }

}

Classes

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.