reflector = $reflector; $this->isAdmin = $isAdmin; $this->isSubAdmin = $isSubAdmin; } /** * @param Controller $controller * @param string $methodName * * @throws NotSubAdminException */ public function beforeController($controller, $methodName) { // If AuthorizedAdminSetting, the check will be done in the SecurityMiddleware if (!$this->isAdmin && !$this->reflector->hasAnnotation('NoSubAdminRequired') && !$this->isSubAdmin && !$this->reflector->hasAnnotation('AuthorizedAdminSetting')) { throw new NotSubAdminException(); } } /** * @param Controller $controller * @param string $methodName * @param \Exception $exception * @throws \Exception * @return Response */ public function afterException($controller, $methodName, \Exception $exception) { if ($exception instanceof NotSubAdminException) { throw new OCSException($exception->getMessage(), Http::STATUS_FORBIDDEN); } throw $exception; } }