You are here

interface FileMetadataPluginInterface in File metadata manager 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/FileMetadataPluginInterface.php \Drupal\file_mdm\Plugin\FileMetadataPluginInterface

Provides an interface defining a FileMetadata plugin.

Hierarchy

Expanded class hierarchy of FileMetadataPluginInterface

All classes that implement FileMetadataPluginInterface

1 file declares its use of FileMetadataPluginInterface
FileMetadataPluginBase.php in src/Plugin/FileMetadata/FileMetadataPluginBase.php

File

src/Plugin/FileMetadataPluginInterface.php, line 12

Namespace

Drupal\file_mdm\Plugin
View source
interface FileMetadataPluginInterface extends ContainerFactoryPluginInterface, PluginInspectionInterface, PluginFormInterface {

  /**
   * Gets default configuration for this plugin.
   *
   * @return array
   *   An associative array with the default configuration.
   */
  public static function defaultConfiguration();

  /**
   * Sets the URI of the file.
   *
   * @param string $uri
   *   A URI.
   *
   * @return $this
   *
   * @throws \Drupal\file_mdm\FileMetadataException
   *   If no URI is specified.
   */
  public function setUri($uri);

  /**
   * Gets the URI of the file.
   *
   * @return string
   *   The URI of the file.
   */
  public function getUri();

  /**
   * Sets the local filesystem path to the file.
   *
   * This is used to allow accessing local copies of files stored remotely, to
   * minimise remote calls and allow functions that cannot access remote stream
   * wrappers to operate locally.
   *
   * @param string $temp_path
   *   A filesystem path.
   *
   * @return $this
   */
  public function setLocalTempPath($temp_path);

  /**
   * Gets the local filesystem path to the file.
   *
   * This is used to allow accessing local copies of files stored remotely, to
   * minimise remote calls and allow functions that cannot access remote stream
   * wrappers to operate locally.
   *
   * @return string
   *   The local filesystem path to the file.
   */
  public function getLocalTempPath();

  /**
   * Sets the hash used to reference the URI by the metadata manager.
   *
   * @param string $hash
   *   A hash string.
   *
   * @return $this
   *
   * @throws \Drupal\file_mdm\FileMetadataException
   *   If no hash is specified.
   */
  public function setHash($hash);

  /**
   * Returns a list of metadata keys supported by the plugin.
   *
   * @param mixed $options
   *   (optional) Allows specifying additional options to control the list of
   *   metadata keys returned.
   *
   * @return array
   *   A simple array of metadata keys supported.
   */
  public function getSupportedKeys($options = NULL);

  /**
   * Checks if file metadata has been already loaded.
   *
   * @return bool
   *   TRUE if metadata is loaded, FALSE otherwise.
   */
  public function isMetadataLoaded();

  /**
   * Loads file metadata from an in-memory object/array.
   *
   * @param mixed $metadata
   *   The file metadata associated to the file at URI.
   *
   * @return bool
   *   TRUE if metadata was loaded successfully, FALSE otherwise.
   */
  public function loadMetadata($metadata);

  /**
   * Loads file metadata from the file at URI/local path.
   *
   * @return bool
   *   TRUE if metadata was loaded successfully, FALSE otherwise.
   *
   * @throws \Drupal\file_mdm\FileMetadataException
   *   In case there were significant errors reading from file.
   */
  public function loadMetadataFromFile();

  /**
   * Loads file metadata from a cache entry.
   *
   * @return bool
   *   TRUE if metadata was loaded successfully, FALSE otherwise.
   *
   * @throws \Drupal\file_mdm\FileMetadataException
   *   In case of significant errors.
   */
  public function loadMetadataFromCache();

  /**
   * Gets a metadata element.
   *
   * @param mixed|null $key
   *   A key to determine the metadata element to be returned. If NULL, the
   *   entire metadata will be returned.
   *
   * @return mixed
   *   The value of the element specified by $key. If $key is NULL, the entire
   *   metadata.
   */
  public function getMetadata($key = NULL);

  /**
   * Sets a metadata element.
   *
   * @param mixed $key
   *   A key to determine the metadata element to be changed.
   * @param mixed $value
   *   The value to change the metadata element to.
   *
   * @return bool
   *   TRUE if metadata was changed successfully, FALSE otherwise.
   */
  public function setMetadata($key, $value);

  /**
   * Removes a metadata element.
   *
   * @param mixed $key
   *   A key to determine the metadata element to be removed.
   *
   * @return bool
   *   TRUE if metadata was removed successfully, FALSE otherwise.
   */
  public function removeMetadata($key);

  /**
   * Determines if plugin is capable of writing metadata to files.
   *
   * @return bool
   *   TRUE if plugin can save data to files, FALSE otherwise.
   */
  public function isSaveToFileSupported();

  /**
   * Saves metadata to file at URI.
   *
   * @return bool
   *   TRUE if metadata was saved successfully, FALSE otherwise.
   */
  public function saveMetadataToFile();

  /**
   * Caches metadata for file at URI.
   *
   * Uses the 'file_mdm' cache bin.
   *
   * @param array $tags
   *   (optional) An array of cache tags to save to cache.
   *
   * @return bool
   *   TRUE if metadata was saved successfully, FALSE otherwise.
   */
  public function saveMetadataToCache(array $tags = []);

  /**
   * Removes cached metadata for file at URI.
   *
   * Uses the 'file_mdm' cache bin.
   *
   * @return bool
   *   TRUE if metadata was removed, FALSE otherwise.
   */
  public function deleteCachedMetadata();

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerFactoryPluginInterface::create public static function Creates an instance of the plugin. 112
FileMetadataPluginInterface::defaultConfiguration public static function Gets default configuration for this plugin. 1
FileMetadataPluginInterface::deleteCachedMetadata public function Removes cached metadata for file at URI. 1
FileMetadataPluginInterface::getLocalTempPath public function Gets the local filesystem path to the file. 1
FileMetadataPluginInterface::getMetadata public function Gets a metadata element. 1
FileMetadataPluginInterface::getSupportedKeys public function Returns a list of metadata keys supported by the plugin. 3
FileMetadataPluginInterface::getUri public function Gets the URI of the file. 1
FileMetadataPluginInterface::isMetadataLoaded public function Checks if file metadata has been already loaded. 1
FileMetadataPluginInterface::isSaveToFileSupported public function Determines if plugin is capable of writing metadata to files. 1
FileMetadataPluginInterface::loadMetadata public function Loads file metadata from an in-memory object/array. 1
FileMetadataPluginInterface::loadMetadataFromCache public function Loads file metadata from a cache entry. 1
FileMetadataPluginInterface::loadMetadataFromFile public function Loads file metadata from the file at URI/local path. 1
FileMetadataPluginInterface::removeMetadata public function Removes a metadata element. 1
FileMetadataPluginInterface::saveMetadataToCache public function Caches metadata for file at URI. 1
FileMetadataPluginInterface::saveMetadataToFile public function Saves metadata to file at URI. 1
FileMetadataPluginInterface::setHash public function Sets the hash used to reference the URI by the metadata manager. 1
FileMetadataPluginInterface::setLocalTempPath public function Sets the local filesystem path to the file. 1
FileMetadataPluginInterface::setMetadata public function Sets a metadata element. 1
FileMetadataPluginInterface::setUri public function Sets the URI of the file. 1
PluginFormInterface::buildConfigurationForm public function Form constructor. 36
PluginFormInterface::submitConfigurationForm public function Form submission handler. 32
PluginFormInterface::validateConfigurationForm public function Form validation handler. 18
PluginInspectionInterface::getPluginDefinition public function Gets the definition of the plugin implementation. 4
PluginInspectionInterface::getPluginId public function Gets the plugin_id of the plugin instance. 2