protected function RouteSubscriber::alterRoutes in Admin Login Path 2.x
Same name and namespace in other branches
- 8 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\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
// Define the routes we want to use the admin theme.
$login_routes = [
'user.login',
'user.register',
'user.pass',
'user.cancel_confirm',
'user.reset.login',
'user.reset',
'user.reset.form',
];
foreach ($collection
->all() as $name => $route) {
if (in_array($name, $login_routes)) {
$route
->setOption('_admin_route', TRUE);
}
}
}