public function ItemList::get in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::get()
Returns the item at the specified position in this list.
Parameters
int $index: Index of the item to return.
Return value
\Drupal\Core\TypedData\TypedDataInterface|null The item at the specified position in this list, or NULL if no item exists at that position.
Throws
\Drupal\Core\TypedData\Exception\MissingDataException If the complex data structure is unset and no item can be created.
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
1 method overrides ItemList::get()
- CommentFieldItemList::get in core/
modules/ comment/ src/ CommentFieldItemList.php - Returns the item at the specified position in this list.
File
- core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ ItemList.php, line 101 - Contains \Drupal\Core\TypedData\Plugin\DataType\ItemList.
Class
- ItemList
- A generic list class.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function get($index) {
if (!is_numeric($index)) {
throw new \InvalidArgumentException('Unable to get a value with a non-numeric delta in a list.');
}
// Automatically create the first item for computed fields.
if ($index == 0 && !isset($this->list[0]) && $this->definition
->isComputed()) {
$this->list[0] = $this
->createItem(0);
}
return isset($this->list[$index]) ? $this->list[$index] : NULL;
}