You are here

protected function Exif::doSetMetadata in File metadata manager 8

Same name and namespace in other branches
  1. 8.2 file_mdm_exif/src/Plugin/FileMetadata/Exif.php \Drupal\file_mdm_exif\Plugin\FileMetadata\Exif::doSetMetadata()

Sets a metadata element.

Parameters

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 FileMetadataPluginBase::doSetMetadata

File

file_mdm_exif/src/Plugin/FileMetadata/Exif.php, line 369

Class

Exif
FileMetadata plugin for EXIF.

Namespace

Drupal\file_mdm_exif\Plugin\FileMetadata

Code

protected function doSetMetadata($key, $value) {
  $ifd_tag = $this->tagMapper
    ->resolveKeyToIfdAndTag($key);
  if ($value instanceof PelEntry) {
    $this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']] = $value;
    return TRUE;
  }
  elseif (isset($this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']])) {
    $this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']]
      ->setValue($value);
    return TRUE;
  }
  return FALSE;
}