public function ComputedPhpFormatterExample::formatItem in Computed Field 8.2
Same name and namespace in other branches
- 3.x computed_field_example_formatter/src/Plugin/Field/FieldFormatter/ComputedPhpFormatterExample.php \Drupal\computed_field_example_formatter\Plugin\Field\FieldFormatter\ComputedPhpFormatterExample::formatItem()
Do something with the value before displaying it.
Parameters
mixed $value: The (computed) value of the item.
\Drupal\Core\Field\FieldItemInterface $item: The item to format for output
int $delta: The delta value (index) of the item in case of multiple items
string $langcode: The language code
Return value
mixed
Overrides ComputedPhpFormatterBase::formatItem
File
- computed_field_example_formatter/
src/ Plugin/ Field/ FieldFormatter/ ComputedPhpFormatterExample.php, line 43 - Contains \Drupal\Core\Field\Plugin\Field\FieldFormatter\ComputedPhpFormatterExample.
Class
- ComputedPhpFormatterExample
- Plugin implementation of the 'Example PHP' formatter for computed fields.
Namespace
Drupal\computed_field_example_formatter\Plugin\Field\FieldFormatterCode
public function formatItem($value, FieldItemInterface $item, $delta = 0, $langcode = NULL) {
return '<b>PHP example:</b> $value = ' . $value;
}