/** * check whether a an XMLHttpRequest was submitted * this will look for a key 'xmlHttpRequest' in both GET and POST and * set the Controller::isXhr flag and * decode the parameters accordingly into their ParameterBages * in addition the presence of ifuRequest in GET is checked for handling IFRAME uploads * * this method is geared to fully support the vxJS.widget.xhrForm() */ private function prepareForXhr() { // do we have a GET XHR? if ($this->request->getMethod() === 'GET' && $this->request->query->get('xmlHttpRequest')) { $this->xhrBag = $this->request->query; foreach (json_decode($this->xhrBag->get('xmlHttpRequest'), TRUE) as $key => $value) { $this->xhrBag->set($key, $value); } } else { if ($this->request->getMethod() === 'POST' && $this->request->request->get('xmlHttpRequest')) { $this->xhrBag = $this->request->request; foreach (json_decode($this->xhrBag->get('xmlHttpRequest'), TRUE) as $key => $value) { $this->xhrBag->set($key, $value); } } else { if ($this->request->query->get('ifuRequest')) { // POST already contains all the parameters $this->request->request->set('httpRequest', 'ifuSubmit'); } else { $this->isXhr = FALSE; return; } } } $this->isXhr = TRUE; // handle request for apc upload poll, this will not be left to individual controller if ($this->xhrBag && $this->xhrBag->get('httpRequest') === 'apcPoll') { $id = $this->xhrBag->get('id'); if ($this->config->server['apc_on'] && $id) { $apcData = apc_fetch('upload_' . $id); } if (isset($apcData['done']) && $apcData['done'] == 1) { apc_clear_cache('user'); } JsonResponse::create($apcData)->send(); exit; } }
/** * initialize parameter bag * parameterbag is either supplied, or depending on request method retrieved from request object * * @param ParameterBag $bag * @return HtmlForm * */ public function bindRequestParameters(ParameterBag $bag = NULL) { if ($bag) { $this->requestValues = $bag; } else { if ($this->request->getMethod() == 'GET') { $this->requestValues = $this->request->query; } else { $this->requestValues = $this->request->request; } } // set form element values foreach ($this->elements as $name => $element) { if (is_array($element)) { $this->setElementArrayRequestValue($name); } else { $this->setElementRequestValue($element); } } return $this; }