function EntityReferenceItem::isEmpty

Same name in other branches
  1. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::isEmpty()
  2. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::isEmpty()
  3. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::isEmpty()
2 calls to EntityReferenceItem::isEmpty()
EntityReferenceItem::hasNewEntity in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Determines whether the item holds an unsaved entity.
EntityReferenceItem::preSave in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php, line 302

Class

EntityReferenceItem
Defines the 'entity_reference' entity field type.

Namespace

Drupal\Core\Field\Plugin\Field\FieldType

Code

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

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