You are here

function ctools_features_export_render in Features 7.2

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

Implements hook_features_export_render(). Adds the ctools mothership hook, ctools_plugin_api().

File

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

Code

function ctools_features_export_render($module, $data) {
  $component_exports = array();
  foreach ($data as $component) {
    $code = array();
    if ($info = _ctools_features_get_info($component)) {

      // For background on why we change the output for hook_views_api()
      // see http://drupal.org/node/1459120.
      if ($info['module'] == 'views') {
        $code[] = '  return array("api" => "3.0");';
      }
      else {
        $code[] = '  if ($module == "' . $info['module'] . '" && $api == "' . $info['api'] . '") {';
        $code[] = '    return array("version" => "' . $info['current_version'] . '");';
        $code[] = '  }';
      }
    }
    ctools_include('plugins');
    $plugin_api_hook_name = ctools_plugin_api_get_hook($info['module'], $info['api']);
    if (key_exists($plugin_api_hook_name, $component_exports)) {
      $component_exports[$plugin_api_hook_name]['code'] .= "\n" . implode("\n", $code);
    }
    else {
      $component_exports[$plugin_api_hook_name] = array(
        'code' => implode("\n", $code),
        'args' => '$module = NULL, $api = NULL',
      );
    }
  }
  return $component_exports;
}