-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrules.rules.inc
143 lines (129 loc) · 3.82 KB
/
rules.rules.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/**
* @file
* Includes any rules integration provided by the module.
*/
/*
* Load all module includes as soon as this file gets included, which is done
* automatically by module_implements().
*/
foreach (rules_core_modules() as $module) {
module_load_include('inc', 'rules', "modules/$module.rules");
}
/**
* Defines a list of core module on whose behalf we provide module integration.
*
* We also add a pseudo 'data' module, which will be used for providing generic
* rules data integration, 'entity' for entity-related integration and 'rules'
* for providing some general stuff.
*/
function rules_core_modules() {
// Make use of the fast, advanced Backdrop static pattern.
static $backdrop_static_fast;
if (!isset($backdrop_static_fast)) {
$backdrop_static_fast = &backdrop_static(__FUNCTION__);
}
$modules = &$backdrop_static_fast;
if (!isset($modules)) {
$modules = array('data', 'entity', 'node', 'system', 'user', 'rules_core');
foreach (array('comment', 'taxonomy', 'php', 'path') as $module) {
if (module_exists($module)) {
$modules[] = $module;
}
}
}
return $modules;
}
/**
* Returns all items for a hook applying the right module defaults.
*/
function _rules_rules_collect_items($hook) {
$items = array();
foreach (rules_core_modules() as $module) {
if (function_exists($function = "rules_{$module}_{$hook}")) {
$items += (array) $function();
}
}
return $items;
}
/**
* Implements hook_rules_file_info().
*/
function rules_rules_file_info() {
// Make use of the fast, advanced Backdrop static pattern.
static $backdrop_static_fast;
if (!isset($backdrop_static_fast)) {
$backdrop_static_fast = &backdrop_static(__FUNCTION__);
}
$items = &$backdrop_static_fast;
if (!isset($items)) {
$items = array();
foreach (rules_core_modules() as $module) {
if (function_exists($function = "rules_{$module}_file_info")) {
$items = array_merge($items, (array) $function());
// Automatically add "$module.rules.inc" for each module.
$items[] = 'modules/' . $module . '.rules';
}
}
}
return $items;
}
/**
* Implements hook_rules_category_info().
*/
function rules_rules_category_info() {
return _rules_rules_collect_items('category_info');
}
/**
* Implements hook_rules_action_info().
*/
function rules_rules_action_info() {
return _rules_rules_collect_items('action_info');
}
/**
* Implements hook_rules_condition_info().
*/
function rules_rules_condition_info() {
return _rules_rules_collect_items('condition_info');
}
/**
* Implements hook_rules_event_info().
*/
function rules_rules_event_info() {
$items = array();
foreach (entity_plus_crud_get_info() as $type => $info) {
// By default we enable the controller only for non-configuration.
$configuration = !empty($info['configuration']) || !empty($info['exportable']);
$info += array('rules controller class' => $configuration ? FALSE : 'RulesEntityEventController');
if ($info['rules controller class']) {
$controller = new $info['rules controller class']($type);
$items += $controller->eventInfo();
}
}
return array_merge(_rules_rules_collect_items('event_info'), $items);
}
/**
* Implements hook_rules_data_info().
*/
function rules_rules_data_info() {
return _rules_rules_collect_items('data_info');
}
/**
* Implements hook_rules_data_info_alter().
*/
function rules_rules_data_info_alter(&$items) {
// For now just invoke the rules core implementation manually.
rules_rules_core_data_info_alter($items);
}
/**
* Implements hook_rules_evaluator_info().
*/
function rules_rules_evaluator_info() {
return _rules_rules_collect_items('evaluator_info');
}
/**
* Implements hook_rules_data_processor_info().
*/
function rules_rules_data_processor_info() {
return _rules_rules_collect_items('data_processor_info');
}