You are here

protected function AccessAwareRouter::checkAccess in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Routing/AccessAwareRouter.php \Drupal\Core\Routing\AccessAwareRouter::checkAccess()

Apply access check service to the route and parameters in the request.

Parameters

\Symfony\Component\HttpFoundation\Request $request: The request to access check.

1 call to AccessAwareRouter::checkAccess()
AccessAwareRouter::matchRequest in core/lib/Drupal/Core/Routing/AccessAwareRouter.php

File

core/lib/Drupal/Core/Routing/AccessAwareRouter.php, line 103
Contains \Drupal\Core\Routing\AccessAwareRouter.

Class

AccessAwareRouter
A router class for Drupal with access check and upcasting.

Namespace

Drupal\Core\Routing

Code

protected function checkAccess(Request $request) {

  // The cacheability (if any) of this request's access check result must be
  // applied to the response.
  $access_result = $this->accessManager
    ->checkRequest($request, $this->account, TRUE);

  // Allow a master request to set the access result for a subrequest: if an
  // access result attribute is already set, don't overwrite it.
  if (!$request->attributes
    ->has(AccessAwareRouterInterface::ACCESS_RESULT)) {
    $request->attributes
      ->set(AccessAwareRouterInterface::ACCESS_RESULT, $access_result);
  }
  if (!$access_result
    ->isAllowed()) {
    throw new AccessDeniedHttpException();
  }
}