Ejemplo n.º 1
0
 /**
  * Get a Request object containing relevant properties
  *
  * @param \Slim\Route $route
  * @param             $params
  *
  * @return \Spore\ReST\Model\Request
  */
 private function getRequestData(\Slim\Route $route, $params)
 {
     $req = new Request();
     $app = $this->getApp();
     $env = $app->environment();
     $data = array();
     $body = $app->request()->getBody();
     $request = $app->request();
     // assign Slim URI params to Request::$params property
     if (!empty($params)) {
         $req->params = $params;
     }
     // assign deserialized HTTP request body to Request::$data property
     if (in_array("PUT", $route->getHttpMethods()) || in_array("POST", $route->getHttpMethods())) {
         // body was deserialized correctly
         if (!empty($body)) {
             $req->data = $body;
         } else {
             if (!empty($env['slim.request.form_hash']) || !empty($_FILES)) {
                 $req->data = $env['slim.request.form_hash'];
                 if (!empty($_FILES)) {
                     $req->files = $_FILES;
                 }
             }
         }
     }
     if (!empty($env["QUERY_STRING"])) {
         parse_str($env["QUERY_STRING"], $query);
         // assign parsed URL query string to Request::$queryParams property
         $req->queryParams = $query;
     }
     // set the Slim Request object
     $req->setRequest($request);
     return $req;
 }
Ejemplo n.º 2
0
 /**
  * @url            	/example10
  * @verbs        	GET
  * @template    	example.twig
  * @render        	nonAJAX
  */
 public function example10(Request $request)
 {
     return array("name" => "Twig", "description" => "the flexible, fast, and secure template engine for PHP", "url" => "http://twig.sensiolabs.org/", "ajax" => $request->request()->isAjax());
 }