diff --git a/core/includes/menu.inc b/core/includes/menu.inc index 1dcaf98..20675e2 100644 --- a/core/includes/menu.inc +++ b/core/includes/menu.inc @@ -771,7 +771,7 @@ function _menu_translate(&$router_item, $map, $to_arg = FALSE) { if (!empty($router_item['route_name'])) { $route_provider = Drupal::getContainer()->get('router.route_provider'); $route = $route_provider->getRouteByName($router_item['route_name']); - menu_item_route_access($route, $router_item); + $router_item['access'] = menu_item_route_access($route, $router_item['href']); } else { // @todo: Remove once all routes are converted. @@ -909,7 +909,7 @@ function _menu_link_translate(&$item, $translate = FALSE) { // menu_tree_check_access() may set this ahead of time for links to nodes. if (!isset($item['access'])) { if ($route = $item->getRoute()) { - menu_item_route_access($route, $item); + $item['access'] = menu_item_route_access($route, $item['href']); } elseif (!empty($item['load_functions']) && !_menu_load_objects($item, $map)) { // An error occurred loading an object. @@ -943,22 +943,24 @@ function _menu_link_translate(&$item, $translate = FALSE) { * * @param \Symfony\Component\Routing\Route $route * Router for the given menu item. - * @param array $item - * Menu item array as returned by menu_get_item(). The 'access' key of the - * menu item will be updated based on the mock request to FALSE if user - * access is not possible. TRUE otherwise. - */ -function menu_item_route_access(Route $route, array &$item) { - $request = Request::create('/' . $item['href']); - $request->attributes->set('system_path', $item['href']); + * @param string $href + * Menu path as returned by $item['href'] of menu_get_item(). + * + * @return bool + * TRUE if the user has access or FALSE if the user should be presented + * with access denied. + */ +function menu_item_route_access(Route $route, $href) { + $request = Request::create('/' . $href); + $request->attributes->set('system_path', $href); // Attempt to match this path to provide a fully built request to the // access checker. try { $request->attributes->add(Drupal::service('router.dynamic')->matchRequest($request)); - $item['access'] = Drupal::service('access_manager')->check($route, $request); + return Drupal::service('access_manager')->check($route, $request); } catch (NotFoundHttpException $e) { - $item['access'] = FALSE; + return FALSE; } }