You are here

public function FileMetadata::setMetadata in File metadata manager 8

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

Sets a metadata element.

Parameters

string $metadata_id: The id of the FileMetadata plugin.

mixed $key: A key to determine the metadata element to be changed.

mixed $value: The value to change the metadata element to.

Return value

bool TRUE if metadata was changed successfully, FALSE otherwise.

Overrides FileMetadataInterface::setMetadata

File

src/FileMetadata.php, line 214

Class

FileMetadata
A file metadata object.

Namespace

Drupal\file_mdm

Code

public function setMetadata($metadata_id, $key, $value) {
  try {
    if ($plugin = $this
      ->getFileMetadataPlugin($metadata_id)) {
      return $plugin
        ->setMetadata($key, $value);
    }
  } catch (\Exception $e) {
    $this->logger
      ->error($e
      ->getMessage());
  }
  return FALSE;
}