diff --git a/core/includes/path.inc b/core/includes/path.inc index 911cfe0..6b8eb8c 100644 --- a/core/includes/path.inc +++ b/core/includes/path.inc @@ -207,44 +207,17 @@ function drupal_valid_path($path, $dynamic_allowed = FALSE) { $item['options'] = ''; _menu_link_translate($item); } - if (empty($item['access'])) { - // Nothing was found in the old routing system, so try the new one. - $item = _drupal_valid_path_new_router($path); - } } else { $item = menu_get_item($path); - if (empty($item['access'])) { - // Nothing was found in the old routing system, so try the new one. - $item = _drupal_valid_path_new_router($path); - } + } + + // Check the new routing system. + if (!empty($item['route_name'])) { + $map = array(); + $route = Drupal::service('router.route_provider')->getRouteByName($item['route_name']); + $item = menu_item_route_access($route, $path, $map); } $menu_admin = FALSE; return $item && $item['access']; } - -/** - * Temporary helper function to check a path in the new routing system. - * - * @param string $path - * The path string as expected by drupal_valid_path(). - * - * @return array|NULL - * An array containing 'access' => TRUE or NULL for paths that were not found - * or the user has no access to. - */ -function _drupal_valid_path_new_router($path) { - $request = Request::create('/' . $path); - $request->attributes->set('system_path', $path); - try { - $dc = drupal_container(); - $route = $dc->get('router.dynamic')->matchRequest($request); - if (!empty($route)) { - $dc->get('access_manager')->check($route['_route_object'], $request); - } - return array('access' => TRUE); - } - catch (Exception $e) { - drupal_set_message($e->getMessage(), 'menu', WATCHDOG_ERROR); - } -}