You are here

public function FileMetadataPluginBase::loadMetadata in File metadata manager 8

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

Loads file metadata from an in-memory object/array.

Parameters

mixed $metadata: The file metadata associated to the file at URI.

Return value

bool TRUE if metadata was loaded successfully, FALSE otherwise.

Overrides FileMetadataPluginInterface::loadMetadata

File

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

Class

FileMetadataPluginBase
Abstract implementation of a base File Metadata plugin.

Namespace

Drupal\file_mdm\Plugin\FileMetadata

Code

public function loadMetadata($metadata) {
  $this->metadata = $metadata;
  $this->hasMetadataChangedFromFileVersion = TRUE;
  $this->hasMetadataChangedFromCacheVersion = TRUE;
  $this
    ->deleteCachedMetadata();
  if ($this->metadata === NULL) {
    $this->isMetadataLoaded = FileMetadataInterface::NOT_LOADED;
  }
  else {
    $this->isMetadataLoaded = FileMetadataInterface::LOADED_BY_CODE;
    $this
      ->saveMetadataToCache();
  }
  return (bool) $this->metadata;
}