Updating module integration

Last updated on
30 November 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

API changes overview

  • Instead of providing separate actions / conditions, it might suffice now to provide some metadata for properties or entity types. See http://drupal.org/node/878880
  • For allowing Rules to intelligently handle saves of your data type, either specify metadata via hook_rules_data_info() or provide an entity, e.g. by using the Entity CRUD API. Entities are automatically supported, just provide metadata for them.
  • Rules caches all info definitions as needed, thus the MODULE.rules.inc is no longer included during rule evaluation except you put your action/condition execution callbacks in there. You may use a separate include file for action/condition execution callbacks and identify the file within hook_rules_file_info() -- or just put them in your .module file.

Updating code for providing actions / conditions

In contrast to 6.x-1.x it is now necessary to specify all arguments in the action info. But thanks to that, it is mostly unnecessary to provide a custom settings form. As a consequence, there is no ACTION_BASE_form() callback any more, but a ACTION_BASE_form_alter() callback. Check RulesPluginImplInterface for details.

The format of the action / condition info has slightly changed too:

  • The arguments key has been renamed to parameter. If there is a set of options to choose from, specify an options list callback. Also it is possible to restrict the input mode for a parameter using the new restrict key.
  • For parameters that should be saved upon successful action evaluation set save to TRUE instead of returning the variable. Even if save is TRUE, Rules will not save the passed parameter, if the callback returns FALSE. Returning a variable as in 6.x-1.x may still be used to updated the value of the passed argument.
  • The new variables key has been renamed to provides.
  • Remove the input eval key. All parameters must be explicitly specified.
  • There are no label callbacks in 7.x any more, just remove them.
  • Instead of the form validate and form submit callbacks there are now ACTION_BASE_validate and ACTION_BASE_process callbacks, which allow validation and processing of the configuration $settings, which has to happen independent of the $form submission.
  • Rules now obeys access permissions. Add appropriate access callback for using your provided action/condition info.

Updating code for providing events

  • The arguments key has been renamed to variables.
  • Rules now obeys access permissions. Add appropriate access callback for using the event.

Changed data types

  • Rules makes use of the same data types as entity metadata recognizes for hook_entity_property_info(). Thus also list is supported, as well as a generic 'entity' type. 'string' got renamed to 'text'.

Changed file inclusion

  • Keep your hooks in yourmodule.rules.inc, but support for rules_forms.inc have been removed. All callback may reside in the .rules.inc file.
  • Specify further include files using hook_rules_file_info(). All action or condition implementations may reside in any of those files or any other anytime included file.

Help improve this page

Page status: No known problems

You can: