Conditional Actions (CA) is a module similar to the Actions system in Drupal 6. When a certain event happens, a trigger causes the module to perform actions on the site. In addition, CA gives the user and other modules the opportunity to prevent the actions from happening if certain conditions are not met when the trigger is pulled.
- Define a set of data objects (entity) with their load and save callbacks and types.
These entities may be passed in to ca_pull_trigger and mapped to a predicate's arguments.
- Define a trigger name with its list of entity arguments. Triggers are fired by ca_pull_trigger('trigger_name', args...)
- Define a condition name with its callback and entity arguments.
- Define an action name with its callback and entity arguments.
- Define a module provided predicate. Predicates are conditions and actions attached to a trigger. The predicate settings map the arguments available from the trigger to the conditions and actions. Conditions and actions can only receive arguments specified by trigger. If the necessary arguments are not available, the condition or action is skipped.
Flow for ca_pull_trigger()
- Prepare by validating inputs.
- Invoke hook_ca_trigger().
- Make sure specified trigger exists.
- Invoke hook_ca_predicate().
- Merge with user modifications from DB, then return predicates for the specified trigger.
- Invoke hook_ca_entity().
- Make sure argument types match trigger definition.
- For each predicate
- Invoke hook_ca_condition().
- Call condition callbacks, and if they return TRUE:
- Invoke hook_ca_action().
- Call action callbacks.