class DataType
Same name in this branch
- 10 core/lib/Drupal/Core/TypedData/Annotation/DataType.php \Drupal\Core\TypedData\Annotation\DataType
Same name in other branches
- 9 core/lib/Drupal/Core/TypedData/Annotation/DataType.php \Drupal\Core\TypedData\Annotation\DataType
- 8.9.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php \Drupal\Core\TypedData\Annotation\DataType
- 11.x core/lib/Drupal/Core/TypedData/Attribute/DataType.php \Drupal\Core\TypedData\Attribute\DataType
- 11.x core/lib/Drupal/Core/TypedData/Annotation/DataType.php \Drupal\Core\TypedData\Annotation\DataType
Defines a data type attribute.
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 below \Drupal\Core\TypedData\Type or may be complex data types, containing one or more data properties. Typed data objects for complex data types have to implement the \Drupal\Core\TypedData\ComplexDataInterface. Further interfaces 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
- class \Drupal\Component\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
Expanded class hierarchy of DataType
See also
\Drupal\Core\TypedData\TypedDataManager::create()
Related topics
25 files declare their use of DataType
- Any.php in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ Any.php - BinaryData.php in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ BinaryData.php - BooleanData.php in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ BooleanData.php - ComputedTestCacheableString.php in core/
modules/ system/ tests/ modules/ entity_test/ src/ Plugin/ DataType/ ComputedTestCacheableString.php - DateTimeIso8601.php in core/
lib/ Drupal/ Core/ TypedData/ Plugin/ DataType/ DateTimeIso8601.php
File
-
core/
lib/ Drupal/ Core/ TypedData/ Attribute/ DataType.php, line 38
Namespace
Drupal\Core\TypedData\AttributeView source
class DataType extends Plugin {
/**
* Constructs a new DataType attribute.
*
* @param string $id
* The data type plugin ID.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup $label
* The human-readable name of the data type.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $description
* (optional) The description of the data type.
* @param string|null $definition_class
* (optional) The definition class to use for defining data of this type.
* @param string|null $list_class
* (optional) The typed data class used for wrapping multiple data items of
* the type.
* @param string|null $list_definition_class
* (optional) The definition class to use for defining a list of items of
* this type.
* @param array $constraints
* (optional) An array of validation constraints for this type.
* @param bool $unwrap_for_canonical_representation
* Whether the typed object wraps the canonical representation of the data.
* @param class-string|null $deriver
* (optional) The deriver class for the data type.
*
* @see \Drupal\Core\TypedData\TypedDataManager::getConstraints()
* @see \Drupal\Core\TypedData\TypedDataManager::getCanonicalRepresentation()
*/
public function __construct(string $id, TranslatableMarkup $label, ?TranslatableMarkup $description = NULL, ?string $definition_class = DataDefinition::class, ?string $list_class = ItemList::class, ?string $list_definition_class = ListDataDefinition::class, array $constraints = [], bool $unwrap_for_canonical_representation = TRUE, ?string $deriver = NULL) {
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AttributeBase::$class | protected | property | The class used for this attribute class. | ||
AttributeBase::$provider | protected | property | The provider of the attribute class. | ||
AttributeBase::get | public | function | Gets the value of an attribute. | Overrides AttributeInterface::get | 6 |
AttributeBase::getClass | public | function | Gets the class of the attribute class. | Overrides AttributeInterface::getClass | 1 |
AttributeBase::getId | public | function | Gets the unique ID for this attribute class. | Overrides AttributeInterface::getId | |
AttributeBase::getProvider | public | function | Gets the name of the provider of the attribute class. | Overrides AttributeInterface::getProvider | |
AttributeBase::setClass | public | function | Sets the class of the attributed class. | Overrides AttributeInterface::setClass | 1 |
AttributeBase::setProvider | public | function | Sets the name of the provider of the attribute class. | Overrides AttributeInterface::setProvider | |
DataType::__construct | public | function | Constructs a new DataType attribute. | Overrides Plugin::__construct |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.