Plugin implementation of the 'text_plain' formatter.
@FieldFormatter(
id = "text_plain",
module = "text",
label = @Translation("Plain text"),
field_types = {
"text",
"text_long",
"text_with_summary"
},
edit = {
"editor" = "direct"
}
)
Expanded class hierarchy of TextPlainFormatter
class TextPlainFormatter extends FormatterBase {
/**
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
*/
public function viewElements(EntityInterface $entity, $langcode, array $items) {
$elements = array();
foreach ($items as $delta => $item) {
// The text value has no text format assigned to it, so the user input
// should equal the output, including newlines.
$elements[$delta] = array(
'#markup' => nl2br(check_plain($item['value'])),
);
}
return $elements;
}
}