/** * Parses the request data and returns it * * @param bool $includeQueryParameters * * @return array php data */ public function getRequestData($includeQueryParameters = true) { if (is_null($this->requestFromObject)) { $get = UrlEncodedFormat::decoderTypeFix($_GET); } else { $get = UrlEncodedFormat::decoderTypeFix($this->requestFromObject->getQuery()->getAll()); } if ($this->requestMethod == 'PUT' || $this->requestMethod == 'PATCH' || $this->requestMethod == 'POST') { if (!empty($this->requestData)) { return $includeQueryParameters ? $this->requestData + $get : $this->requestData; } if (is_null($this->requestFromObject)) { $stream = $this->getRequestStream(); if ($stream === FALSE) { return array(); } $r = $this->requestFormat instanceof iDecodeStream ? $this->requestFormat->decodeStream($stream) : $this->requestFormat->decode(stream_get_contents($stream)); } else { $r = $this->requestFormat->decode($this->requestFromObject->getBody()); } $r = is_array($r) ? array_merge($r, array(Defaults::$fullRequestDataName => $r)) : array(Defaults::$fullRequestDataName => $r); return $includeQueryParameters ? $r + $get : $r; } return $includeQueryParameters ? $get : array(); //no body }
/** * Parses the request data and returns it * * @return array php data */ public function getRequestData() { if ($this->requestMethod == 'PUT' || $this->requestMethod == 'PATCH' || $this->requestMethod == 'POST') { if (!empty($this->requestData)) { return $this->requestData; } try { $r = file_get_contents('php://input'); if (is_null($r)) { return array(); } $r = $this->requestFormat->decode($r); return is_null($r) ? array() : $r; } catch (RestException $e) { $this->handleError($e->getCode(), $e->getMessage()); } } return array(); }
/** * Parses the request data and returns it * * @param bool $includeQueryParameters * * @return array php data */ public function getRequestData($includeQueryParameters = true) { $get = UrlEncodedFormat::decoderTypeFix($_GET); if ($this->requestMethod == 'PUT' || $this->requestMethod == 'PATCH' || $this->requestMethod == 'POST') { if (!empty($this->requestData)) { return $includeQueryParameters ? $this->requestData + $get : $this->requestData; } $r = file_get_contents('php://input'); if (is_null($r)) { return array(); //no body } $r = $this->requestFormat->decode($r); $r = is_array($r) ? array_merge($r, array(Defaults::$fullRequestDataName => $r)) : array(Defaults::$fullRequestDataName => $r); return $includeQueryParameters ? $r + $get : $r; } return $includeQueryParameters ? $get : array(); //no body }