예제 #1
0
 /**
  * Handles the actual process from within the ajaxExec function
  * therefore, it does exactly the same as the real typo3/tce_file.php
  * but without calling the "finish" method, thus makes it simpler to deal with the
  * actual return value
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function processAjaxRequest(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->main();
     $errors = $this->fileProcessor->getErrorMessages();
     if (!empty($errors)) {
         $response->getBody()->write(implode(',', $errors));
         $response = $response->withHeader('Content-Type', 'text/html; charset=utf-8');
     } else {
         $flatResult = array();
         foreach ($this->fileData as $action => $results) {
             foreach ($results as $result) {
                 if (is_array($result)) {
                     foreach ($result as $subResult) {
                         $flatResult[$action][] = $this->flattenResultDataValue($subResult);
                     }
                 } else {
                     $flatResult[$action][] = $this->flattenResultDataValue($result);
                 }
             }
         }
         $content = ['result' => $flatResult];
         if ($this->redirect) {
             $content['redirect'] = $this->redirect;
         }
         $response->getBody()->write(json_encode($content));
     }
     return $response;
 }
예제 #2
0
 /**
  * Handles the actual process from within the ajaxExec function
  * therefore, it does exactly the same as the real typo3/tce_file.php
  * but without calling the "finish" method, thus makes it simpler to deal with the
  * actual return value
  *
  * @param array $params Always empty.
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object used to return content and set content types
  * @return void
  */
 public function processAjaxRequest(array $params, \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj)
 {
     $this->init();
     $this->main();
     $errors = $this->fileProcessor->getErrorMessages();
     if (!empty($errors)) {
         $ajaxObj->setError(implode(',', $errors));
     } else {
         $flatResult = array();
         foreach ($this->fileData as $action => $results) {
             foreach ($results as $result) {
                 if (is_array($result)) {
                     foreach ($result as $subResult) {
                         $flatResult[$action][] = $this->flattenResultDataValue($subResult);
                     }
                 } else {
                     $flatResult[$action][] = $this->flattenResultDataValue($result);
                 }
             }
         }
         $ajaxObj->addContent('result', $flatResult);
         if ($this->redirect) {
             $ajaxObj->addContent('redirect', $this->redirect);
         }
         $ajaxObj->setContentFormat('json');
     }
 }