You are here

public function AgreementSubscriber::exceptionRedirect in Agreement 3.0.x

Same name and namespace in other branches
  1. 8.2 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\ExceptionEvent $event: The response exception event.

File

src/EventSubscriber/AgreementSubscriber.php, line 111

Class

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

Namespace

Drupal\agreement\EventSubscriber

Code

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