protected function CpfCnpjFormatter::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/ CpfCnpjFormatter.php, line 64
Class
- CpfCnpjFormatter
- Formatter for CPF and CNPJ numbers.
Namespace
Drupal\brazilian_ids\Plugin\Field\FieldFormatterCode
protected function viewValue(FieldItemInterface $item) {
$render_array = parent::viewValue($item);
// Uses the formatted value.
$render_array['#context']['value'] = $this->brazilianIds
->formatCpfCnpj($item->value);
return $render_array;
}