function ComputedItemListTrait::get
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php \Drupal\Core\TypedData\ComputedItemListTrait::get()
- 10 core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php \Drupal\Core\TypedData\ComputedItemListTrait::get()
- 11.x core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php \Drupal\Core\TypedData\ComputedItemListTrait::get()
1 call to ComputedItemListTrait::get()
- 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/ ComputedItemListTrait.php, line 69
Class
- ComputedItemListTrait
- Provides common functionality for computed item lists.
Namespace
Drupal\Core\TypedDataCode
public function get($index) {
if (!is_numeric($index)) {
throw new \InvalidArgumentException('Unable to get a value with a non-numeric delta in a list.');
}
// Unlike the base implementation of
// \Drupal\Core\TypedData\ListInterface::get(), we do not add an empty item
// automatically because computed item lists need to behave like
// non-computed ones. For example, calling isEmpty() on a computed item list
// should return TRUE when the values were computed and the item list is
// truly empty.
// @see \Drupal\Core\TypedData\Plugin\DataType\ItemList::get().
$this->ensureComputedValue();
return isset($this->list[$index]) ? $this->list[$index] : NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.