Ejemplo n.º 1
0
 /**
  * Initiate a sub request to $this->controller. Make sure to fill $this->controller
  * via Dependency Injection.
  *
  * @return \TYPO3\CMS\Extbase\Mvc\ResponseInterface the response of this request.
  * @api
  */
 protected function initiateSubRequest()
 {
     if (!$this->controller instanceof \TYPO3\Fluid\Core\Widget\AbstractWidgetController) {
         if (isset($this->controller)) {
             throw new \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException('initiateSubRequest() can not be called if there is no valid controller extending TYPO3\\Fluid\\Core\\Widget\\AbstractWidgetController. Got "' . get_class($this->controller) . '" in class "' . get_class($this) . '".', 1289422564);
         }
         throw new \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add a corresponding injectController method to your WidgetViewHelper class "' . get_class($this) . '".', 1284401632);
     }
     $subRequest = $this->objectManager->create('TYPO3\\Fluid\\Core\\Widget\\WidgetRequest');
     $subRequest->setWidgetContext($this->widgetContext);
     $this->passArgumentsToSubRequest($subRequest);
     $subResponse = $this->objectManager->create('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     $this->controller->processRequest($subRequest, $subResponse);
     return $subResponse;
 }
 /**
  * Initiate a sub request to $this->controller. Make sure to fill $this->controller
  * via Dependency Injection.
  *
  * @return \TYPO3\Flow\Http\Response the response of this request.
  * @throws Exception\MissingControllerException
  * @api
  */
 protected function initiateSubRequest()
 {
     if ($this->controller instanceof DependencyProxy) {
         $this->controller->_activateDependency();
     }
     if (!$this->controller instanceof \TYPO3\Fluid\Core\Widget\AbstractWidgetController) {
         throw new \TYPO3\Fluid\Core\Widget\Exception\MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add the @TYPO3\\Flow\\Annotations\\Inject annotation in your widget class.', 1284401632);
     }
     $subRequest = $this->objectManager->get('TYPO3\\Flow\\Mvc\\ActionRequest', $this->controllerContext->getRequest());
     $this->passArgumentsToSubRequest($subRequest);
     $subRequest->setArgument('__widgetContext', $this->widgetContext);
     $subRequest->setControllerObjectName($this->widgetContext->getControllerObjectName());
     $subRequest->setArgumentNamespace('--' . $this->widgetContext->getWidgetIdentifier());
     $subResponse = $this->objectManager->get('TYPO3\\Flow\\Http\\Response');
     $this->controller->processRequest($subRequest, $subResponse);
     return $subResponse;
 }
 /**
  * Initiate a sub request to $this->controller. Make sure to fill $this->controller
  * via Dependency Injection.
  *
  * @return Response the response of this request.
  * @throws Exception\MissingControllerException
  * @throws \TYPO3\Flow\Mvc\Exception\StopActionException
  * @throws \TYPO3\Flow\Mvc\Exception\InfiniteLoopException
  * @api
  */
 protected function initiateSubRequest()
 {
     if ($this->controller instanceof DependencyProxy) {
         $this->controller->_activateDependency();
     }
     if (!$this->controller instanceof AbstractWidgetController) {
         throw new Exception\MissingControllerException('initiateSubRequest() can not be called if there is no controller inside $this->controller. Make sure to add the @TYPO3\\Flow\\Annotations\\Inject annotation in your widget class.', 1284401632);
     }
     /** @var $subRequest ActionRequest */
     $subRequest = $this->objectManager->get(\TYPO3\Flow\Mvc\ActionRequest::class, $this->controllerContext->getRequest());
     /** @var $subResponse Response */
     $subResponse = $this->objectManager->get(\TYPO3\Flow\Http\Response::class, $this->controllerContext->getResponse());
     $this->passArgumentsToSubRequest($subRequest);
     $subRequest->setArgument('__widgetContext', $this->widgetContext);
     $subRequest->setArgumentNamespace('--' . $this->widgetContext->getWidgetIdentifier());
     $dispatchLoopCount = 0;
     while (!$subRequest->isDispatched()) {
         if ($dispatchLoopCount++ > 99) {
             throw new InfiniteLoopException('Could not ultimately dispatch the widget request after ' . $dispatchLoopCount . ' iterations.', 1380282310);
         }
         $widgetControllerObjectName = $this->widgetContext->getControllerObjectName();
         if ($subRequest->getControllerObjectName() !== '' && $subRequest->getControllerObjectName() !== $widgetControllerObjectName) {
             throw new Exception\InvalidControllerException(sprintf('You are not allowed to initiate requests to different controllers from a widget.' . chr(10) . 'widget controller: "%s", requested controller: "%s".', $widgetControllerObjectName, $subRequest->getControllerObjectName()), 1380284579);
         }
         $subRequest->setControllerObjectName($this->widgetContext->getControllerObjectName());
         try {
             $this->controller->processRequest($subRequest, $subResponse);
         } catch (StopActionException $exception) {
             if ($exception instanceof ForwardException) {
                 $subRequest = $exception->getNextRequest();
                 continue;
             }
             /** @var $parentResponse Response */
             $parentResponse = $this->controllerContext->getResponse();
             $parentResponse->setStatus($subResponse->getStatusCode())->setContent($subResponse->getContent())->setHeader('Location', $subResponse->getHeader('Location'));
             throw $exception;
         }
     }
     return $subResponse;
 }