public function AccessSubscriber::onKernelRequestAccessCheck

Verifies that the current user can access the requested path.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The Event to process.

File

drupal/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php, line 41
Contains Drupal\Core\EventSubscriber\AccessSubscriber.

Class

AccessSubscriber
Access subscriber for controller requests.

Namespace

Drupal\Core\EventSubscriber

Code

public function onKernelRequestAccessCheck(GetResponseEvent $event) {
  $request = $event
    ->getRequest();
  if (!$request->attributes
    ->has(RouteObjectInterface::ROUTE_OBJECT)) {

    // If no Route is available it is likely a static resource and access is
    // handled elsewhere.
    return;
  }
  $access = $this->accessManager
    ->check($request->attributes
    ->get(RouteObjectInterface::ROUTE_OBJECT), $request);
  if (!$access) {
    throw new AccessDeniedHttpException();
  }
}