You are here

protected function RouteSubscriber::alterRoutes in Admin Login Path 8

Same name and namespace in other branches
  1. 2.x src/Routing/RouteSubscriber.php \Drupal\admin_login_path\Routing\RouteSubscriber::alterRoutes()

Alters existing routes for a specific collection.

Parameters

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

Overrides RouteSubscriberBase::alterRoutes

File

src/Routing/RouteSubscriber.php, line 16

Class

RouteSubscriber
Listens to the dynamic route events.

Namespace

Drupal\admin_login_path\Routing

Code

protected function alterRoutes(RouteCollection $collection) {

  // Define the routes we want to use the admin theme.
  $login_routes = [
    'user.login',
    'user.register',
    'user.pass',
  ];
  foreach ($collection
    ->all() as $name => $route) {
    if (in_array($name, $login_routes)) {
      $route
        ->setOption('_admin_route', TRUE);
    }
  }
}