Voting starts in March for the Drupal Association Board election.
Components are stand-alone Rules configuration that can be called from reaction rules, other modules and also programmatically from custom code. Components may be useful in the following cases:
- You are using modules that make use of components, such as Views Bulk Operations or Rules Scheduler.
- You have complex actions or conditions used in multiple places in your configuration, and want to manage them all in one place.
- You are writing a module that uses configurable actions or conditions, and you don't want to write the user interface from scratch.
- You are exporting Rules configuration, and you want fine-grained control over the exports.
- You have complex actions you want to run manually every once in a while.
Rules component system is pluggable, which means that modules can provide more component types. The types available by default are:
- Rule: Rule components are the most versatile. They contain both conditions and actions. Unlike reaction rules, rule components don't have any events.
- Action set: This is a set of actions, executed one after the other.
- Condition set (OR): This is a set of conditions, where only one needs to be met in order for the whole set to be evaluated to true.
- Condition set (AND): This is a set of conditions, where all must be met in order for the whole set to be evaluated to true.
- Rule set: This is a set of rules, evaluated one after the other. As with rule components, rule sets don't have any events. Rule sets are useful when you want to perform one or several actions, depending on the context.
Variables and creating components
When creating a component, you are asked to enter any variables that the component uses. Normally, variables are parameters – input data that the component needs in order to know what to do.
Note: It is not required to configure variables to begin. You can start building a component by hard-coding with an example object to make sure it works correctly, and then add variables to replace whichever aspects or your component need to be changed dynamically. Begin by manually loading an example object which your component will use, and then remove it later once you know it works and your component's element are configured to use variables.
You must specify the data type for each variable, and also give it a label (used in the admin interface) and a unique machine name (used for data selection and more).
Variables can also be provided – meaning that they are output rather than required input.
Example 1: An action set sending a message to a node author needs to know which node to act on. Additionally, you could add a text parameter, to allow specifying or varying the message to send. You would not need a user parameter, since that can be fetched from the node parameter.
Example 2: An action set loading a user's most recent comment would require a user parameter. It could also have a comment as a provided parameter, allowing the calling function to act on the fetched comment.
Executing components manually
In the overview of available components, each component has an execute link. This can be used for executing the component manually, without the need of reaction rules or other modules. When executing a component manually, you are asked to enter all parameters manually (if any). If the component has any entity parameters, you can switch to "direct input" mode and enter the ID of the entity.