public function BaseMapping::getOptionAttributes in Flags 8
Gets array with attributes for each option element.
Parameters
array $options: The array of keys, either language codes, or country codes.
Return value
\Drupal\Core\Template\Attribute[] List of classes per option.
Overrides FlagMappingInterface::getOptionAttributes
File
- src/
Mapping/ BaseMapping.php, line 65
Class
- BaseMapping
- Provides generic mapping service to map values to flags using config entities.
Namespace
Drupal\flags\MappingCode
public function getOptionAttributes(array $options = []) {
$attributes = [];
foreach ($options as $key) {
$classes = [
'flag',
'flag-' . strtolower($this
->map($key)),
];
$classes = array_merge($this
->getExtraClasses(), $classes);
$attributes[$key] = new Attribute([
'data-class' => $classes,
]);
}
return $attributes;
}