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 { ...@@ -15,10 +15,16 @@ class UwNodeAccessRouteSubscriber extends RouteSubscriberBase {
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function alterRoutes(RouteCollection $collection) { protected function alterRoutes(RouteCollection $collection) {
// Change the route associated with node (/node/{nid}). $access_route_names = [
if ($route = $collection->get('entity.node.canonical')) { // Node pages (/node/{nid}).
$route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access'); '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} * {@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