-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.features.inc
83 lines (73 loc) · 2.64 KB
/
rules.features.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
<?php
/**
* @file
* Provides Features integration for the Rules module, based upon the features
* integration provided by the Entity API.
*/
/**
* Controller handling the features integration.
*/
class RulesFeaturesController extends EntityDefaultFeaturesController {
/**
* Defines the result for hook_features_api().
*/
public function api() {
$info = parent::api();
$info['rules_config']['default_file'] = FEATURES_DEFAULTS_CUSTOM;
$info['rules_config']['default_filename'] = 'rules_defaults';
return $info;
}
/**
* Generates the result for hook_features_export().
* Overridden to add in rules specific stuff.
*/
public function export($data, &$export, $module_name = '') {
$pipe = parent::export($data, $export, $module_name);
foreach (entity_load_multiple_by_name($this->type, $data) as $name => $rules_config) {
// Add in the dependencies.
$export['dependencies'] += drupal_map_assoc($rules_config->dependencies());
// Add in plugin / element specific additions.
$iterator = new RecursiveIteratorIterator($rules_config, RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $element) {
if ($element->facesAs('RulesPluginFeaturesIntegrationInterface')) {
// Directly use __call() so we can pass $export by reference.
$element->__call('features_export', array(&$export, &$pipe, $module_name));
}
}
}
return $pipe;
}
}
/**
* Default extension callback used as default for the abstract plugin class.
* Actions / conditions may override this with their own implementation, which
* actually does something.
*
* @see RulesPluginFeaturesIntegrationInterface
*/
function rules_features_abstract_default_features_export(&$export, &$pipe, $module_name = '', $element) {
}
/**
* Interface that allows rules plugins or actions/conditions to customize the
* features export by implementing the interface using the faces extensions
* mechanism.
*
* @see hook_rules_plugin_info()
* @see hook_rules_action_info()
*/
interface RulesPluginFeaturesIntegrationInterface {
/**
* Allows customizing the features export for a given rule element.
*/
function features_export(&$export, &$pipe, $module_name = '');
}
/**
* Mis-spelled interface provided so that contributed modules which were
* implementing the wrong spelling (corrected in Rules 7.x-2.12) will not stop
* working now that the interface is spelled correctly.
*
* @todo Remove this when we can be sure that no contributed modules are
* still using the wrong spelling.
*/
interface RulesPluginFeaturesIntegrationInterace extends RulesPluginFeaturesIntegrationInterface {
}