You are here

protected function TelephoneFormatter::viewFormattedValue in Telephone Formatter 8

Generate the output appropriate for one field item.

Parameters

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

Return value

array The textual output generated as a render array.

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

File

src/Plugin/Field/FieldFormatter/TelephoneFormatter.php, line 197

Class

TelephoneFormatter
Plugin implementation of the 'telephone_formatter' formatter.

Namespace

Drupal\telephone_formatter\Plugin\Field\FieldFormatter

Code

protected function viewFormattedValue(FieldItemInterface $item) {

  // The text value has no text format assigned to it, so the user input
  // should equal the output.
  return [
    '#type' => 'inline_template',
    '#template' => '{{ value }}',
    '#context' => [
      'value' => $this
        ->getFormattedValue($item),
    ],
  ];
}