public function kernelException(GetResponseForExceptionEvent $event)
    {
        $exception = $event->getException();

        if (!$exception instanceof NoPermissionsException) {
            return;
        }

        // In the event a user requests a list of entities and has no permissions,
        // an empty list is returned.
        $response = new JsonResponse([]);
        $event->setResponse($response);
    }