Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function set($key, $value)
 {
     if (!is_array($value) && !$value instanceof UploadedFile) {
         throw new \InvalidArgumentException('An uploaded file must be an array or an instance of FilesystemFile.');
     }
     parent::set($key, $this->convertFileInformation($value));
 }
Ejemplo n.º 2
0
 /**
  * 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;
     }
 }