You are here

public function AgreementSubscriber::exceptionRedirect in Agreement 8.2

Same name and namespace in other branches
  1. 3.0.x src/EventSubscriber/AgreementSubscriber.php \Drupal\agreement\EventSubscriber\AgreementSubscriber::exceptionRedirect()

Performs redirect for access denied exceptions.

In case the user has no permission to access a page, the denied exception will be thrown. Therefore the response will be set before executing of the checkForRedirection function, that will lead to an infinite redirect loop.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent $event: The response exception event.

File

src/EventSubscriber/AgreementSubscriber.php, line 109

Class

AgreementSubscriber
Checks if the current user is required to accept an agreement.

Namespace

Drupal\agreement\EventSubscriber

Code

public function exceptionRedirect(GetResponseForExceptionEvent $event) {
  $exception = $event
    ->getException();
  if ($exception instanceof HttpExceptionInterface && $event
    ->getException()
    ->getStatusCode() === 403) {
    $this
      ->checkForRedirection($event);
  }
}