You are here

public function ItemList::first in Drupal 9

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

Returns the first item in this list.

Return value

\Drupal\Core\TypedData\TypedDataInterface|null The first item in this list, or NULL if there are no items.

Throws

\Drupal\Core\TypedData\Exception\MissingDataException If the complex data structure is unset and no item can be created.

Overrides ListInterface::first

5 calls to ItemList::first()
FieldItemList::applyDefaultValue in core/lib/Drupal/Core/Field/FieldItemList.php
Applies the default value.
FieldItemList::__get in core/lib/Drupal/Core/Field/FieldItemList.php
Magic method: Gets a property value of to the first field item.
FieldItemList::__isset in core/lib/Drupal/Core/Field/FieldItemList.php
Magic method: Determines whether a property of the first field item is set.
FieldItemList::__set in core/lib/Drupal/Core/Field/FieldItemList.php
Magic method: Sets a property value of the first field item.
FieldItemList::__unset in core/lib/Drupal/Core/Field/FieldItemList.php
Magic method: Unsets a property of the first field item.

File

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

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function first() {
  return $this
    ->get(0);
}