public static BaseFieldDefinition::createFromItemType($item_type)
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
File
- core/lib/Drupal/Core/Field/BaseFieldDefinition.php, line 102
Class
- BaseFieldDefinition
- A class for defining entity fields.
Namespace
Drupal\Core\Field
Code
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]); }
Please login to continue.