diff --git a/core/core.services.yml b/core/core.services.yml index 497fea3f3f..7e617223b2 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -854,8 +854,8 @@ services: class: Drupal\Core\Utility\LinkGenerator arguments: ['@url_generator', '@module_handler', '@renderer'] router: - class: \Drupal\Core\Routing\Router - arguments: ['@router.route_provider', '@path.current', '@url_generator', '@access_manager', '@current_user', TRUE] + class: Drupal\Core\Routing\AccessAwareRouter + arguments: ['@router.route_provider', '@path.current', '@url_generator', '@access_manager', '@current_user'] tags: - { name: service_collector, tag: non_lazy_route_enhancer, call: addRouteEnhancer } - { name: service_collector, tag: non_lazy_route_filter, call: addRouteFilter } @@ -870,9 +870,6 @@ services: router.no_access_checks: class: \Drupal\Core\Routing\Router parent: router - arguments: - index_5: FALSE - # Tags are not inherited from the parent service. Must be kept in sync. tags: - { name: service_collector, tag: non_lazy_route_enhancer, call: addRouteEnhancer } - { name: service_collector, tag: non_lazy_route_filter, call: addRouteFilter } diff --git a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php index 7ed10d6145..6bb25c89c3 100644 --- a/core/lib/Drupal/Core/Routing/AccessAwareRouter.php +++ b/core/lib/Drupal/Core/Routing/AccessAwareRouter.php @@ -2,33 +2,14 @@ namespace Drupal\Core\Routing; -use Drupal\Core\Access\AccessManagerInterface; -use Drupal\Core\Access\AccessResultReasonInterface; -use Drupal\Core\Path\CurrentPathStack; -use Drupal\Core\Session\AccountInterface; -use Symfony\Cmf\Component\Routing\RouteProviderInterface as BaseRouteProviderInterface; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface as BaseUrlGeneratorInterface; -use Symfony\Component\Routing\Matcher\RequestMatcherInterface; -use Symfony\Component\Routing\RequestContext as SymfonyRequestContext; -use Symfony\Component\Routing\RequestContextAwareInterface; -use Symfony\Component\Routing\RouterInterface; - /** - * @deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. - * Use Drupal\Core\Routing\Router with $check_access in the constructor instead. - * See https://www.drupal.org/node/2915905 + * Extends the router to provide access checking. */ -class AccessAwareRouter extends Router { +class AccessAwareRouter extends Router implements AccessAwareRouterInterface { /** * {@inheritdoc} */ - public function __construct(RouteProviderInterface $route_provider, CurrentPathStack $current_path, UrlGeneratorInterface $url_generator, AccessManagerInterface $access_manager, AccountInterface $account, $check_access = TRUE) { - parent::__construct($route_provider, $current_path, $url_generator, $access_manager, $account, $check_access); - - @trigger_error(__NAMESPACE__ . '\AccessAwareRouter is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.0. Use Drupal\Core\Routing\Router with $check_access in the constructor instead. See https://www.drupal.org/node/2915905', E_USER_DEPRECATED); - } + protected $checkAccess = TRUE; } diff --git a/core/lib/Drupal/Core/Routing/Router.php b/core/lib/Drupal/Core/Routing/Router.php index 580effbe7f..c2e94a994e 100644 --- a/core/lib/Drupal/Core/Routing/Router.php +++ b/core/lib/Drupal/Core/Routing/Router.php @@ -46,7 +46,7 @@ * @see \Drupal\Core\Routing\UrlMatcher * @see \Symfony\Cmf\Component\Routing\NestedMatcher\NestedMatcher */ -class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterface, AccessAwareRouterInterface { +class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterface { /** * The route provider responsible for the first-pass match. @@ -124,16 +124,13 @@ class Router extends UrlMatcher implements RequestMatcherInterface, RouterInterf * The access manager. * @param \Drupal\Core\Session\AccountInterface $account * The current user. - * @param bool $check_access - * Whether to check access. */ - public function __construct(BaseRouteProviderInterface $route_provider, CurrentPathStack $current_path, BaseUrlGeneratorInterface $url_generator, AccessManagerInterface $access_manager, AccountInterface $account, $check_access = TRUE) { + public function __construct(BaseRouteProviderInterface $route_provider, CurrentPathStack $current_path, BaseUrlGeneratorInterface $url_generator, AccessManagerInterface $access_manager, AccountInterface $account) { parent::__construct($current_path); $this->routeProvider = $route_provider; $this->urlGenerator = $url_generator; $this->accessManager = $access_manager; $this->account = $account; - $this->checkAccess = $check_access; } /**