You are here

protected function CnpjFormatter::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/CnpjFormatter.php, line 64

Class

CnpjFormatter
Formatter for CNPJ 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
    ->formatCnpj($item->value);
  return $render_array;
}