1. 8.3.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php DataType
  2. 8.0.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php DataType
  3. 8.1.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php DataType
  4. 8.2.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php DataType
  5. 8.4.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php DataType

Defines a data type annotation object.

The typed data API allows modules to support any kind of data based upon pre-defined primitive types and interfaces for complex data and lists.

Defined data types may map to one of the pre-defined primitive types in \Drupal\Core\TypedData\Primitive or may be complex data types, containing on or more data properties. Typed data objects for complex data types have to implement the \Drupal\Core\TypedData\ComplexDataInterface. Further interface that may be implemented are:

Furthermore, lists of data items are represented by objects implementing the \Drupal\Core\TypedData\ListInterface. A list contains items of the same data type, is ordered and may contain duplicates. The class used for a list of items of a certain type may be specified using the 'list class' key.

Hierarchy

Expanded class hierarchy of DataType

See also

\Drupal::typedDataManager()

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

hook_data_type_info_alter()

Related topics

1 file declares its use of DataType
FieldType.php in core/lib/Drupal/Core/Field/Annotation/FieldType.php
19 classes are annotated with DataType
Any in core/lib/Drupal/Core/TypedData/Plugin/DataType/Any.php
The "any" data type.
BinaryData in core/lib/Drupal/Core/TypedData/Plugin/DataType/BinaryData.php
The binary data type.
BooleanData in core/lib/Drupal/Core/TypedData/Plugin/DataType/BooleanData.php
The boolean data type.
DateTimeIso8601 in core/lib/Drupal/Core/TypedData/Plugin/DataType/DateTimeIso8601.php
A data type for ISO 8601 date strings.
DurationIso8601 in core/lib/Drupal/Core/TypedData/Plugin/DataType/DurationIso8601.php
The duration ISO8601 data type.

... See full list

File

core/lib/Drupal/Core/TypedData/Annotation/DataType.php, line 34

Namespace

Drupal\Core\TypedData\Annotation
View source
class DataType extends Plugin {

  /**
   * The data type plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The human-readable name of the data type.
   *
   * @ingroup plugin_translatable
   *
   * @var \Drupal\Core\Annotation\Translation
   */
  public $label;

  /**
   * The description of the data type.
   *
   * @ingroup plugin_translatable
   *
   * @var \Drupal\Core\Annotation\Translation
   */
  public $description;

  /**
   * The definition class to use for defining data of this type.
   * Must implement the \Drupal\Core\TypedData\DataDefinitionInterface.
   *
   * @var string
   */
  public $definition_class = '\Drupal\Core\TypedData\DataDefinition';

  /**
   * The typed data class used for wrapping multiple data items of the type.
   * Must implement the \Drupal\Core\TypedData\ListInterface.
   *
   * @var string
   */
  public $list_class = '\Drupal\Core\TypedData\Plugin\DataType\ItemList';

  /**
   * The definition class to use for defining a list of items of this type.
   * Must implement the \Drupal\Core\TypedData\ListDataDefinitionInterface.
   *
   * @var string
   */
  public $list_definition_class = '\Drupal\Core\TypedData\ListDataDefinition';

  /**
   * The pre-defined primitive type that this data type maps to.
   *
   * If set, it must be a constant defined by \Drupal\Core\TypedData\Primitive
   * such as \Drupal\Core\TypedData\Primitive::STRING.
   *
   * @var string
   */
  public $primitive_type;

  /**
   * An array of validation constraints for this type.
   *
   * @var array
   *
   * @see \Drupal\Core\TypedData\TypedDataManager::getConstraints().
   */
  public $constraints;

  /**
   * Whether the typed object wraps the canonical representation of the data.
   *
   * @var bool
   *
   * @see \Drupal\Core\TypedData\TypedDataManager::getCanonicalRepresentation()
   */
  public $unwrap_for_canonical_representation = TRUE;

}

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description Overrides
DataType::$constraints public property An array of validation constraints for this type.
DataType::$definition_class public property The definition class to use for defining data of this type. Must implement the \Drupal\Core\TypedData\DataDefinitionInterface.
DataType::$description public property The description of the data type. 1
DataType::$id public property The data type plugin ID. 1
DataType::$label public property The human-readable name of the data type. 1
DataType::$list_class public property The typed data class used for wrapping multiple data items of the type. Must implement the \Drupal\Core\TypedData\ListInterface. 1
DataType::$list_definition_class public property The definition class to use for defining a list of items of this type. Must implement the \Drupal\Core\TypedData\ListDataDefinitionInterface.
DataType::$primitive_type public property The pre-defined primitive type that this data type maps to.
DataType::$unwrap_for_canonical_representation public property Whether the typed object wraps the canonical representation of the data.
Plugin::$definition protected property The plugin definition read from the class annotation. 1
Plugin::get public function Gets the value of an annotation. Overrides AnnotationInterface::get 2
Plugin::getClass public function Gets the class of the annotated class. Overrides AnnotationInterface::getClass
Plugin::getId public function Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId
Plugin::getProvider public function Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider 1
Plugin::parse protected function Parses an annotation into its definition.
Plugin::setClass public function Sets the class of the annotated class. Overrides AnnotationInterface::setClass
Plugin::setProvider public function Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider
Plugin::__construct public function Constructs a Plugin object. 2