You are here

public function ExceptionJsonSubscriber::on403 in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/EventSubscriber/ExceptionJsonSubscriber.php \Drupal\Core\EventSubscriber\ExceptionJsonSubscriber::on403()

Handles a 403 error for JSON.

Parameters

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

File

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

Class

ExceptionJsonSubscriber
Default handling for JSON errors.

Namespace

Drupal\Core\EventSubscriber

Code

public function on403(GetResponseForExceptionEvent $event) {
  $response = new JsonResponse(array(
    'message' => $event
      ->getException()
      ->getMessage(),
  ), Response::HTTP_FORBIDDEN);
  $event
    ->setResponse($response);
}