You are here

public function ItemList::isEmpty in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::isEmpty()

Determines whether the list contains any non-empty items.

Return value

bool TRUE if the list is empty, FALSE otherwise.

Overrides ListInterface::isEmpty

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 252
Contains \Drupal\Core\TypedData\Plugin\DataType\ItemList.

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;
}