function hook_computed_field_FIELD_NAME_value_alter in Computed Field 3.x
Alter the value of a specific computed field.
Parameters
mixed $value: The computed value that can be altered.
array $context: An array containing the 'entity' and 'field_name'.
File
- ./
computed_field.api.php, line 34 - API documentation for the Computed Field module.
Code
function hook_computed_field_FIELD_NAME_value_alter(&$value, $context) {
$service = Drupal::service('computed_field.helpers');
// Only proceed when the hook does not exist.
if (!$service
->computeFunctionNameExists($context['field_name'])) {
// Set this one computed field to 42.
$value = 42;
}
}