updated rules

This commit is contained in:
2020-06-23 12:29:12 +02:00
parent 35b78db5c0
commit da7085e201
72 changed files with 2402 additions and 1060 deletions
@@ -2,19 +2,20 @@
/**
* @file
* Documentation for hooks provided by the Rules API.
*
* This file contains no working PHP code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard
* Drupal manner.
*/
/**
* @defgroup rules Rules module integrations.
*
* Module integrations with the rules module.
*
* The Rules developer documentation describes how modules can integrate with
* rules: http://drupal.org/node/298486.
* rules: https://www.drupal.org/node/298486.
*/
/**
@@ -34,7 +35,7 @@
* handlers may be provided by implementing RulesActionHandlerInterface. See
* the interface for details.
*
* @return
* @return array
* An array of information about the module's provided rules actions.
* The array contains a sub-array for each action, with the action name as
* the key. Actions names may only contain lowercase alpha-numeric characters
@@ -66,7 +67,7 @@
* - 'access callback': (optional) A callback which has to return whether the
* currently logged in user is allowed to configure this action. See
* rules_node_integration_access() for an example callback.
* Each 'parameter' array may contain the following properties:
* Each 'parameter' array may contain the following properties:
* - label: The label of the parameter. Start capitalized. Required.
* - type: The rules data type of the parameter, which is to be passed to the
* action. All types declared in hook_rules_data_info() may be specified, as
@@ -114,7 +115,7 @@
* to clean inserted replacements; e.g. this is used by the token evaluator.
* - wrapped: (optional) Set this to TRUE in case the data should be passed
* wrapped. This only applies to wrapped data types, e.g. entities.
* Each 'provides' array may contain the following properties:
* Each 'provides' array may contain the following properties:
* - label: The label of the variable. Start capitalized. Required.
* - type: The rules data type of the variable. All types declared in
* hook_rules_data_info() may be specified. Types may be parametrized e.g.
@@ -122,21 +123,20 @@
* - save: (optional) If this is set to TRUE, the provided variable is saved
* by rules when the rules evaluation ends. Only possible for savable data
* types. Defaults to FALSE.
* The module has to provide an implementation for each action, being a
* function named as specified in the 'base' key or for the execution callback.
* All other possible callbacks are optional.
* Supported action callbacks by rules are defined and documented in the
* RulesPluginImplInterface. However any module may extend the action plugin
* based upon a defined interface using hook_rules_plugin_info(). All methods
* defined in those interfaces can be overridden by the action implementation.
* The callback implementations for those interfaces may reside in any file
* specified in hook_rules_file_info().
*
* The module has to provide an implementation for each action, being a
* function named as specified in the 'base' key or for the execution callback.
* All other possible callbacks are optional.
* Supported action callbacks by rules are defined and documented in the
* RulesPluginImplInterface. However any module may extend the action plugin
* based upon a defined interface using hook_rules_plugin_info(). All methods
* defined in those interfaces can be overridden by the action implementation.
* The callback implementations for those interfaces may reside in any file
* specified in hook_rules_file_info().
*
* @see hook_rules_file_info()
* @see rules_action_execution_callback()
* @see hook_rules_plugin_info()
* @see RulesPluginImplInterface
* @see hook_rules_file_info()
* @see rules_action_execution_callback()
* @see hook_rules_plugin_info()
* @see RulesPluginImplInterface
*/
function hook_rules_action_info() {
return array(
@@ -167,7 +167,7 @@ function hook_rules_action_info() {
* will be treated as grouping in the given category (e.g. group "paypal" in
* category "commerce payment").
*
* @return
* @return array
* An array of information about the module's provided categories.
* The array contains a sub-array for each category, with the category name as
* the key. Names may only contain lowercase alpha-numeric characters
@@ -176,18 +176,18 @@ function hook_rules_action_info() {
* - label: The label of the category. Start capitalized. Required.
* - weight: (optional) A weight for sorting the category. Defaults to 0.
* - equals group: (optional) For BC, categories may be defined that equal
* a previsouly used 'group'.
* a previously used 'group'.
* - icon: (optional) The file path of an icon to use, relative to the module
* or specified icon path. The icon should be a transparent SVG containing
* no colors (only #fff). See https://drupal.org/node/2090265 for
* instructions on how to create a suiting icon.
* no colors (only #fff). See https://www.drupal.org/node/2090265 for
* instructions on how to create a suitable icon.
* Note that the icon is currently not used by Rules, however other UIs
* building upon Rules (like fluxkraft) do, and future releases of Rules
* might do as well. Consequently, the definition of an icon is optional.
* However, if both an icon font and icon is given, the icon is preferred.
* - icon path: (optional) The base path for the icon. Defaults to the
* providing module's directory.
* - icon font class: (optional) An icon font class referring to a suiting
* - icon font class: (optional) An icon font class referring to a suitable
* icon. Icon font class names should map to the ones as defined by Font
* Awesome, while themes might want to choose to provide another icon font.
* See http://fortawesome.github.io/Font-Awesome/cheatsheet/.
@@ -221,7 +221,7 @@ function hook_rules_category_info() {
* plugin method callbacks in any file without having to care about file
* inclusion.
*
* @return
* @return array
* An array of file names without the file ending which defaults to '.inc'.
*/
function hook_rules_file_info() {
@@ -259,10 +259,11 @@ function hook_rules_directory() {
* The callback gets arguments passed as described as parameter in
* hook_rules_action_info() as well as an array containing the action's
* configuration settings.
* @return
* The action may return an array containg parameter or provided variables
*
* @return array
* The action may return an array containing parameter or provided variables
* with their names as key. This is used update the value of a parameter or to
* provdide the value for a provided variable.
* provide the value for a provided variable.
* Apart from that any parameters which have the key 'save' set to TRUE will
* be remembered to be saved by rules unless the action returns FALSE.
* Conditions have to return a boolean value in any case.
@@ -321,7 +322,7 @@ function hook_rules_condition_info() {
* handlers may be provided by implementing RulesEventHandlerInterface. See
* the interface for details.
*
* @return
* @return array
* An array of information about the module's provided rules events. The array
* contains a sub-array for each event, with the event name as the key. The
* name may only contain lower case alpha-numeric characters and underscores
@@ -360,11 +361,11 @@ function hook_rules_condition_info() {
* - handler: (optional) A handler to load the actual variable value. This
* is useful for lazy loading variables. The handler gets all so far
* available variables passed in the order as defined. Also see
* http://drupal.org/node/884554.
* https://www.drupal.org/node/884554.
* Note that for lazy-loading entities just the entity id may be passed
* as variable value, so a handler is not necessary in that case.
*
* @see rules_invoke_event()
* @see rules_invoke_event()
*/
function hook_rules_event_info() {
$items = array(
@@ -413,8 +414,7 @@ function hook_rules_event_info() {
* module.
* For a list of data types defined by rules see rules_rules_core_data_info().
*
*
* @return
* @return array
* An array of information about the module's provided data types. The array
* contains a sub-array for each data type, with the data type name as the
* key. The name may only contain lower case alpha-numeric characters and
@@ -446,7 +446,7 @@ function hook_rules_event_info() {
* makes use of the class for wrapping the data of the given type. However
* note that if data is already wrapped when it is passed to Rules, the
* existing wrappers will be kept.
* For modules implementing identifiable data types being non-entites the
* For modules implementing identifiable data types being non-entities the
* class RulesIdentifiableDataWrapper is provided, which can be used as base
* for a custom wrapper class. See RulesIdentifiableDataWrapper for details.
* - property info: (optional) May be used for non-entity data structures to
@@ -470,9 +470,9 @@ function hook_rules_event_info() {
* - cleaning callback: (optional) A callback that input evaluators may use
* to clean inserted replacements; e.g. this is used by the token evaluator.
*
* @see entity_metadata_wrapper()
* @see hook_rules_data_info_alter()
* @see rules_rules_core_data_info()
* @see entity_metadata_wrapper()
* @see hook_rules_data_info_alter()
* @see rules_rules_core_data_info()
*/
function hook_rules_data_info() {
return array(
@@ -497,7 +497,7 @@ function hook_rules_data_info() {
* A rules configuration may consist of elements being instances of any rules
* plugin. This hook can be used to define new or to extend rules plugins.
*
* @return
* @return array
* An array of information about the module's provided rules plugins. The
* array contains a sub-array for each plugin, with the plugin name as the
* key. The name may only contain lower case alpha-numeric characters,
@@ -543,8 +543,8 @@ function hook_rules_data_info() {
* of the 'or' plugin. Note that only uppercase values are allowed, as
* lower case values are treated as action or condition exports.
*
* @see class RulesPlugin
* @see hook_rules_plugin_info_alter()
* @see RulesPlugin
* @see hook_rules_plugin_info_alter()
*/
function hook_rules_plugin_info() {
return array(
@@ -583,7 +583,7 @@ function hook_rules_plugin_info() {
* and help() could be overridden in order to control access permissions or to
* provide some usage help.
*
* @return
* @return array
* An array of information about the module's provided input evaluators. The
* array contains a sub-array for each evaluator, with the evaluator name as
* the key. The name may only contain lower case alpha-numeric characters and
@@ -597,8 +597,8 @@ function hook_rules_plugin_info() {
* used. Defaults to 'text'. Multiple data types may be specified using an
* array.
*
* @see class RulesDataInputEvaluator
* @see hook_rules_evaluator_info_alter()
* @see RulesDataInputEvaluator
* @see hook_rules_evaluator_info_alter()
*/
function hook_rules_evaluator_info() {
return array(
@@ -606,7 +606,7 @@ function hook_rules_evaluator_info() {
'class' => 'RulesTokenEvaluator',
'type' => array('text', 'uri'),
'weight' => 0,
),
),
);
}
@@ -621,7 +621,7 @@ function hook_rules_evaluator_info() {
* access() could be overridden in order to provide a configuration form or
* to control access permissions.
*
* @return
* @return array
* An array of information about the module's provided data processors. The
* array contains a sub-array for each processor, with the processor name as
* the key. The name may only contain lower case alpha-numeric characters and
@@ -636,8 +636,8 @@ function hook_rules_evaluator_info() {
* used. Defaults to 'text'. Multiple data types may be specified using an
* array.
*
* @see class RulesDataProcessor
* @see hook_rules_data_processor_info_alter()
* @see RulesDataProcessor
* @see hook_rules_data_processor_info_alter()
*/
function hook_rules_data_processor_info() {
return array(
@@ -645,7 +645,7 @@ function hook_rules_data_processor_info() {
'class' => 'RulesDateOffsetProcessor',
'type' => 'date',
'weight' => -2,
),
),
);
}
@@ -658,10 +658,10 @@ function hook_rules_data_processor_info() {
* @param $actions
* The items of all modules as returned from hook_rules_action_info().
*
* @see hook_rules_action_info().
* @see hook_rules_action_info()
*/
function hook_rules_action_info_alter(&$actions) {
// The rules action is more powerful, so hide the core action
// The rules action is more powerful, so hide the core action.
unset($actions['rules_core_node_assign_owner_action']);
// We prefer handling saving by rules - not by the user.
unset($actions['rules_core_node_save_action']);
@@ -691,7 +691,7 @@ function hook_rules_condition_info_alter(&$conditions) {
* @param $events
* The items of all modules as returned from hook_rules_event_info().
*
* @see hook_rules_event_info().
* @see hook_rules_event_info()
*/
function hook_rules_event_info_alter(&$events) {
// Change events.
@@ -763,7 +763,7 @@ function hook_rules_data_processor_info_alter(&$processor_info) {
* This hook is invoked during rules configuration loading, which is handled
* by entity_load(), via classes RulesEntityController and EntityCRUDController.
*
* @param $configs
* @param array $configs
* An array of rules configurations being loaded, keyed by id.
*/
function hook_rules_config_load($configs) {
@@ -857,7 +857,7 @@ function hook_rules_config_execute($config) {
* should be placed into the file MODULENAME.rules_defaults.inc, which gets
* automatically included when the hook is invoked.
*
* @return
* @return array
* An array of rules configurations with the configuration names as keys.
*
* @see hook_default_rules_configuration_alter()
@@ -866,6 +866,8 @@ function hook_rules_config_execute($config) {
function hook_default_rules_configuration() {
$rule = rules_reaction_rule();
$rule->label = 'example default rule';
// Add rules tags.
$rule->tags = array('Admin', 'Tag2');
$rule->active = FALSE;
$rule->event('node_update')
->condition(rules_condition('data_is', array('data:select' => 'node:status', 'value' => TRUE))->negate())
@@ -873,6 +875,7 @@ function hook_default_rules_configuration() {
->action('drupal_message', array('message' => 'A node has been updated.'));
$configs['rules_test_default_1'] = $rule;
return $configs;
}
@@ -900,10 +903,10 @@ function hook_default_rules_configuration_alter(&$configs) {
* This hook is invoked by the entity module after default rules configurations
* have been rebuilt; i.e. defaults have been saved to the database.
*
* @param $rules_configs
* @param array $rules_configs
* The array of default rules configurations which have been inserted or
* updated, keyed by name.
* @param $originals
* @param array $originals
* An array of original rules configurations keyed by name; i.e. the rules
* configurations before the current defaults have been applied. For inserted
* rules configurations no original is available.
@@ -982,7 +985,8 @@ function hook_rules_event_set_alter($event_name, RulesEventSet $event_set) {
* @param $element
* The element array of a configured condition or action which is to be
* upgraded.
* @return
*
* @return string
* The name of the action or condition which should be used.
*/
function hook_rules_action_base_upgrade_map_name($element) {
@@ -990,13 +994,13 @@ function hook_rules_action_base_upgrade_map_name($element) {
}
/**
* D6 to D7 upgrade procedure hook for mapping action or condition configuration.
* D6 to D7 upgrade process hook for mapping action or condition configuration.
*
* During upgrading Drupal 6 rule configurations to Drupal 7 Rules is taking
* care of upgrading the configuration of all known parameters, which only works
* if the parameter name has not changed.
* If something changed, this callback can be used to properly apply the
* configruation of the Drupal 6 action ($element) to the Drupal 7 version
* configuration of the Drupal 6 action ($element) to the Drupal 7 version
* ($target).
*
* This is no real hook, but a callback that is invoked for each Drupal 6
@@ -1018,7 +1022,7 @@ function hook_rules_action_base_upgrade($element, RulesPlugin $target) {
}
/**
* D6 to D7 upgrade procedure hook for mapping action or condition configuration.
* D6 to D7 upgrade process hook for mapping action or condition configuration.
*
* A alter hook that is called after the action/condition specific callback for
* each element of a configuration that is upgraded.
@@ -1068,7 +1072,7 @@ function hook_rules_ui_menu_alter(&$items, $base_path, $base_count) {
* a given user has access to perform a given operation on a Rules
* configuration.
*
* @param $op
* @param string $op
* The operation being performed. One of 'view', 'create', 'update' or
* 'delete'.
* @param $rules_config
@@ -1077,7 +1081,8 @@ function hook_rules_ui_menu_alter(&$items, $base_path, $base_count) {
* @param $account
* (optional) The user to check for. If no account is passed, access is
* determined for the current user.
* @return boolean
*
* @return bool|null
* Return TRUE to grant access, FALSE to explicitly deny access. Return NULL
* or nothing to not affect the operation.
* Access is granted as soon as a module grants access and no one denies