function ItemList::isEmpty

Same name in other branches
  1. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::isEmpty()
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::isEmpty()
  3. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::isEmpty()

Overrides ListInterface::isEmpty

1 call to ItemList::isEmpty()
EntityReferenceFieldItemList::referencedEntities in core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php
Gets the entities referenced by this field, preserving field item deltas.

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 250

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function isEmpty() {
    foreach ($this->list as $item) {
        if ($item instanceof ComplexDataInterface || $item instanceof ListInterface) {
            if (!$item->isEmpty()) {
                return FALSE;
            }
        }
        elseif ($item->getValue() !== NULL) {
            return FALSE;
        }
    }
    return TRUE;
}

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