You are here

protected function Exif::doGetMetadata in File metadata manager 8.2

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

Gets a metadata element.

Parameters

mixed|null $key: A key to determine the metadata element to be returned. If NULL, the entire metadata will be returned.

Return value

mixed|null The value of the element specified by $key. If $key is NULL, the entire metadata. If no metadata is available, return NULL.

Overrides FileMetadataPluginBase::doGetMetadata

File

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

Class

Exif
FileMetadata plugin for EXIF.

Namespace

Drupal\file_mdm_exif\Plugin\FileMetadata

Code

protected function doGetMetadata($key = NULL) {
  if (!$this->metadata) {
    return NULL;
  }
  if (!$key) {
    return $this->metadata;
  }
  else {
    $ifd_tag = $this->tagMapper
      ->resolveKeyToIfdAndTag($key);
    if (!isset($this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']]) || $this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']] === 'deleted') {
      return NULL;
    }
    $entry = $this->metadata[$ifd_tag['ifd']][$ifd_tag['tag']];
    return [
      'value' => $entry
        ->getValue(),
      'text' => $entry
        ->getText(),
    ];
  }
}