function FieldTestItem::preSave
Same name in other branches
- 8.9.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php \Drupal\entity_test\Plugin\Field\FieldType\FieldTestItem::preSave()
- 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php \Drupal\entity_test\Plugin\Field\FieldType\FieldTestItem::preSave()
- 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php \Drupal\entity_test\Plugin\Field\FieldType\FieldTestItem::preSave()
Overrides FieldItemBase::preSave
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Plugin/ Field/ FieldType/ FieldTestItem.php, line 69
Class
- FieldTestItem
- Defines the 'field_test' entity field type.
Namespace
Drupal\entity_test\Plugin\Field\FieldTypeCode
public function preSave() {
$name = $this->getFieldDefinition()
->getName();
static::$counter[$name]++;
// Overwrite the field value unless it is going to be overridden, in which
// case its final value will already be different from the current one.
if (!$this->getEntity()
->isNew() && !$this->mustResave()) {
$this->setValue('overwritten');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.