/**
  * Redirecting the user after the processing has been done.
  * Might also display error messages directly, if any.
  *
  * @return void
  * @todo Define visibility
  */
 public function finish()
 {
     // Prints errors, if...
     if ($this->prErr) {
         $this->tce->printLogErrorMessages($this->redirect);
     }
     if ($this->redirect && !$this->tce->debug) {
         \TYPO3\CMS\Core\Utility\HttpUtility::redirect($this->redirect);
     }
 }
Exemplo n.º 2
0
 /**
  * Processes all AJAX calls and returns a JSON formatted string
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     // do the regular / main logic
     $this->initClipboard();
     $this->main();
     /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
     $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
     $content = ['redirect' => $this->redirect, 'messages' => [], 'hasErrors' => false];
     // Prints errors (= write them to the message queue)
     if ($this->prErr) {
         $content['hasErrors'] = true;
         $this->tce->printLogErrorMessages($this->redirect);
     }
     $messages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush();
     if (!empty($messages)) {
         foreach ($messages as $message) {
             $content['messages'][] = ['title' => $message->getTitle(), 'message' => $message->getMessage(), 'severity' => $message->getSeverity()];
             if ($message->getSeverity() === AbstractMessage::ERROR) {
                 $content['hasErrors'] = true;
             }
         }
     }
     $response->getBody()->write(json_encode($content));
     return $response;
 }
 /**
  * Processes all AJAX calls and returns a JSON formatted string
  *
  * @param array $parameters
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxRequestHandler
  */
 public function processAjaxRequest($parameters, AjaxRequestHandler $ajaxRequestHandler)
 {
     // do the regular / main logic
     $this->initClipboard();
     $this->main();
     /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
     $flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
     $content = array('redirect' => $this->redirect, 'messages' => array(), 'hasErrors' => FALSE);
     // Prints errors (= write them to the message queue)
     if ($this->prErr) {
         $content['hasErrors'] = TRUE;
         $this->tce->printLogErrorMessages($this->redirect);
     }
     $messages = $flashMessageService->getMessageQueueByIdentifier()->getAllMessagesAndFlush();
     if (!empty($messages)) {
         foreach ($messages as $message) {
             $content['messages'][] = array('title' => $message->getTitle(), 'message' => $message->getMessage(), 'severity' => $message->getSeverity());
             if ($message->getSeverity() === AbstractMessage::ERROR) {
                 $content['hasErrors'] = TRUE;
             }
         }
     }
     $ajaxRequestHandler->setContentFormat('json');
     $ajaxRequestHandler->setContent($content);
 }