/** * Creates a new Model with the data from the request * * @return array|integer Returns the Model's data on success, otherwise a descriptive error code */ public function create() { /* MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM */ /* CREATE */ /* MWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWMWM */ $dataProvider = $this->getDataProvider(); $request = $this->getRequest(); $data = $request->getSentData(); Dispatcher::getSharedDispatcher()->logRequest('create request', array('body' => $data)); /** * @var \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $model */ $model = $dataProvider->getModelWithDataForPath($data, $this->getPath()); if (!$model) { return $this->responseFactory->createSuccessResponse(NULL, 400); } $dataProvider->saveModelForPath($model, $this->getPath()); $result = $dataProvider->getModelData($model); if ($this->objectManager->getConfigurationProvider()->getSetting('addRootObjectForCollection')) { return array(Utility::singularize($request->getRootObjectKey()) => $result); } return $result; }
/** * Returns a response with the given message and status code * * @param string|array $data * @param int $status * @return Response * @deprecated use ResponseFactory->createSuccessResponse() */ public function createSuccessResponse($data, $status) { \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction(); return $this->responseFactory->createSuccessResponse($data, $status); }