You are here

function hook_rules_data_type_info in Rules 6

Define rules data types.

This hook is required in order to add a new rules data type. It should be placed into the file MODULENAME.rules.inc.

Return value

An array of information about the module's provided data types. The array contains a sub-array for each data type, with the data type name as the key. See http://drupal.org/node/298633.

Possible attributes for each sub-array are:

  • 'label' The label of the data type. Start uncapitalized. Required.
  • 'class' The implementing class of the data type. It has to extend the class 'rules_data_type' and override methods depending on the other attributes 'identifiable', 'savable' and 'uses_input_form'. Thus this attribute is optional (defaulting to 'rules_data_type'), but in fact required for most data types.
  • 'identifiable' Whether data of this type can be identified, e.g. for loading from the database. Optional (defaults to TRUE).
  • 'savable' Whether data of this type can be saved automatically, so the save() method has to be implemented. Optional (defaults to FALSE).
  • 'uses_input_form' Whether the data type provides an input form for specifying a data value. Optional (defaults to not identifiable).
  • 'eval input' If the data type uses an input form, this can be used to enable input evaluation for it. Optional (defaults to FALSE).
  • 'token type' The type name as used by the token module. Defaults to the type name as used by rules. Use FALSE to let token ignore this type. Optional.
  • 'hidden' Whether the data type should be hidden from the UI. Optional (defaults to FALSE).
  • 'module' The providing module's user readable name. Rules generates actions to save 'savable' data types, thus this attribute is used for those generated actions. Should start with a capital letter. Optional.

@see class rules_data_type.

Related topics

6 functions implement hook_rules_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.

comment_rules_data_type_info in rules/modules/comment.rules.inc
Implementation of hook_rules_data_type_info()
node_rules_data_type_info in rules/modules/node.rules.inc
Implementation of hook_rules_data_type_info()
rules_forms_rules_data_type_info in rules_forms/rules_forms.rules.inc
Implementation of hook_rules_data_type_info().
rules_rules_data_type_info in rules/modules/rules.rules.inc
Implementation of hook_rules_data_type_info().
taxonomy_rules_data_type_info in rules/modules/taxonomy.rules.inc
Implementation of hook_rules_data_type_info().

... See full list

File

rules/rules.api.php, line 438
This file contains no working PHP code; it exists to provide additional documentation for doxygen as well as to document hooks in the standard Drupal manner.

Code

function hook_rules_data_type_info() {
  return array(
    'node' => array(
      'label' => t('content'),
      'class' => 'rules_data_type_node',
      'savable' => TRUE,
      'identifiable' => TRUE,
      'module' => 'Node',
    ),
  );
}