You are here

function BaseMapping::map in Flags 8

Maps provided string to a flag code. Returned string should be lower case flag code.

Parameters

string $value Value of the source data.:

Return value

string

Overrides FlagMappingInterface::map

1 call to BaseMapping::map()
BaseMapping::getOptionAttributes in src/Mapping/BaseMapping.php
Gets array with attributes for each option element.

File

src/Mapping/BaseMapping.php, line 48

Class

BaseMapping
Provides generic mapping service to map values to flags using config entities.

Namespace

Drupal\flags\Mapping

Code

function map($value) {

  // Unify input data
  $code = trim(strtolower($value));
  $key = $this
    ->getConfigKey() . '.' . $code;
  if (isset($this->config[$key])) {

    // We make sure that flag is lowercase to match our CSS.
    return strtolower($this->config[$key]
      ->get('flag'));
  }
  return $code;
}