protected function AccessAwareRouter::checkAccess in Drupal 9
Same name and namespace in other branches
- 8 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 106
Class
- AccessAwareRouter
- A router class for Drupal with access check and upcasting.
Namespace
Drupal\Core\RoutingCode
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()) {
if ($access_result instanceof CacheableDependencyInterface && $request
->isMethodCacheable()) {
throw new CacheableAccessDeniedHttpException($access_result, $access_result instanceof AccessResultReasonInterface ? $access_result
->getReason() : NULL);
}
else {
throw new AccessDeniedHttpException($access_result instanceof AccessResultReasonInterface ? $access_result
->getReason() : NULL);
}
}
}