AccessAwareRouter::checkAccess

protected AccessAwareRouter::checkAccess(Request $request)

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

Parameters

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

File

core/lib/Drupal/Core/Routing/AccessAwareRouter.php, line 99

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($access_result instanceof AccessResultReasonInterface ? $access_result->getReason() : NULL);
  }
}
doc_Drupal
2016-10-29 08:42:20
Comments
Leave a Comment

Please login to continue.