function ListInterface::set
Same name in other branches
- 8.9.x core/lib/Drupal/Core/TypedData/ListInterface.php \Drupal\Core\TypedData\ListInterface::set()
- 10 core/lib/Drupal/Core/TypedData/ListInterface.php \Drupal\Core\TypedData\ListInterface::set()
- 11.x core/lib/Drupal/Core/TypedData/ListInterface.php \Drupal\Core\TypedData\ListInterface::set()
Sets the value of the item at a given position in the list.
Parameters
int $index: The position of the item in the list. Since a List only contains sequential, 0-based indexes, $index has to be:
- Either the position of an existing item in the list. This updates the
item value.
- Or the next available position in the sequence of the current list
indexes. This appends a new item with the provided value at the end of the list.
mixed $value: The value of the item to be stored at the specified position.
Return value
$this
Throws
\InvalidArgumentException If the $index is invalid (non-numeric, or pointing to an invalid position in the list).
\Drupal\Core\TypedData\Exception\MissingDataException If the complex data structure is unset and no item can be set.
1 method overrides ListInterface::set()
- ItemList::set in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ ItemList.php - Sets the value of the item at a given position in the list.
File
-
core/
lib/ Drupal/ Core/ TypedData/ ListInterface.php, line 81
Class
- ListInterface
- Interface for a list of typed data.
Namespace
Drupal\Core\TypedDataCode
public function set($index, $value);
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.