Projet

Général

Profil

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

root / drupal7 / sites / all / modules / rules / rules.features.inc @ d719f12f

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides Features integration for the Rules module, based upon the features
6
 * integration provided by the Entity API.
7
 */
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
   * Overridden to add in rules specific stuff.
28
   */
29
  public function export($data, &$export, $module_name = '') {
30
    $pipe = parent::export($data, $export, $module_name);
31
    foreach (entity_load_multiple_by_name($this->type, $data) as $name => $rules_config) {
32
      // Add in the dependencies.
33
      $export['dependencies'] += drupal_map_assoc($rules_config->dependencies());
34
      // Add in plugin / element specific additions.
35
      $iterator = new RecursiveIteratorIterator($rules_config, RecursiveIteratorIterator::SELF_FIRST);
36
      foreach ($iterator as $element) {
37
        if ($element->facesAs('RulesPluginFeaturesIntegrationInterace')) {
38
          // Directly use __call() so we cann pass $export by reference.
39
          $element->__call('features_export', array(&$export, &$pipe, $module_name));
40
        }
41
      }
42
    }
43
    return $pipe;
44
  }
45
}
46

    
47
/**
48
 * Default extension callback used as default for the abstract plugin class.
49
 * Actions / conditions may override this with their own implementation, which
50
 * actually does something.
51
 *
52
 * @see RulesPluginFeaturesIntegrationInterace
53
 */
54
function rules_features_abstract_default_features_export(&$export, &$pipe, $module_name = '', $element) {
55

    
56
}
57

    
58
/**
59
 * Interface that allows rules plugins or actions/conditions to customize the
60
 * features export by implementing the interface using the faces extensions
61
 * mechanism.
62
 *
63
 * @see hook_rules_plugin_info()
64
 * @see hook_rules_action_info()
65
 */
66
interface RulesPluginFeaturesIntegrationInterace {
67

    
68
  /**
69
   * Allows customizing the features export for a given rule element.
70
   */
71
  function features_export(&$export, &$pipe, $module_name = '');
72
}