You are here

public function Map::isEmpty in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::isEmpty()
  2. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php \Drupal\Core\TypedData\Plugin\DataType\Map::isEmpty()

Determines whether the data structure is empty.

Return value

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

Overrides ComplexDataInterface::isEmpty

17 methods override Map::isEmpty()
CommentItem::isEmpty in core/modules/comment/src/Plugin/Field/FieldType/CommentItem.php
Determines whether the data structure is empty.
DateTimeItem::isEmpty in core/modules/datetime/src/Plugin/Field/FieldType/DateTimeItem.php
Determines whether the data structure is empty.
DummyAjaxItem::isEmpty in core/modules/image/tests/modules/image_module_test/src/Plugin/Field/FieldType/DummyAjaxItem.php
Determines whether the data structure is empty.
EmailItem::isEmpty in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EmailItem.php
Determines whether the data structure is empty.
EntityReferenceItem::isEmpty in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Determines whether the data structure is empty.

... See full list

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php, line 192

Class

Map
The "map" data type.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function isEmpty() {
  foreach ($this->properties as $property) {
    $definition = $property
      ->getDataDefinition();
    if (!$definition
      ->isComputed() && $property
      ->getValue() !== NULL) {
      return FALSE;
    }
  }
  if (isset($this->values)) {
    foreach ($this->values as $name => $value) {
      if (isset($value) && !isset($this->properties[$name])) {
        return FALSE;
      }
    }
  }
  return TRUE;
}