getAttributes(RequireGroupFolderAdmin::class) !== [] && !$this->delegatedService->hasApiAccess()) { throw new Exception('Logged in user must be an admin, a sub admin or gotten special right to access this setting'); } } public function afterException(Controller $controller, string $methodName, Exception $exception): Response { /** @var Http::STATUS_* $code */ $code = $exception->getCode(); if (stripos($this->request->getHeader('Accept'), 'html') === false) { return new JSONResponse( ['message' => $exception->getMessage()], $code ); } return new TemplateResponse('core', '403', ['message' => $exception->getMessage()], 'guest', $code); } }