public function TextDefaultFormatter::viewElements in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter::viewElements()
Builds a renderable array for a field value.
Parameters
\Drupal\Core\Field\FieldItemListInterface $items: The field values to be rendered.
string $langcode: The language that should be used to render the field.
Return value
array A renderable array for $items, as an array of child elements keyed by consecutive numeric indexes starting from 0.
Overrides FormatterInterface::viewElements
File
- core/
modules/ text/ src/ Plugin/ Field/ FieldFormatter/ TextDefaultFormatter.php, line 34 - Contains \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter.
Class
- TextDefaultFormatter
- Plugin implementation of the 'text_default' formatter.
Namespace
Drupal\text\Plugin\Field\FieldFormatterCode
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = array();
// The ProcessedText element already handles cache context & tag bubbling.
// @see \Drupal\filter\Element\ProcessedText::preRenderText()
foreach ($items as $delta => $item) {
$elements[$delta] = array(
'#type' => 'processed_text',
'#text' => $item->value,
'#format' => $item->format,
'#langcode' => $item
->getLangcode(),
);
}
return $elements;
}