Exemplo n.º 1
0
 /**
  * Update the current stored file
  *
  * @return bool
  */
 protected function update()
 {
     if (empty($this->fileProperties)) {
         return false;
     }
     $user = JFactory::getUser();
     $date = JFactory::getDate();
     $table = JTable::getInstance('File', 'MediaTable');
     $path = str_replace(JPATH_ROOT . '/', '', dirname($this->fileProperties['path']));
     $hash = null;
     if ($this->fileAdapter instanceof MediaModelFileAdapterInterface) {
         $hash = $this->fileAdapter->getHash();
     }
     $data = array('id' => $this->id, 'filename' => basename($this->fileProperties['path']), 'path' => $path, 'md5sum' => $hash, 'user_id' => $user->id, 'modified_by' => $user->id, 'modified' => $date->toSql(), 'adapter' => 'local', 'published' => 1, 'ordering' => 1);
     if (!$table->save($data)) {
         throw RuntimeException($table->getError());
         return false;
     }
     return $this->id;
 }