/** * Update the current stored file * * @return bool * @since 3.7.0 */ public function update() { $user = JFactory::getUser(); $date = JFactory::getDate(); if (empty($this->fileProperties)) { return false; } $path = str_replace(JPATH_ROOT . '/', '', dirname($this->fileProperties['path'])); $hash = null; if ($this->fileAdapter instanceof MediaModelFileAdapterInterfaceAdapter) { $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); // Get the table $table = JTable::getInstance('File', 'MediaTable'); if (!$table->save($data)) { throw new RuntimeException($table->getError()); } return $this->id; }