diff --git a/src/Access/UwNodeAccessCheck.php b/src/Access/UwNodeAccessCheck.php index 21019ee707ffe03d7c8c9ca237692ba395d82a51..9c3fac1843eeb283460402018b35268774f92fff 100644 --- a/src/Access/UwNodeAccessCheck.php +++ b/src/Access/UwNodeAccessCheck.php @@ -27,37 +27,31 @@ class UwNodeAccessCheck implements AccessInterface { * The access result. */ public function access(RouteMatchInterface $route_match, AccountInterface $account): AccessResult { - $route_name = $route_match->getRouteName(); - - // Menu link edit pages. - if ($route_name === 'menu_ui.link_edit') { - $menu_link_plugin = $route_match->getParameter('menu_link_plugin'); - // Only those with permission may edit home page menu entry. - if ($menu_link_plugin->getPluginId() === 'uw_base_profile.front_page') { - return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); - } - else { + switch ($route_match->getRouteName()) { + // Menu link edit pages. + case 'menu_ui.link_edit': + $menu_link_plugin = $route_match->getParameter('menu_link_plugin'); + // Only those with permission may edit home page menu entry. + if ($menu_link_plugin->getPluginId() === 'uw_base_profile.front_page') { + return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); + } // Otherwise, default to access set in menu_admin_per_menu. $menu_admin_per_menu = new MenuAdminPerMenuAccess(); return $menu_admin_per_menu->menuLinkAccess($account, $menu_link_plugin); - } - } - // Node delete pages. - if ($route_name === 'entity.node.delete_form') { - $node = $route_match->getParameter('node'); - // Only those with permission may delete the home page. - if ($node && UWService::nodeIsHomePage((int) $node->id())) { - return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); - } - else { + // Node delete pages. + case 'entity.node.delete_form': + $node = $route_match->getParameter('node'); + // Only those with permission may delete the home page. + if ($node && UWService::nodeIsHomePage((int) $node->id())) { + return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); + } return AccessResult::allowed(); - } - } - // Dashboard config: admin/config/dashboards/dashboardssettings. - if ($route_name === 'dashboards.dashboards_settings_form') { - return $account->hasPermission('access dashboard config') ? AccessResult::allowed() : AccessResult::forbidden(); + // Dashboard config: admin/config/dashboards/dashboardssettings. + case 'dashboards.dashboards_settings_form': + return $account->hasPermission('access dashboard config') ? AccessResult::allowed() : AccessResult::forbidden(); + } // Get the node object, which is in the route match variable.