function ItemList::get

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

Overrides ListInterface::get

3 calls to ItemList::get()
CommentFieldItemList::get in core/modules/comment/src/CommentFieldItemList.php
Returns the item at the specified position in this list.
ItemList::first in core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
Returns the first item in this list.
ItemList::offsetGet in core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
2 methods override ItemList::get()
CommentFieldItemList::get in core/modules/comment/src/CommentFieldItemList.php
Returns the item at the specified position in this list.
ModerationStateFieldItemList::get in core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php
Returns the item at the specified position in this list.

File

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

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function get($index) {
    if (!is_numeric($index)) {
        throw new \InvalidArgumentException('Unable to get a value with a non-numeric delta in a list.');
    }
    return $this->list[$index] ?? NULL;
}

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