You are here

protected function ExifTagMapper::getStringToIfdMap in File metadata manager 8.2

Same name and namespace in other branches
  1. 8 file_mdm_exif/src/ExifTagMapper.php \Drupal\file_mdm_exif\ExifTagMapper::getStringToIfdMap()

Returns the map of IFD strings to IFD integers.

Builds and caches the list as needed.

Return value

array An associative array where keys are IFD literals, and values the IFD integer identifiers.

File

file_mdm_exif/src/ExifTagMapper.php, line 295

Class

ExifTagMapper
Provides a mapping service for EXIF ifds and tags.

Namespace

Drupal\file_mdm_exif

Code

protected function getStringToIfdMap() {
  if (!$this->stringToIfdMap) {
    $cache_id = 'stringToIfd';
    if ($cache = $this
      ->getCache($cache_id)) {
      $this->stringToIfdMap = $cache->data;
    }
    else {
      $config_map = $this->configFactory
        ->get('file_mdm_exif.file_metadata_plugin.exif')
        ->get('ifd_map');
      $this->stringToIfdMap = [];
      foreach ($config_map as $value) {
        foreach ($value['aliases'] as $alias) {
          $k = strtolower($alias);
          $this->stringToIfdMap[$k] = $value['type'];
        }
      }
      $this
        ->setCache($cache_id, $this->stringToIfdMap);
    }
  }
  return $this->stringToIfdMap;
}