You are here

function hook_features_export in Features 7.2

Same name and namespace in other branches
  1. 6 features.api.php \hook_features_export()
  2. 7 features.api.php \hook_features_export()

Component hook. Process the export array for a given component.

The hook should be implemented using the name of the component, not the module, eg. [component]_features_export() rather than [module]_features_export().

Implementations of this hook have three key tasks:

1. Determine module dependencies for any of the components passed to it e.g. the views implementation iterates over each views' handlers and plugins to determine which modules need to be added as dependencies.

2. Correctly add components to the export array. In general this is usually adding all of the items in $data to $export['features']['my_key'], but can become more complicated if components are shared between features or modules.

3. Delegating further detection and export tasks to related or derivative components.

Each export processor can kickoff further export processors by returning a keyed array (aka the "pipe") where the key is the next export processor hook to call and the value is an array to be passed to that processor's $data argument. This allows an export process to start simply at a few objects:

[context]

And then branch out, delegating each component to its appropriate hook:

[context]--------+------------+ | | | [node] [block] [views] | [CCK] | [imagecache]

Parameters

string[] $data: An array of machine names for the component in question to be exported.

array &$export: By reference. An array of all components to be exported with a given feature. Component objects that should be exported should be added to this array.

string $module_name: The name of the feature module to be generated.

Return value

string[][]|void Format: $[$component][] = $name The pipe array of further processors that should be called.

20 functions implement hook_features_export()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

block_features_export in includes/features.block.inc
Implements hook_features_export().
contact_categories_features_export in includes/features.contact.inc
Implements hook_features_export().
context_features_export in includes/features.context.inc
Implements hook_features_export().
ctools_component_features_export in includes/features.ctools.inc
Master implementation of hook_features_export() for all ctools components.
ctools_features_export in includes/features.ctools.inc
Implements hook_features_export(). Adds references to the ctools mothership hook, ctools_plugin_api().

... See full list

File

./features.api.php, line 154
Hooks provided by the features module.

Code

function hook_features_export($data, &$export, $module_name) {

  // The following is the simplest implementation of a straight object export
  // with no further export processors called.
  foreach ($data as $component) {
    $export['features']['mycomponent'][$component] = $component;
  }
  return array();
}