In Drupal 9 I would like to know if it is possible to overwrite the value of a field in a BundleClass. Looking at the Drupal API, I see that it is common to use either hook_entity_view_alter
or hook_views_pre_render
. The only way I have found is to define a new method:
public function getUpdateFieldName() {
$value = this->get('field_name')->getValue();
# Code here ...
return $code
}
However, with this example, I have to create a pseudo-field to be able to get the value in a view. Are there any other ways?