protected function StringFormatter::viewValue in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::viewValue()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::viewValue()
Generate the output appropriate for one field item.
Parameters
\Drupal\Core\Field\FieldItemInterface $item: One field item.
Return value
array The textual output generated as a render array.
1 call to StringFormatter::viewValue()
- StringFormatter::viewElements in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldFormatter/ StringFormatter.php - Builds a renderable array for a field value.
1 method overrides StringFormatter::viewValue()
- LanguageFormatter::viewValue in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldFormatter/ LanguageFormatter.php - Generate the output appropriate for one field item.
File
- core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldFormatter/ StringFormatter.php, line 155
Class
- StringFormatter
- Plugin implementation of the 'string' formatter.
Namespace
Drupal\Core\Field\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
return [
'#type' => 'inline_template',
'#template' => '{{ value|nl2br }}',
'#context' => [
'value' => $item->value,
],
];
}