You are here

public function FileMetadataPluginBase::saveMetadataToFile in File metadata manager 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/FileMetadata/FileMetadataPluginBase.php \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase::saveMetadataToFile()

Saves metadata to file at URI.

Return value

bool TRUE if metadata was saved successfully, FALSE otherwise.

Overrides FileMetadataPluginInterface::saveMetadataToFile

File

src/Plugin/FileMetadata/FileMetadataPluginBase.php, line 481

Class

FileMetadataPluginBase
Abstract implementation of a base File Metadata plugin.

Namespace

Drupal\file_mdm\Plugin\FileMetadata

Code

public function saveMetadataToFile() {
  if (!$this
    ->isSaveToFileSupported()) {
    throw new FileMetadataException('Write metadata to file is not supported', $this
      ->getPluginId(), __FUNCTION__);
  }
  if ($this->metadata === NULL) {
    return FALSE;
  }
  if ($this->hasMetadataChangedFromFileVersion) {

    // Clears cache so that next time metadata will be fetched from file.
    $this
      ->deleteCachedMetadata();
    return $this
      ->doSaveMetadataToFile();
  }
  return FALSE;
}