On this page
Porting Conditions
Last updated on
11 December 2021
Tasks
- Make a list of conditions that your module defines.
- 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. - Write a
<modulename>/src/Plugin/Condition/<conditionname>.php
class for each condition that your module defines. Use the classes provided by the Rules module inrules/src/Plugin/Condition/
as examples. - Manually test, in the Rules UI, that each condition shows up and has the same arguments as it did in D7.
- Manually review the conditions plugins to make sure all comments and text strings are correct for each condition.
- Manually test, by creating test reaction rules in the Rules UI, that each condition works as expected.
- 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:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion