public function FileMetadataPluginBase::removeMetadata in File metadata manager 8
Same name and namespace in other branches
- 8.2 src/Plugin/FileMetadata/FileMetadataPluginBase.php \Drupal\file_mdm\Plugin\FileMetadata\FileMetadataPluginBase::removeMetadata()
Removes a metadata element.
Parameters
mixed $key: A key to determine the metadata element to be removed.
Return value
bool TRUE if metadata was removed successfully, FALSE otherwise.
Overrides FileMetadataPluginInterface::removeMetadata
File
- src/
Plugin/ FileMetadata/ FileMetadataPluginBase.php, line 431
Class
- FileMetadataPluginBase
- Abstract implementation of a base File Metadata plugin.
Namespace
Drupal\file_mdm\Plugin\FileMetadataCode
public function removeMetadata($key) {
if ($key === NULL) {
throw new FileMetadataException("No metadata key specified for file at '{$this->getUri()}'", $this
->getPluginId(), __FUNCTION__);
}
if (!$this->metadata && !$this
->getMetadata()) {
throw new FileMetadataException("No metadata loaded for file at '{$this->getUri()}'", $this
->getPluginId(), __FUNCTION__);
}
if ($this
->doRemoveMetadata($key)) {
$this->hasMetadataChangedFromFileVersion = TRUE;
if ($this->isMetadataLoaded === FileMetadataInterface::LOADED_FROM_CACHE) {
$this->hasMetadataChangedFromCacheVersion = TRUE;
}
return TRUE;
}
return FALSE;
}