You are here

protected function ComputedRawFormatter::viewValue in Computed Field 8

Generate the output appropriate for one field item.

Parameters

\Drupal\Core\Field\FieldItemInterface $item: One field item.

Return value

string The textual output generated.

1 call to ComputedRawFormatter::viewValue()
ComputedRawFormatter::viewElements in src/Plugin/Field/FieldFormatter/ComputedRawFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/ComputedRawFormatter.php, line 81

Class

ComputedRawFormatter
Plugin implementation of the 'computed_raw' formatter.

Namespace

Drupal\computed_field\Plugin\Field\FieldFormatter

Code

protected function viewValue(FieldItemInterface $item) {
  if ($this
    ->getSetting('sanitized')) {
    return nl2br(SafeMarkup::checkPlain($item->value));
  }
  else {
    return nl2br($item->value);
  }
}