/** * Process post data and call create * * This method is overridden from the AbstractRestfulController to allow * processing of multipart POSTs. * * @param Request $request * @return mixed */ public function processPostData(Request $request) { $contentType = $request->getHeader('content-type'); if ($contentType->match('multipart/form-data')) { $content = $request->getPost('data'); $fileData = $request->getFiles()->toArray(); } else { $content = $request->getContent(); $fileData = null; } $data = Json::decode($content, $this->jsonDecodeType); return $this->create($data, $fileData); }
/** * Extracts the directory paths from a CLI request * * Uses format of a URL query * * @param RequestInterface $request * @return array */ private function extractFromCli(RequestInterface $request) { if (!($request instanceof Request)) { return []; } $bootstrapParam = new ComplexParameter(self::BOOTSTRAP_PARAM); foreach ($request->getContent() as $paramStr) { $result = $bootstrapParam->getFromString($paramStr); if (!empty($result)) { return $result; } } return []; }
/** * Process put data and call update * * @param Request $request * @param $routeMatch * @return mixed * @throws Exception\DomainException */ public function processPutData(Request $request, $routeMatch) { if (null === ($id = $routeMatch->getParam('id'))) { if (!($id = $request->getQuery()->get('id', false))) { throw new Exception\DomainException('Missing identifier'); } } $content = $request->getContent(); parse_str($content, $parsedParams); return $this->update($id, $parsedParams); }