Community Documentation

5. Updating module integration

Last updated January 25, 2009. Created by jpetso on August 23, 2008.
Edited by fago, MGParisi. Log in to edit this page.

This document helps you to update your workflow-ng module integration to rules. Note that you can import workflow-ng rules in the usual rules import tool - this is useful for easy testing converting rules from workflow-ng to rules.

General changes

  • Module integration goes into a .rules.inc include file
  • All hooks are prefixed with 'rules' now, hook_action_info is hook_rules_action_info and so so on.
  • The keys of the items returned by the hook_rules_*_info implementations does not make use of the leading # any more. Remove it from every property, e.g. by automatically replace all "'#" with single quote (').
  • Replace 'workflow_ng' with 'rules'.
  • In the hook_*_info implementations replace the 'description' property with the 'help' property or remove it, if it's just a description and no help.

Actions and conditions

A straight action and conditions update requires the following:

  • Remove all calls to workflow-ng's token integration. Just make use of input evaluation instead.
  • Change the configuration forms to work with the new function parameters as documented here. Most of the time all that is needed is:
    • Adapt the function signature to $settings, &$form
    • Remove the return $form, as $form is taken by reference now.
    • Put the form elements in $form['settings'].
    • Remove calls to add token help.
    • Remove the form submit callback and if needed alter $settings function signature to &$settings, $form, $form_state and just alter $settings.
  • Replace the 'new arguments' property with 'new variables'.
  • Optionally improve the action or condition by specifying label callbacks for the action / condition or for new variables.

Sometimes this doesn't suffice. E.g. one new single actions should replace two old ones. In such cases; implement the upgrade callback for actions / conditions.

Events

  • As the {modulename}.rules.inc files are only included by rules, when rules are evaluated, you can't invoke your events from there. Best just do it in your modulename.module file and wrap the call to rules_invoke_event() into a if (module_exists('rules')) check.
  • If your event names have changed, you have to provide a mapping from the old to the new name.

Misc changes

  • Providing default rules has changed. Update your default rules and export them again.
  • hook_entity_info() has been deprecated in favour of hook_rules_data_type_info(). Also, the 'entity' property of arguments in hook_rules_event_info() needs to be replaced with 'type' if you make use of data types.

About this page

Drupal version
Drupal 6.x
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here