/**
  * error action
  */
 public function errorAction()
 {
     $this->clearCacheOnError();
     if ($this->arguments instanceof Arguments) {
         $validationResult = $this->arguments->getValidationResults();
         if ($validationResult->hasErrors()) {
             $referringRequest = $this->request->getReferringRequest();
             if ($referringRequest !== null) {
                 $originalRequest = clone $this->request;
                 $this->request->setOriginalRequest($originalRequest);
                 $this->request->setOriginalRequestMappingResults($this->arguments->getValidationResults());
                 $this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $referringRequest->getControllerExtensionName(), $referringRequest->getArguments());
             }
         }
     }
     // clear any previous flashmessage in order to avoid double entries
     $flashMessageQueue = $this->getFlashMessageQueue();
     if ($flashMessageQueue instanceof FlashMessageQueue) {
         $flashMessageQueue->__call('getAllMessagesAndFlush', []);
     }
     $this->addFlashMessage($this->getErrorFlashMessage(), '', FlashMessage::ERROR);
     $this->session->clean();
 }
Esempio n. 2
0
 /**
  * A special action which is called if the originally intended action could
  * not be called, for example if the arguments were not valid.
  *
  * The default implementation sets a flash message, request errors and forwards back
  * to the originating action. This is suitable for most actions dealing with form input.
  *
  * We clear the page cache by default on an error as well, as we need to make sure the
  * data is re-evaluated when the user changes something.
  *
  * @return string
  * @api
  */
 protected function errorAction()
 {
     $this->clearCacheOnError();
     $errorFlashMessage = $this->getErrorFlashMessage();
     if ($errorFlashMessage !== FALSE) {
         $errorFlashMessageObject = new \TYPO3\CMS\Core\Messaging\FlashMessage($errorFlashMessage, '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         $this->controllerContext->getFlashMessageQueue()->enqueue($errorFlashMessageObject);
     }
     $referringRequest = $this->request->getReferringRequest();
     if ($referringRequest !== NULL) {
         $originalRequest = clone $this->request;
         $this->request->setOriginalRequest($originalRequest);
         $this->request->setOriginalRequestMappingResults($this->arguments->getValidationResults());
         $this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $referringRequest->getControllerExtensionName(), $referringRequest->getArguments());
     }
     $message = 'An error occurred while trying to call ' . get_class($this) . '->' . $this->actionMethodName . '().' . PHP_EOL;
     return $message;
 }
Esempio n. 3
0
 /**
  * If information on the request before the current request was sent, this method forwards back
  * to the originating request. This effectively ends processing of the current request, so do not
  * call this method before you have finished the necessary business logic!
  *
  * @return void
  * @throws StopActionException
  */
 protected function forwardToReferringRequest()
 {
     $referringRequest = $this->request->getReferringRequest();
     if ($referringRequest !== null) {
         $originalRequest = clone $this->request;
         $this->request->setOriginalRequest($originalRequest);
         $this->request->setOriginalRequestMappingResults($this->arguments->getValidationResults());
         $this->forward($referringRequest->getControllerActionName(), $referringRequest->getControllerName(), $referringRequest->getControllerExtensionName(), $referringRequest->getArguments());
     }
 }