Porting Rules code from Drupal 7

Porting code to Drupal 8 or Drupal 9 is a big deal - there are so many changes between D7 and D8/9 it's tempting to re-write your code from scratch rather than try to port it. This is hindered by lack of documentation for a lot of Drupal 8/9 - this lack of documentation is much much worse for contributed modules like Rules. Many times you have to resort to reading code to figure out how things are supposed to work, because there is no documentation and no examples!

By providing some examples here, I hope I can ease this painful process. These examples complement the more detailed description found later in this documentation - I'm not going to try to explain too much here, just present both 'before' and 'after' code that covers many typical use cases, so you can shortcut much of the process.

Porting Events

Steps for porting Drupal 7 code that uses hook_rules_event_info() to define custom events

Porting Conditions

Steps for porting Drupal 7 code that uses hook_rules_condition_info() to define custom conditions

Porting Actions

Steps for porting Drupal 7 code that uses hook_rules_action_info() to define custom actions

Porting Reaction Rules

A checklist

Porting Rules Components

A checklist

Exposing data to Rules

Steps for porting code that uses hook_rules_data_info() in Drupal 7 to expose custom data structures to Rules

Porting Expression Plugins

Steps for porting code that uses hook_rules_plugin_info() in Drupal 7 to define custom plugins

Guide maintainers

tr's picture