You are here

public function FieldTypePluginManager::createFieldItem in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldTypePluginManager.php \Drupal\Core\Field\FieldTypePluginManager::createFieldItem()

Creates a new field item as part of a field item list.

The provided item list is assigned as the parent of the created item. It However, it is the responsibility of the caller (usually the parent list itself) to have the parent aware of the item as a new child.

Parameters

\Drupal\Core\Field\FieldItemListInterface $items: The field item list, for which to create a new item.

int $index: The list index at which the item is created.

array|null $values: (optional) The values to assign to the field item properties.

Return value

\Drupal\Core\Field\FieldItemInterface The instantiated object.

Overrides FieldTypePluginManagerInterface::createFieldItem

File

core/lib/Drupal/Core/Field/FieldTypePluginManager.php, line 80

Class

FieldTypePluginManager
Plugin manager for 'field type' plugins.

Namespace

Drupal\Core\Field

Code

public function createFieldItem(FieldItemListInterface $items, $index, $values = NULL) {

  // Leverage prototyping of the Typed Data API for fast instantiation.
  return $this->typedDataManager
    ->getPropertyInstance($items, $index, $values);
}