You are here

public function DynamicEntityReferenceItem::isEmpty in Dynamic Entity Reference 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php \Drupal\dynamic_entity_reference\Plugin\Field\FieldType\DynamicEntityReferenceItem::isEmpty()

Determines whether the data structure is empty.

Return value

bool TRUE if the data structure is empty, FALSE otherwise.

Overrides EntityReferenceItem::isEmpty

1 call to DynamicEntityReferenceItem::isEmpty()
DynamicEntityReferenceItem::preSave in src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php
Defines custom presave behavior for field values.

File

src/Plugin/Field/FieldType/DynamicEntityReferenceItem.php, line 473

Class

DynamicEntityReferenceItem
Defines the 'dynamic_entity_reference' entity field type.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldType

Code

public function isEmpty() {

  // Avoid loading the entity by first checking the 'target_id'.
  if ($this->target_id !== NULL && $this->target_type !== NULL) {
    return FALSE;
  }
  if ($this->entity && $this->entity instanceof EntityInterface) {
    return FALSE;
  }
  return TRUE;
}