protected function NameFormatter::parseAdditionalComponents in Name Field 8
Gets any additional linked components.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The name formatters FieldItemList.
Return value
array An array of any additional components if set.
1 call to NameFormatter::parseAdditionalComponents()
- NameFormatter::viewElements in src/
Plugin/ Field/ FieldFormatter/ NameFormatter.php - Builds a renderable array for a field value.
File
- src/
Plugin/ Field/ FieldFormatter/ NameFormatter.php, line 406
Class
- NameFormatter
- Plugin implementation of the 'name' formatter.
Namespace
Drupal\name\Plugin\Field\FieldFormatterCode
protected function parseAdditionalComponents(FieldItemListInterface $items) {
$extra = [];
foreach ([
'preferred',
'alternative',
] as $key) {
$key_value = $this
->getSetting($key . '_field_reference');
$sep_value = $this
->getSetting($key . '_field_reference_separator');
if (!$key_value) {
$key_value = $this->fieldDefinition
->getSetting($key . '_field_reference');
$sep_value = $this->fieldDefinition
->getSetting($key . '_field_reference_separator');
}
if ($value = name_get_additional_component($this->entityTypeManager, $this->renderer, $items, $key_value, $sep_value)) {
$extra[$key] = $value;
}
}
return $extra;
}