Esempio n. 1
0
 /**
  * @param string $json a json string, if omitted, request params will be used to built json string
  * @return self
  */
 public function json($json = null)
 {
     $this->request->headers->set('content-type', 'application/json');
     $this->request->headers->set('charset', 'utf-8');
     $this->request->headers->set('accept', 'application/json');
     if ($this->request->getMethod() !== "GET") {
         $json = $json === null ? json_encode($this->request->request->all()) : (string) $json;
         $this->request->setContent($json);
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Creates a Request based on a given URI and configuration.
  *
  * The information contained in the URI always take precedence
  * over the other information (server and parameters).
  *
  * @param string $uri        The URI
  * @param string $method     The HTTP method
  * @param array  $parameters The query (GET) or request (POST) parameters
  * @param array  $cookies    The request cookies ($_COOKIE)
  * @param array  $files      The request files ($_FILES)
  * @param array  $server     The server parameters ($_SERVER)
  * @param string $content    The raw body data
  *
  * @return \Symfony\Component\HttpFoundation\Request
  */
 protected function createRequest($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
 {
     return Request::create($uri, $method, $parameters, $cookies, $files, array(), $content);
 }