public function ItemList::removeItem in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::removeItem()
Removes the item at the specified position.
Parameters
int $index: Index of the item to remove.
Return value
$this
Overrides ListInterface::removeItem
1 call to ItemList::removeItem()
- ItemList::offsetUnset in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ ItemList.php
File
- core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ ItemList.php, line 131
Class
- ItemList
- A generic list class.
Namespace
Drupal\Core\TypedData\Plugin\DataTypeCode
public function removeItem($index) {
if (isset($this->list) && array_key_exists($index, $this->list)) {
// Remove the item, and reassign deltas.
unset($this->list[$index]);
$this
->rekey($index);
}
else {
throw new \InvalidArgumentException('Unable to remove item at non-existing index.');
}
return $this;
}