You are here

function ctools_component_features_export_render in Features 6

Same name and namespace in other branches
  1. 7.2 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.

2 calls to ctools_component_features_export_render()
context_features_export_render in includes/features.context.inc
Implementation of hook_features_export_render().
page_manager_pages_features_export_render in includes/features.ctools.inc
Implementation of hook_features_export_render() for page_manager.

File

includes/features.ctools.inc, line 157

Code

function ctools_component_features_export_render($component, $module, $data) {
  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($code, "{\n"));
    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,
  );
}