ListInterface::set

public ListInterface::set($index, $value)

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.

File

core/lib/Drupal/Core/TypedData/ListInterface.php, line 81

Class

ListInterface
Interface for a list of typed data.

Namespace

Drupal\Core\TypedData

Code

public function set($index, $value);
doc_Drupal
2016-10-29 09:23:34
Comments
Leave a Comment

Please login to continue.