コード例 #1
0
ファイル: Web.php プロジェクト: clickalicious/doozr
 /**
  * Receive method.
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return bool TRUE on success, otherwise FALSE
  */
 public function receive()
 {
     // Set valid request sources
     $this->setRequestSources($this->emitValidRequestSources(DOOZR_RUNTIME_ENVIRONMENT));
     // HTTP Version of the request made
     $protocolVersion = explode('/', isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : '/');
     // Store protocol version
     $this->withProtocolVersion(true === isset($protocolVersion[1]) ? $protocolVersion[1] : '1.0');
     // Store headers normalized to prevent System/OS/PHP mismatches
     $headers = $this->normalizeHeaders(getallheaders());
     foreach ($headers as $header => $value) {
         $this->withHeader($header, $value);
     }
     // Receive and store request method (HTTP verb)
     $this->withMethod($this->receiveMethod());
     // Emulate the request in case of PUT ...
     $this->equalizeRequestArguments($this->getMethod(), $headers);
     // Store cookies
     $this->withCookieParams($_COOKIE);
     // Parse upload(s) in PSR-7 more/better logical structure (some array shuffling)
     $uploadedFileFactory = new Doozr_Request_File_UploadedFileFactory($_FILES);
     $uploadedFiles = $uploadedFileFactory->build();
     $this->withUploadedFiles($uploadedFiles);
     // Store query params as array
     $queryArguments = [];
     parse_str($_SERVER['QUERY_STRING'], $queryArguments);
     $this->withQueryParams($queryArguments);
     // Detect if Ajax and set flag
     $this->withAttribute('isAjax', $this->isAjax());
     // Store body arguments (_POST _PUT ...) as parsed body representation
     $this->withParsedBody($this->receiveArguments($this->getMethod()));
     // Set the request target!
     $this->withRequestTarget($this->getUri()->getPath());
     return true;
 }
コード例 #2
0
 /**
  * Setter for parsedUploadedFiles.
  *
  * @param array $parsedUploadedFiles Value for parsedUploadedFiles to set.
  *
  * @author Benjamin Carl <*****@*****.**>
  */
 protected function setParsedUploadedFiles(array $parsedUploadedFiles)
 {
     self::$parsedUploadedFiles = $parsedUploadedFiles;
 }