You are here

public function FileMetadataPluginBase::loadMetadataFromCache 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::loadMetadataFromCache()

Loads file metadata from a cache entry.

Return value

bool TRUE if metadata was loaded successfully, FALSE otherwise.

Throws

\Drupal\file_mdm\FileMetadataException In case of significant errors.

Overrides FileMetadataPluginInterface::loadMetadataFromCache

1 call to FileMetadataPluginBase::loadMetadataFromCache()
FileMetadataPluginBase::getMetadata in src/Plugin/FileMetadata/FileMetadataPluginBase.php
Gets a metadata element.

File

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

Class

FileMetadataPluginBase
Abstract implementation of a base File Metadata plugin.

Namespace

Drupal\file_mdm\Plugin\FileMetadata

Code

public function loadMetadataFromCache() {
  $plugin_id = $this
    ->getPluginId();
  $this->hasMetadataChangedFromFileVersion = FALSE;
  $this->hasMetadataChangedFromCacheVersion = FALSE;
  if ($this
    ->isUriFileMetadataCacheable() !== FALSE && ($cache = $this->cache
    ->get("hash:{$plugin_id}:{$this->hash}"))) {
    $this->metadata = $cache->data;
    $this->isMetadataLoaded = FileMetadataInterface::LOADED_FROM_CACHE;
  }
  else {
    $this->metadata = NULL;
    $this->isMetadataLoaded = FileMetadataInterface::NOT_LOADED;
  }
  return (bool) $this->metadata;
}