You are here

public function FileMetadata::removeMetadata in File metadata manager 8.2

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

Removes a metadata element.

Parameters

string $metadata_id: The id of the FileMetadata plugin.

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

Return value

bool TRUE if metadata was removed successfully, FALSE otherwise.

Overrides FileMetadataInterface::removeMetadata

File

src/FileMetadata.php, line 199

Class

FileMetadata
A file metadata object.

Namespace

Drupal\file_mdm

Code

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