Example #1
0
 public function getValue()
 {
     if ($this->isUploaded()) {
         // new id, if i always fetch a new entity for every upload
         if ($this->_value === null) {
             $this->_value = $this->_fileRepository->fetchNew();
         } else {
             $this->_value->update = new \DateTime();
         }
         $info = $this->getFileInfo();
         $this->_value->name = $info[$this->_name]['name'];
         $this->_value->mimetype = $info[$this->_name]['type'];
         $this->_value->data = file_get_contents($info[$this->_name]['tmp_name']);
         $this->_value->size = $info[$this->_name]['size'];
     } else {
         if (isset($_FILES[$this->getName()])) {
             $this->_value = null;
         }
     }
     return $this->_value;
 }