You are here

function _ctools_configuration_get_info in Configuration Management 7

Helper function to return various ctools information for components.

5 calls to _ctools_configuration_get_info()
configuration_get_default in ./configuration.export.inc
Get defaults for a given module/component pair.
ctools_component_configuration_api in includes/configuration.ctools.inc
Master implementation of hook_configuration_api() for all ctools components.
ctools_component_configuration_export in includes/configuration.ctools.inc
Master implementation of hook_configuration_export() for all ctools components.
ctools_configuration_check in includes/configuration.ctools.inc
ctools_configuration_export_render in includes/configuration.ctools.inc
Implements hook_configuration_export_render(). Adds the ctools mothership hook, ctools_plugin_api().

File

includes/configuration.ctools.inc, line 214

Code

function _ctools_configuration_get_info($identifier = NULL, $reset = FALSE) {
  static $components;
  if (!isset($components) || $reset) {
    $components = array();
    $modules = configuration_get_info();
    ctools_include('export');
    foreach (ctools_export_get_schemas_by_module() as $module => $schemas) {
      foreach ($schemas as $table => $schema) {
        if ($schema['export']['bulk export']) {

          // Let the API owner take precedence as the owning module.
          $api_module = isset($schema['export']['api']['owner']) ? $schema['export']['api']['owner'] : $module;
          $components[$table] = array(
            'name' => isset($modules[$api_module]->info['name']) ? $modules[$api_module]->info['name'] : $api_module,
            'default_hook' => 'configuration_' . $schema['export']['default hook'],
            'default_file' => CONFIGURATION_DEFAULTS_INCLUDED,
            'module' => $api_module,
            'feature_source' => TRUE,
          );
          if (isset($schema['export']['api'])) {
            $components[$table] += array(
              'api' => $schema['export']['api']['api'],
              'default_filename' => $schema['export']['api']['api'],
              'current_version' => $schema['export']['api']['current_version'],
            );
          }
        }
      }
    }
  }

  // Return information specific to a particular component.
  if (isset($identifier)) {

    // Identified by the table name.
    if (isset($components[$identifier])) {
      return $components[$identifier];
    }
    elseif (substr_count($identifier, ':') === 2) {
      list($module, $api, $current_version) = explode(':', $identifier);

      // If a schema component matches the provided identifier, provide that
      // information. This also ensures that the version number is up to date.
      foreach ($components as $table => $info) {
        if ($info['module'] == $module && $info['api'] == $api && $info['current_version'] >= $current_version) {
          return $info;
        }
      }

      // Fallback to just giving back what was provided to us.
      return array(
        'module' => $module,
        'api' => $api,
        'current_version' => $current_version,
      );
    }
    return FALSE;
  }
  return $components;
}