diff --git a/core/lib/Drupal/Core/TypedData/Annotation/DataType.php b/core/lib/Drupal/Core/TypedData/Annotation/DataType.php index 7778267..c0569ab 100644 --- a/core/lib/Drupal/Core/TypedData/Annotation/DataType.php +++ b/core/lib/Drupal/Core/TypedData/Annotation/DataType.php @@ -12,6 +12,26 @@ /** * 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: + * - \Drupal\Core\TypedData\AccessibleInterface + * - \Drupal\Core\TypedData\TranslatableInterface + * + * 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 classed used for a list of + * items of a certain type may be specified using the 'list class' key. + * + * @see \Drupal::typedData() + * @see Drupal\Core\TypedData\TypedDataManager::create() + * @see hook_data_type_info_alter() + * * @Annotation */ class DataType extends Plugin { @@ -42,9 +62,30 @@ class DataType extends Plugin { public $description; /** - * The name of the list class for the data type. + * 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\ItemList'; + + /** + * 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; + }