Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. class Request extends Kohana_Request {
  2.  
  3.     /**
  4.      * Creates a new request object for the given URI. This differs from
  5.      * [Request::instance] in that it does not automatically detect the URI
  6.      * and should only be used for creating HMVC requests.
  7.      * @param   string  URI of the request
  8.      * @param   array   $params An array of various paramaters that should be set when using an HMVC request
  9.      * @return  Request
  10.      */
  11.    
  12.     public static function factory($uri, Kohana_Cache $cache = NULL, array $params = NULL)
  13.     {
  14.         if ($params)
  15.         {
  16.             foreach ($params as $key => $value)
  17.             {  
  18.                 if ($key === 'server')
  19.                 {
  20.                     array_unshift($value, '--uri='.$uri);
  21.                     array_unshift($value, DOCROOT.'index'.EXT);
  22.                    
  23.                     $_SERVER['argv'] = $value;
  24.                     $_SERVER['argc'] = count($value);
  25.                 }
  26.                 elseif ($key === 'get')
  27.                 {
  28.                     $_GET = $value;
  29.                 }
  30.                 elseif ($key === 'post')
  31.                 {
  32.                     $_POST = $value;
  33.                 }
  34.             }
  35.         }
  36.         return new Request($uri);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement