You are here

function hook_features_export_render in Features 7.2

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

Component hook. Renders one or more component objects to code.

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

Parameters

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

array $data: An array of machine name identifiers for the objects to be rendered.

array $export: The full export array of the current feature being exported. This is only passed when hook_features_export_render() is invoked for an actual feature update or recreate, not during state checks or other operations.

Return value

string[]|mixed[] Format: Combination of:

  • $[$hook] = $function_body
  • $[$hook] = ['code' => $function_body, 'args' => $params_php]

An associative array of rendered PHP code where the key is the name of the hook that should wrap the PHP code. The hook should not include the name of the module, e.g. the key for `hook_example` should simply be `example` The values in the array can also be in the form of an associative array with the required key of 'code' and optional key of 'args', if 'args' need to be added to the hook. Alternate it can be an associative array in the same style as hook_features_export_files() to add additional files.

16 functions implement hook_features_export_render()

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

contact_categories_features_export_render in includes/features.contact.inc
Implements hook_features_export_render().
ctools_component_features_export_render in includes/features.ctools.inc
Master implementation of hook_features_export_render() for all ctools components.
ctools_features_export_render in includes/features.ctools.inc
Implements hook_features_export_render(). Adds the ctools mothership hook, ctools_plugin_api().
field_base_features_export_render in includes/features.field.inc
Implements hook_features_export_render().
field_features_export_render in includes/features.field.inc
Implements hook_features_export_render().

... See full list

File

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

Code

function hook_features_export_render($module_name, $data, $export = NULL) {
  $code = array();
  $code[] = '$mycomponents = array();';
  foreach ($data as $name) {
    $code[] = "  \$mycomponents['{$name}'] = " . features_var_export(mycomponent_load($name)) . ";";
  }
  $code[] = "return \$mycomponents;";
  $code = implode("\n", $code);
  return array(
    'mycomponent_defaults' => $code,
  );
}