public static function BaseFieldDefinition::createFromItemType in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Field/BaseFieldDefinition.php \Drupal\Core\Field\BaseFieldDefinition::createFromItemType()
Creates a new list data definition for items of the given data type.
This method is typically used by \Drupal\Core\TypedData\TypedDataManager::createListDataDefinition() to build a definition object for an arbitrary item type. When the definition class is known, it is recommended to directly use the static create() method on that class instead; e.g.:
$list_definition = \Drupal\Core\TypedData\ListDataDefinition::create('string');
Parameters
string $item_type: The item type, for which a list data definition should be created.
Return value
static
Throws
\InvalidArgumentException If an unsupported data type gets passed to the class; e.g., 'string' to a definition class handling lists of 'field_item:* data types.
Overrides ListDataDefinition::createFromItemType
1 call to BaseFieldDefinition::createFromItemType()
- FieldConfigBase::createFromItemType in core/
lib/ Drupal/ Core/ Field/ FieldConfigBase.php - Creates a new list data definition for items of the given data type.
File
- core/
lib/ Drupal/ Core/ Field/ BaseFieldDefinition.php, line 101
Class
- BaseFieldDefinition
- A class for defining entity fields.
Namespace
Drupal\Core\FieldCode
public static function createFromItemType($item_type) {
// The data type of a field item is in the form of "field_item:$field_type".
$parts = explode(':', $item_type, 2);
return static::create($parts[1]);
}