public function ComputedPhpFormatterPhp::formatItem in Computed Field 8.2
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_php_formatter/
src/ Plugin/ Field/ FieldFormatter/ ComputedPhpFormatterPhp.php, line 90 - Contains \Drupal\Core\Field\Plugin\Field\FieldFormatter\ComputedPhpFormatterPhp.
Class
- ComputedPhpFormatterPhp
- Plugin implementation of the 'Free PHP' formatter for computed fields.
Namespace
Drupal\computed_field_php_formatter\Plugin\Field\FieldFormatterCode
public function formatItem($value, FieldItemInterface $item, $delta = 0, $langcode = NULL) {
$settings = $this
->getSettings();
$value_escaped = Html::escape($value);
$display_value = NULL;
eval($settings['php_code']);
return $display_value;
}