function EntityReferenceUuidItem::hasNewEntity

Determines whether the item holds an unsaved entity.

This is notably used for "autocreate" widgets, and more generally to support referencing freshly created entities (they will get saved automatically as the hosting entity gets saved).

Return value

bool TRUE if the item holds an unsaved entity.

Overrides EntityReferenceItem::hasNewEntity

1 call to EntityReferenceUuidItem::hasNewEntity()
EntityReferenceUuidItem::preSave in core/modules/jsonapi/tests/modules/jsonapi_test_field_type/src/Plugin/Field/FieldType/EntityReferenceUuidItem.php

File

core/modules/jsonapi/tests/modules/jsonapi_test_field_type/src/Plugin/Field/FieldType/EntityReferenceUuidItem.php, line 237

Class

EntityReferenceUuidItem
Defines the 'entity_reference_uuid' entity field type.

Namespace

Drupal\jsonapi_test_field_type\Plugin\Field\FieldType

Code

public function hasNewEntity() {
  return !$this->isEmpty() && $this->target_uuid === NULL && $this->entity
    ->isNew();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.