in modules/quanthub_core/src/Plugin/Field/FieldFormatter/QuanthubKeyValueFormatter.php [63:90]
public function viewElements(FieldItemListInterface $items, $langcode) {
// Get the value elements from the TextDefaultFormatter class.
$value_elements = parent::viewElements($items, $langcode);
// Buffer the return value.
$elements = [];
// Loop through all items.
foreach ($items as $delta => $item) {
// Just add the key element to the render array, when 'value_only' is not
// checked.
if (isset($item->key)) {
if (!$this->getSetting('value_only') && $this->getSetting('show_period')) {
$elements[$delta]['key'] = [
'#plain_text' => nl2br($item->key . ': '),
];
}
if (!$this->getSetting('value_only') && !$this->getSetting('show_period')) {
$elements[$delta]['key'] = [
'#plain_text' => nl2br($item->key),
];
}
}
// Add the value to the render array.
$elements[$delta]['value'] = $value_elements[$delta];
}
return $elements;
}