<?php
namespace DrupalcustomRouting;
use DrupalCoreRoutingRouteSubscriberBase;
use SymfonyComponentRoutingRouteCollection;
/**
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Always deny access to unwanted routes.
$disallow_routes = [
'user.login',
'user.register',
'user.pass',
];
foreach ($disallow_routes as $disallow_route) {
if ($route = $collection->get($disallow_route)) {
$route->setRequirement('_access', 'FALSE');
}
}
}
}