function FieldItemDataDefinition::create

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php \Drupal\Core\Field\TypedData\FieldItemDataDefinition::create()
  2. 10 core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php \Drupal\Core\Field\TypedData\FieldItemDataDefinition::create()
  3. 11.x core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php \Drupal\Core\Field\TypedData\FieldItemDataDefinition::create()

Creates a new field item definition.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition the item definition belongs to.

Return value

static

Overrides DataDefinition::create

3 calls to FieldItemDataDefinition::create()
BaseFieldDefinition::create in core/lib/Drupal/Core/Field/BaseFieldDefinition.php
Creates a new field definition.
FieldDefinition::setFieldStorageDefinition in core/lib/Drupal/Core/Field/FieldDefinition.php
Set the field storage definition.
FileUploadForm::createFileItem in core/modules/media_library/src/Form/FileUploadForm.php
Create a file field item.

File

core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php, line 47

Class

FieldItemDataDefinition
A typed data definition class for defining field items.

Namespace

Drupal\Core\Field\TypedData

Code

public static function create($field_definition) {
    $definition['type'] = 'field_item:' . $field_definition->getType();
    $item_definition = new static($definition);
    $item_definition->fieldDefinition = $field_definition;
    return $item_definition;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.