function EntityReferenceUuidItem::preSave
Same name and namespace in other branches
- 11.x core/modules/jsonapi/tests/modules/jsonapi_test_field_type/src/Plugin/Field/FieldType/EntityReferenceUuidItem.php \Drupal\jsonapi_test_field_type\Plugin\Field\FieldType\EntityReferenceUuidItem::preSave()
Overrides EntityReferenceItem::preSave
File
-
core/
modules/ jsonapi/ tests/ modules/ jsonapi_test_field_type/ src/ Plugin/ Field/ FieldType/ EntityReferenceUuidItem.php, line 181
Class
- EntityReferenceUuidItem
- Defines the 'entity_reference_uuid' entity field type.
Namespace
Drupal\jsonapi_test_field_type\Plugin\Field\FieldTypeCode
public function preSave() : void {
if ($this->hasNewEntity()) {
// Save the entity if it has not already been saved by some other code.
if ($this->entity
->isNew()) {
$this->entity
->save();
}
// Make sure the parent knows we are updating this property so it can
// react properly.
$this->target_uuid = $this->entity
->uuid();
}
if (!$this->isEmpty() && $this->target_uuid === NULL) {
$this->target_uuid = $this->entity
->uuid();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.