Пример #1
0
 public function merge(ParameterBag $bag)
 {
     foreach ($bag->all() as $key => $value) {
         $this->set($key, $value);
     }
     return $this;
 }
Пример #2
0
 /**
  * Populate $input variable with Request
  */
 private function populateInput()
 {
     // If already populate, return
     if ($this->input) {
         return;
     }
     if ($this->isJson()) {
         $json = new ParameterBag((array) json_decode($this->getContent(), true));
         $this->input = $json->all();
     }
     // GET
     $get = $this->query->all();
     // POST
     $post = $this->request->all();
     $this->input = array_merge($get, $post);
 }
Пример #3
0
 /**
  * @return array
  */
 public function all()
 {
     return array_merge_recursive($this->query->all(), $this->request->all());
 }
Пример #4
0
 /**
  * Overrides the PHP global variables according to this request instance.
  *
  * It overrides $_GET, $_POST, $_REQUEST, $_SERVER, $_COOKIE.
  * $_FILES is never overridden, see rfc1867
  */
 public function overrideGlobals()
 {
     $this->server->set('QUERY_STRING', static::normalizeQueryString(http_build_query($this->query->all(), NULL, '&')));
     $_GET = $this->query->all();
     $_POST = $this->request->all();
     $_SERVER = $this->server->all();
     $_COOKIE = $this->cookies->all();
     foreach ($this->headers->all() as $key => $value) {
         $key = strtoupper(str_replace('-', '_', $key));
         if (in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH'])) {
             $_SERVER[$key] = implode(', ', $value);
         } else {
             $_SERVER['HTTP_' . $key] = implode(', ', $value);
         }
     }
     $request = ['g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE];
     $requestOrder = ini_get('request_order') ?: ini_get('variables_order');
     $requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
     $_REQUEST = [];
     foreach (str_split($requestOrder) as $order) {
         $_REQUEST = array_merge($_REQUEST, $request[$order]);
     }
 }