Projet

Général

Profil

Paste
Télécharger (2,82 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / rules / rules.features.inc @ 950416da

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides Features integration for the Rules module.
6
 *
7
 * This code is based upon the features integration provided by the Entity API.
8
 */
9

    
10
/**
11
 * Controller handling the features integration.
12
 */
13
class RulesFeaturesController extends EntityDefaultFeaturesController {
14

    
15
  /**
16
   * Defines the result for hook_features_api().
17
   */
18
  public function api() {
19
    $info = parent::api();
20
    $info['rules_config']['default_file'] = FEATURES_DEFAULTS_CUSTOM;
21
    $info['rules_config']['default_filename'] = 'rules_defaults';
22
    return $info;
23
  }
24

    
25
  /**
26
   * Generates the result for hook_features_export().
27
   *
28
   * Overridden to add in rules-specific stuff.
29
   */
30
  public function export($data, &$export, $module_name = '') {
31
    $pipe = parent::export($data, $export, $module_name);
32
    foreach (entity_load_multiple_by_name($this->type, $data) as $name => $rules_config) {
33
      // Add in the dependencies.
34
      $export['dependencies'] += drupal_map_assoc($rules_config->dependencies());
35
      // Add in plugin / element specific additions.
36
      $iterator = new RecursiveIteratorIterator($rules_config, RecursiveIteratorIterator::SELF_FIRST);
37
      foreach ($iterator as $element) {
38
        if ($element->facesAs('RulesPluginFeaturesIntegrationInterface')) {
39
          // Directly use __call() so we can pass $export by reference.
40
          $element->__call('features_export', array(&$export, &$pipe, $module_name));
41
        }
42
      }
43
    }
44
    return $pipe;
45
  }
46

    
47
}
48

    
49
/**
50
 * Default extension callback used as default for the abstract plugin class.
51
 *
52
 * Actions and conditions may override this with an implementation which
53
 * actually does something.
54
 *
55
 * @see RulesPluginFeaturesIntegrationInterface
56
 */
57
function rules_features_abstract_default_features_export(&$export, &$pipe, $module_name = '', $element) {
58
  // Do nothing.
59
}
60

    
61
/**
62
 * Interface to give features access to the faces extensions mechanism.
63
 *
64
 * Interface that allows rules plugins or actions/conditions to customize the
65
 * features export by implementing the interface using the faces extensions
66
 * mechanism.
67
 *
68
 * @see hook_rules_plugin_info()
69
 * @see hook_rules_action_info()
70
 */
71
interface RulesPluginFeaturesIntegrationInterface {
72

    
73
  /**
74
   * Allows customizing the features export for a given rule element.
75
   */
76
  public function features_export(&$export, &$pipe, $module_name = '');
77

    
78
}
79

    
80
/**
81
 * Interface for backwards compatibility with older versions of Rules.
82
 *
83
 * Mis-spelled interface provided so that contributed modules which were
84
 * implementing the wrong spelling (corrected in Rules 7.x-2.12) will not stop
85
 * working now that the interface is spelled correctly.
86
 *
87
 * @todo Remove this when we can be sure that no contributed modules are
88
 * still using the wrong spelling.
89
 */
90
interface RulesPluginFeaturesIntegrationInterace extends RulesPluginFeaturesIntegrationInterface {
91
}