You are here

public function FileMetadata::getFileMetadataPlugin in File metadata manager 8

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

Gets a FileMetadata plugin instance.

Parameters

string $metadata_id: The id of the plugin whose instance is to be returned. If it is does not exist, an instance is created.

Return value

\Drupal\file_mdm\Plugin\FileMetadataPluginInterface|null The FileMetadata plugin instance. NULL if no plugin is found.

Overrides FileMetadataInterface::getFileMetadataPlugin

9 calls to FileMetadata::getFileMetadataPlugin()
FileMetadata::getMetadata in src/FileMetadata.php
Gets a metadata element.
FileMetadata::getSupportedKeys in src/FileMetadata.php
Returns a list of supported metadata keys.
FileMetadata::isMetadataLoaded in src/FileMetadata.php
Checks if file metadata has been already loaded.
FileMetadata::loadMetadata in src/FileMetadata.php
Loads file metadata.
FileMetadata::loadMetadataFromCache in src/FileMetadata.php
Loads file metadata from a cache entry.

... See full list

File

src/FileMetadata.php, line 143

Class

FileMetadata
A file metadata object.

Namespace

Drupal\file_mdm

Code

public function getFileMetadataPlugin($metadata_id) {
  if (!isset($this->plugins[$metadata_id])) {
    try {
      $this->plugins[$metadata_id] = $this->pluginManager
        ->createInstance($metadata_id);
      $this->plugins[$metadata_id]
        ->setUri($this->uri);
      $this->plugins[$metadata_id]
        ->setLocalTempPath($this->localTempPath ?: $this->uri);
      $this->plugins[$metadata_id]
        ->setHash($this->hash);
    } catch (PluginNotFoundException $e) {
      return NULL;
    }
  }
  return $this->plugins[$metadata_id];
}