You are here

public function ItemList::appendItem in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::appendItem()

Appends a new item to the list.

Parameters

mixed $value: The value of the new item.

Return value

\Drupal\Core\TypedData\TypedDataInterface The item that was appended.

Overrides ListInterface::appendItem

6 calls to ItemList::appendItem()
CommentFieldItemList::get in core/modules/comment/src/CommentFieldItemList.php
Returns the item at the specified position in this list.
FieldItemList::applyDefaultValue in core/lib/Drupal/Core/Field/FieldItemList.php
Applies the default value.
FieldItemList::__set in core/lib/Drupal/Core/Field/FieldItemList.php
Magic method: Sets a property value of the first field item.
ItemList::offsetSet in core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php
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.

... See full list

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 206

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function appendItem($value = NULL) {
  $offset = count($this->list);
  $item = $this
    ->createItem($offset, $value);
  $this->list[$offset] = $item;
  return $item;
}