public function ExceptionController::on403Json

Processes an AccessDenied exception that occured on a JSON request.

Parameters

Symfony\Component\HttpKernel\Exception\FlattenException $exception: The flattened exception.

Symfony\Component\HttpFoundation\Request $request: The request object that triggered this exception.

File

drupal/core/lib/Drupal/Core/Controller/ExceptionController.php, line 274
Contains \Drupal\Core\Controller\ExceptionController.

Class

ExceptionController
This controller handles HTTP errors generated by the routing system.

Namespace

Drupal\Core\Controller

Code

public function on403Json(FlattenException $exception, Request $request) {
  $response = new JsonResponse();
  $response
    ->setStatusCode(403, 'Access Denied');
  return $response;
}