Beispiel #1
0
 /**
  * Ext Direct does not provide named arguments by now, so we have
  * to map them by reflecting on the action parameters.
  *
  * @return array The mapped arguments
  */
 public function getArguments()
 {
     if ($this->data === array()) {
         return array();
     }
     $arguments = array();
     if (!$this->request->isFormPost()) {
         $parameters = $this->reflectionService->getMethodParameters($this->getControllerObjectName(), $this->method . 'Action');
         // TODO Add checks for parameters
         foreach ($parameters as $name => $options) {
             $parameterIndex = $options['position'];
             if (isset($this->data[$parameterIndex])) {
                 $arguments[$name] = $this->convertObjectToArray($this->data[$parameterIndex]);
             }
         }
     } else {
         // TODO Reuse setArgumentsFromRawRequestData from Web/RequestBuilder
     }
     return $arguments;
 }
Beispiel #2
0
 /**
  * Prepares the response by setting content and content type as needed.
  *
  * @param array $results The collected results from the transaction requests
  * @param \TYPO3\ExtJS\ExtDirect\Request $extDirectRequest
  * @return void
  */
 protected function prepareResponse(array $results, Request $extDirectRequest = NULL)
 {
     $responseData = json_encode(count($results) === 1 ? $results[0] : $results);
     if ($extDirectRequest !== NULL && $extDirectRequest->isFormPost() && $extDirectRequest->isFileUpload()) {
         $this->response->setContent('<html><body><textarea>' . $responseData . '</textarea></body></html>');
     } else {
         $this->response->setHeader('Content-Type', 'text/javascript');
         $this->response->setContent($responseData);
     }
 }