You are here

function ctools_component_features_export_render in Features 7.2

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

Master implementation of hook_features_export_render() 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: The component name.

string $module: Feature module name.

string[] $data: Identifiers of objects to be rendered.

Return value

string[] Format: $[$hook_name] = $function_body.

See also

\hook_features_export_render()

1 call to ctools_component_features_export_render()
page_manager_pages_features_export_render in includes/features.ctools.inc
Implements hook_features_export_render() for page_manager.

File

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

Code

function ctools_component_features_export_render($component, $module, $data) {

  // Reset the export display static to prevent clashes.
  drupal_static_reset('panels_export_display');
  ctools_include('export');
  $schema = ctools_export_get_schema($component);
  if (function_exists($schema['export']['to hook code callback'])) {
    $export = $schema['export']['to hook code callback']($data, $module);
    $code = explode("{\n", $export);
    array_shift($code);
    $code = explode('}', implode("{\n", $code));
    array_pop($code);
    $code = implode('}', $code);
  }
  else {
    $code = '  $export = array();' . "\n\n";
    foreach ($data as $object_name) {
      if ($object = _ctools_features_export_crud_load($component, $object_name)) {
        $identifier = $schema['export']['identifier'];
        $code .= _ctools_features_export_crud_export($component, $object, '  ');
        $code .= "  \$export[" . ctools_var_export($object_name) . "] = \${$identifier};\n\n";
      }
    }
    $code .= '  return $export;';
  }
  return array(
    $schema['export']['default hook'] => $code,
  );
}