Beispiel #1
0
 /**
  * Возвращает результат работы контроллера компонента.
  * @param IComponent $component
  * @param IDispatchContext $context
  * @param SplStack $callStack
  * @param array $routeMatches
  * @throws ResourceAccessForbiddenException
  * @throws HttpNotFound
  * @return Response
  */
 private function processControllerRequest(IComponent $component, IDispatchContext $context, SplStack $callStack, array $routeMatches)
 {
     if (!$component->hasController($routeMatches[IComponent::MATCH_CONTROLLER])) {
         throw new HttpNotFound($this->translate('Controller "{name}" not found.', ['name' => $routeMatches[IComponent::MATCH_CONTROLLER]]));
     }
     /**
      * @var IController|IACLResource $controller
      */
     $controller = $component->getController($routeMatches[IComponent::MATCH_CONTROLLER])->setContext($context)->setRequest($this->getCurrentRequest());
     if ($controller instanceof IACLResource && !$this->checkPermissions($component, $controller)) {
         throw new ResourceAccessForbiddenException($controller, $this->translate('Cannot execute controller "{name}" for component "{path}". Access denied.', ['name' => $controller->getName(), 'path' => $component->getPath()]));
     }
     $componentResponse = $this->invokeController($controller);
     return $this->processResponse($componentResponse, $callStack);
 }