Porting Conditions

Last updated on
11 December 2021

Tasks

  1. Make a list of conditions that your module defines.
  2. Rules conditions are defined by hook_rules_condition_info(), which usually may be found in <modulename>/<modulename>.rules.inc (although, some modules implement this hook in <modulename>/<modulename>.module instead). Refer to the D7 version of these files to ensure that you port ALL the conditions that were in D7.
  3. Write a <modulename>/src/Plugin/Condition/<conditionname>.php class for each condition that your module defines. Use the classes provided by the Rules module in rules/src/Plugin/Condition/ as examples.
  4. Manually test, in the Rules UI, that each condition shows up and has the same arguments as it did in D7.
  5. Manually review the conditions plugins to make sure all comments and text strings are correct for each condition.
  6. Manually test, by creating test reaction rules in the Rules UI, that each condition works as expected.
  7. Write unit test cases for each condition. Use the code in rules/tests/src/Unit/Integration/Condition/* as examples.

Try not to skip writing the tests - these are EXTREMELY useful for maintaining your module and for documenting how you expect your conditions to work.

Help improve this page

Page status: No known problems

You can: