You are here

function ctools_component_features_export in Features 7.2

Same name and namespace in other branches
  1. 6 includes/features.ctools.inc \ctools_component_features_export()
  2. 7 includes/features.ctools.inc \ctools_component_features_export()

Master implementation of hook_features_export() for all ctools components.

This is not registered as a hook implementation by itself. Instead, it gets called from other implementations, especially those dynamically declared in ctools_features_declare_functions().

Parameters

string $component: Component name.

string[] $data: Identifiers of objects to export.

array $export: Export array.

string $module_name: Feature module name.

Return value

string[][] The pipe array.

See also

\hook_features_export()

1 call to ctools_component_features_export()
context_features_export in includes/features.context.inc
Implements hook_features_export().

File

includes/features.ctools.inc, line 212
Features integration for 'ctools' module.

Code

function ctools_component_features_export($component, $data, &$export, $module_name = '') {

  // Add the actual implementing module as a dependency.
  $info = _ctools_features_get_info();
  if ($module_name !== $info[$component]['module']) {
    $export['dependencies'][$info[$component]['module']] = $info[$component]['module'];
  }

  // Add the components.
  foreach ($data as $object_name) {
    if ($object = _ctools_features_export_crud_load($component, $object_name)) {

      // If this object is provided as a default by a different module, don't
      // export and add that module as a dependency instead.
      if (!empty($object->export_module) && $object->export_module !== $module_name) {
        $export['dependencies'][$object->export_module] = $object->export_module;
        if (isset($export['features'][$component][$object_name])) {
          unset($export['features'][$component][$object_name]);
        }
      }
      else {
        $export['features'][$component][$object_name] = $object_name;
      }
    }
  }

  // Let CTools handle API integration for this component.
  return array(
    'ctools' => array(
      $component,
    ),
  );
}