You are here

interface FileMetadataInterface in File metadata manager 8.2

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

Provides an interface for file metadata objects.

Hierarchy

Expanded class hierarchy of FileMetadataInterface

All classes that implement FileMetadataInterface

5 files declare their use of FileMetadataInterface
FileMetadataExifTest.php in file_mdm_exif/tests/src/Kernel/FileMetadataExifTest.php
FileMetadataFontTest.php in file_mdm_font/tests/src/Kernel/FileMetadataFontTest.php
FileMetadataManagerTest.php in tests/src/Kernel/FileMetadataManagerTest.php
FileMetadataManagerTestBase.php in tests/src/Kernel/FileMetadataManagerTestBase.php
FileMetadataPluginBase.php in src/Plugin/FileMetadata/FileMetadataPluginBase.php

File

src/FileMetadataInterface.php, line 8

Namespace

Drupal\file_mdm
View source
interface FileMetadataInterface {

  /**
   * Metadata not loaded.
   */
  const NOT_LOADED = 0;

  /**
   * Metadata loaded by code.
   */
  const LOADED_BY_CODE = 1;

  /**
   * Metadata loaded from cache.
   */
  const LOADED_FROM_CACHE = 2;

  /**
   * Metadata loaded from file.
   */
  const LOADED_FROM_FILE = 3;

  /**
   * Gets the URI of the file.
   *
   * @return string|null
   *   The URI of the file, or a local path.
   */
  public function getUri();

  /**
   * Gets the local filesystem URI to the temporary file.
   *
   * @return string|null
   *   The URI, or a local path, of the temporary file.
   */
  public function getLocalTempPath();

  /**
   * Sets the local filesystem URI to the temporary file.
   *
   * @param string $temp_uri
   *   A URI to a temporary file.
   *
   * @return $this
   */
  public function setLocalTempPath($temp_uri);

  /**
   * Copies the file at URI to a local temporary file.
   *
   * @param string $temp_uri
   *   (optional) a URI to a temporary file. If NULL, a temp URI will be
   *   defined by the operation. Defaults to NULL.
   *
   * @return bool
   *   TRUE if the file was copied successfully, FALSE
   *   otherwise.
   */
  public function copyUriToTemp($temp_uri = NULL);

  /**
   * Copies the local temporary file to the destination URI.
   *
   * @return bool
   *   TRUE if the file was copied successfully, FALSE
   *   otherwise.
   */
  public function copyTempToUri();

  /**
   * Gets a FileMetadata plugin instance.
   *
   * @param 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 \Drupal\file_mdm\Plugin\FileMetadataPluginInterface|null
   *   The FileMetadata plugin instance. NULL if no plugin is found.
   */
  public function getFileMetadataPlugin($metadata_id);

  /**
   * Returns a list of supported metadata keys.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata 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($metadata_id, $options = NULL);

  /**
   * Gets a metadata element.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   * @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($metadata_id, $key = NULL);

  /**
   * Removes a metadata element.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   * @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($metadata_id, $key);

  /**
   * Sets a metadata element.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   * @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($metadata_id, $key, $value);

  /**
   * Checks if file metadata has been already loaded.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   *
   * @return bool
   *   TRUE if metadata is loaded, FALSE otherwise.
   */
  public function isMetadataLoaded($metadata_id);

  /**
   * Loads file metadata.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   * @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_id, $metadata);

  /**
   * Loads file metadata from a cache entry.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   *
   * @return bool
   *   TRUE if metadata was loaded successfully, FALSE otherwise.
   */
  public function loadMetadataFromCache($metadata_id);

  /**
   * Caches metadata for file at URI.
   *
   * Uses the 'file_mdm' cache bin.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   * @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($metadata_id, array $tags = []);

  /**
   * Saves metadata to file at URI.
   *
   * @param string $metadata_id
   *   The id of the FileMetadata plugin.
   *
   * @return bool
   *   TRUE if metadata was saved successfully, FALSE otherwise.
   */
  public function saveMetadataToFile($metadata_id);

}

Members

Namesort descending Modifiers Type Description Overrides
FileMetadataInterface::copyTempToUri public function Copies the local temporary file to the destination URI. 1
FileMetadataInterface::copyUriToTemp public function Copies the file at URI to a local temporary file. 1
FileMetadataInterface::getFileMetadataPlugin public function Gets a FileMetadata plugin instance. 1
FileMetadataInterface::getLocalTempPath public function Gets the local filesystem URI to the temporary file. 1
FileMetadataInterface::getMetadata public function Gets a metadata element. 1
FileMetadataInterface::getSupportedKeys public function Returns a list of supported metadata keys. 1
FileMetadataInterface::getUri public function Gets the URI of the file. 1
FileMetadataInterface::isMetadataLoaded public function Checks if file metadata has been already loaded. 1
FileMetadataInterface::LOADED_BY_CODE constant Metadata loaded by code.
FileMetadataInterface::LOADED_FROM_CACHE constant Metadata loaded from cache.
FileMetadataInterface::LOADED_FROM_FILE constant Metadata loaded from file.
FileMetadataInterface::loadMetadata public function Loads file metadata. 1
FileMetadataInterface::loadMetadataFromCache public function Loads file metadata from a cache entry. 1
FileMetadataInterface::NOT_LOADED constant Metadata not loaded.
FileMetadataInterface::removeMetadata public function Removes a metadata element. 1
FileMetadataInterface::saveMetadataToCache public function Caches metadata for file at URI. 1
FileMetadataInterface::saveMetadataToFile public function Saves metadata to file at URI. 1
FileMetadataInterface::setLocalTempPath public function Sets the local filesystem URI to the temporary file. 1
FileMetadataInterface::setMetadata public function Sets a metadata element. 1