Example #1
0
 /**
  * Create a new request using PHP's super globals.
  * 
  * @param \Darya\Http\Session $session [optional]
  * @return \Darya\Http\Request
  */
 public static function createFromGlobals(Session $session = null)
 {
     $request = Request::create($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD'], array('get' => $_GET, 'post' => $_POST, 'cookie' => $_COOKIE, 'file' => $_FILES, 'server' => $_SERVER, 'header' => static::headersFromGlobals($_SERVER)), $session);
     return $request;
 }
Example #2
0
 /**
  * Instantiates a new request using the given argument.
  *
  * @param Request|string $request
  * @return Request
  */
 public static function prepareRequest($request)
 {
     if (!$request instanceof Request) {
         $request = Request::create($request);
     }
     return $request;
 }