You are here

function _features_populate in Features 7

Same name and namespace in other branches
  1. 6 features.export.inc \_features_populate()
  2. 7.2 features.export.inc \_features_populate()

Iterate and descend into a feature definition to extract module dependencies and feature definition. Calls hook_features_export for modules that implement it.

Parameters

$pipe: Associative of array of module => info-for-module

$export: Associative array of items, and module dependencies which define a feature. Passed by reference.

Return value

fully populated $export array.

2 calls to _features_populate()
drush_features_export in ./features.drush.inc
Add a component to a features module, or create a new module with the selected components.
features_populate in ./features.export.inc

File

./features.export.inc, line 47

Code

function _features_populate($pipe, &$export, $module_name = '') {
  features_include();
  foreach ($pipe as $component => $data) {
    static $processed = array();

    // Convert already defined items to dependencies.
    _features_resolve_dependencies($data, $export, $module_name, $component);
    if (!empty($data) && ($function = features_hook($component, 'features_export'))) {

      // Pass module-specific data and export array.
      // We don't use features_invoke() here since we need to pass $export by reference.
      $more = $function($data, $export, $module_name, $component);

      // Add the context information.
      $export['component'] = $component;
      $export['module_name'] = $module_name;

      // Allow other modules to manipulate the pipe to add in additional modules.
      drupal_alter(array(
        'features_pipe',
        'features_pipe_' . $component,
      ), $more, $data, $export);

      // Remove the component information.
      unset($export['component']);
      unset($export['module_name']);

      // Allow for export functions to request additional exports, but avoid
      // circular references on already processed components.
      $processed[$component] = isset($processed[$component]) ? array_merge($processed[$component], $data) : $data;
      if (!empty($more)) {

        // Remove already processed components.
        foreach ($more as $component_name => $component_data) {
          if (isset($processed[$component_name])) {
            $more[$component_name] = array_diff($component_data, $processed[$component_name]);
          }
        }
        if ($more = array_filter($more)) {
          _features_populate($more, $export, $module_name);
        }
      }
    }
  }
  return $export;
}