/** * 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 * @author Robert Lemke <*****@*****.**> * @author Christopher Hlubek <*****@*****.**> */ public function getArguments() { if ($this->data === array()) { return array(); } $arguments = array(); if (!$this->request->isFormPost()) { $parameters = $this->reflectionService->getMethodParameters($this->getControllerObjectName(), $this->getControllerActionName() . '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; }
/** * Sends the response * * @param array $results The collected results from the transaction requests * @param Tx_Newsletter_MVC_ExtDirect_Request $extDirectRequest * @return void * @author Robert Lemke <*****@*****.**> */ protected function sendResponse(array $results, Tx_Newsletter_MVC_ExtDirect_Request $extDirectRequest) { $response = $this->objectManager->create('Tx_Extbase_MVC_Web_Response'); $jsonResponse = json_encode(count($results) === 1 ? $results[0] : $results); if ($extDirectRequest->isFormPost() && $extDirectRequest->isFileUpload()) { $response->setHeader('Content-Type', 'text/html'); $response->setContent('<html><body><textarea>' . $jsonResponse . '</textarea></body></html>'); } else { $response->setHeader('Content-Type', 'application/json'); $response->setContent($jsonResponse); } return $response; }