Skip to content
Snippets Groups Projects
Commit bee083a8 authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-4229: Refactor UwNodeAccessRouteSubscriber::alterRoutes()

parent f46a4199
No related branches found
No related tags found
1 merge request!63ISTWCMS-4229: Protect home page
......@@ -15,10 +15,16 @@ class UwNodeAccessRouteSubscriber extends RouteSubscriberBase {
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// Change the route associated with node (/node/{nid}).
if ($route = $collection->get('entity.node.canonical')) {
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access');
$access_route_names = [
// Node pages (/node/{nid}).
'entity.node.canonical',
];
foreach ($access_route_names as $route_name) {
if ($route = $collection->get($route_name)) {
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access');
}
}
}
/**
* {@inheritdoc}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment