function hook_data_type_info

Defines available data types for the typed data API.

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 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 classed used for a list of items of a certain type may be specified using the 'list class' key.

Return value

array An associative array where the key is the data type name and the value is again an associative array. Supported keys are:

See also

typed_data()

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

hook_data_type_info_alter()

Related topics

2 functions implement hook_data_type_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_data_type_info in drupal/core/modules/field/field.module
Implements hook_data_type_info() to register data types for all field types.
system_data_type_info in drupal/core/modules/system/system.module
Implements hook_data_type_info().

File

drupal/core/modules/system/system.api.php, line 186
Hooks provided by Drupal core and the System module.

Code

function hook_data_type_info() {
  return array(
    'email' => array(
      'label' => t('Email'),
      'class' => '\\Drupal\\email\\Type\\Email',
      'primitive type' => \Drupal\Core\TypedData\Primitive::String,
    ),
  );
}