Exemplo n.º 1
0
 /**
  * prepareRequest
  *
  * @param string $uri in format "module/controllers"
  * @param array $params of request
  * @param string $method HTTP
  * @param bool $ajax
  * @return Http\Request
  */
 private function prepareRequest($uri, array $params = null, $method = Http\Request::METHOD_GET, $ajax = false)
 {
     Request::setRequestUri($uri);
     Request::setOptions(Config::getData('request'));
     Request::setMethod($method);
     // process $_GET params
     if ($query = stristr($uri, '?')) {
         $query = substr($query, 1);
         // remove `?` sign
         parse_str($query, $_GET);
         // fill $_GET
     }
     // process custom params
     if ($params) {
         Request::setParams($params);
     }
     if ($ajax) {
         $_SERVER['HTTP_ACCEPT'] = 'application/json';
         $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
     } else {
         $_SERVER['HTTP_ACCEPT'] = 'text/html';
     }
 }