function DataDefinition::create

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

Creates a new data definition.

Parameters

string $type: The data type of the data; e.g., 'string', 'integer' or 'any'.

Return value

static A new DataDefinition object.

12 calls to DataDefinition::create()
ContextTypedDataTest::testGetContextValue in core/tests/Drupal/KernelTests/Core/Plugin/ContextTypedDataTest.php
Tests that getting a context value does not throw fatal errors.
ContextTypedDataTest::testSerialize in core/tests/Drupal/KernelTests/Core/Plugin/ContextTypedDataTest.php
Tests that contexts can be serialized.
DataDefinition::createFromDataType in core/lib/Drupal/Core/TypedData/DataDefinition.php
Creates a new data definition object.
DataReferenceDefinition::create in core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php
Creates a new data reference definition.
FilterAPITest::testTypedDataAPI in core/modules/filter/tests/src/Kernel/FilterAPITest.php
Tests the function of the typed data type.

... See full list

5 methods override DataDefinition::create()
DataReferenceDefinition::create in core/lib/Drupal/Core/TypedData/DataReferenceDefinition.php
Creates a new data reference definition.
EntityDataDefinition::create in core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php
Creates a new entity definition.
FieldItemDataDefinition::create in core/lib/Drupal/Core/Field/TypedData/FieldItemDataDefinition.php
Creates a new field item definition.
ListDataDefinition::create in core/lib/Drupal/Core/TypedData/ListDataDefinition.php
Creates a new list definition.
MapDataDefinition::create in core/lib/Drupal/Core/TypedData/MapDataDefinition.php
Creates a new map definition.

File

core/lib/Drupal/Core/TypedData/DataDefinition.php, line 28

Class

DataDefinition
A typed data definition class for defining data based on defined data types.

Namespace

Drupal\Core\TypedData

Code

public static function create($type) {
    $definition['type'] = $type;
    return new static($definition);
}

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