You are here

public function ListDataDefinition::setDataType in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/TypedData/ListDataDefinition.php \Drupal\Core\TypedData\ListDataDefinition::setDataType()
  2. 9 core/lib/Drupal/Core/TypedData/ListDataDefinition.php \Drupal\Core\TypedData\ListDataDefinition::setDataType()

Sets the data type.

Parameters

string $type: The data type to set.

Return value

static The object itself for chaining.

Overrides DataDefinition::setDataType

File

core/lib/Drupal/Core/TypedData/ListDataDefinition.php, line 65

Class

ListDataDefinition
A typed data definition class for defining lists.

Namespace

Drupal\Core\TypedData

Code

public function setDataType($type) {
  if ($type != 'list') {
    throw new \LogicException('Lists must always be of data type "list".');
  }
}