You are here

public function TypedDataManager::createListDataDefinition in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/TypedDataManager.php \Drupal\Core\TypedData\TypedDataManager::createListDataDefinition()

Creates a new list data definition for items of the given data type.

Parameters

string $item_type: The item type, for which a list data definition should be created.

Return value

\Drupal\Core\TypedData\ListDataDefinitionInterface A list definition for items of the given data type.

Overrides TypedDataManagerInterface::createListDataDefinition

See also

\Drupal\Core\TypedData\TypedDataManager::createDataDefinition()

File

core/lib/Drupal/Core/TypedData/TypedDataManager.php, line 132

Class

TypedDataManager
Manages data type plugins.

Namespace

Drupal\Core\TypedData

Code

public function createListDataDefinition($item_type) {
  $type_definition = $this
    ->getDefinition($item_type);
  if (!isset($type_definition)) {
    throw new \InvalidArgumentException("Invalid data type '{$item_type}' has been given");
  }
  $class = $type_definition['list_definition_class'];
  return $class::createFromItemType($item_type);
}