You are here

protected function CpfFormatter::viewValue in Brazilian IDs 8

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.

Overrides StringFormatter::viewValue

File

src/Plugin/Field/FieldFormatter/CpfFormatter.php, line 64

Class

CpfFormatter
Formatter for CPF numbers.

Namespace

Drupal\brazilian_ids\Plugin\Field\FieldFormatter

Code

protected function viewValue(FieldItemInterface $item) {
  $render_array = parent::viewValue($item);

  // Uses the formatted value.
  $render_array['#context']['value'] = $this->brazilianIds
    ->formatCpf($item->value);
  return $render_array;
}