W3cubDocs

/Drupal 8

public function 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);

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!TypedData!ListInterface.php/function/ListInterface::set/8.1.x