userSession->getUser(); if ($userObject === null) { return false; } return $this->subAdminManager->isSubAdmin($userObject); } #[Override] public function beforeController(Controller $controller, string $methodName): void { if (!$this->reflector->hasAnnotation('NoSubAdminRequired') && !$this->reflector->hasAnnotation('AuthorizedAdminSetting')) { if (!$this->isSubAdmin()) { throw new NotAdminException($this->l10n->t('Logged in account must be a sub admin')); } } } #[Override] public function afterException(Controller $controller, string $methodName, \Exception $exception): TemplateResponse { if ($exception instanceof NotAdminException) { $response = new TemplateResponse('core', '403', [], 'guest'); $response->setStatus(Http::STATUS_FORBIDDEN); return $response; } throw $exception; } }