You are here

function configuration_get_default in Configuration Management 7

Get defaults for a given module/component pair.

15 calls to configuration_get_default()
configuration_get_default_map in ./configuration.export.inc
Get a map of components to their providing modules.
configuration_get_signature in ./configuration.export.inc
Wrapper around configuration_get_[storage] to return an md5hash of a normalized defaults/normal object array. Can be used to compare normal/default states of a module's component.
ctools_component_configuration_revert in includes/configuration.ctools.inc
Master implementation of hook_configuration_revert() for all ctools components.
field_configuration_rebuild in includes/configuration.field.inc
Implements of hook_configuration_rebuild(). Rebuilds fields from code defaults.
filter_configuration_rebuild in includes/configuration.filter.inc
Implements hook_configuration_rebuild().

... See full list

File

./configuration.export.inc, line 521

Code

function configuration_get_default($component, $module_name = NULL, $alter = TRUE, $reset = FALSE) {
  static $cache = array();
  configuration_include();
  configuration_include_defaults($component);
  $default_hook = configuration_get_default_hooks($component);
  $components = configuration_get_components();

  // Collect defaults for all modules if no module name was specified.
  if (isset($module_name)) {
    $modules = array(
      $module_name,
    );
  }
  else {
    if ($component === 'dependencies') {
      $modules = array_keys(configuration_get_configurations());
    }
    else {
      $modules = array(
        'configuration',
      );
    }
  }

  // Collect and cache information for each specified module.
  foreach ($modules as $m) {
    if (!isset($cache[$component][$m]) || $reset) {

      // Special handling for dependencies component.
      if ($component === 'dependencies') {
        $module = configuration_get_configuration($m);
        $cache[$component][$m] = isset($module->info['dependencies']) ? $module->info['dependencies'] : array();
        unset($module);
      }
      else {
        if ($default_hook && module_hook($m, $default_hook)) {
          $cache[$component][$m] = call_user_func("{$m}_{$default_hook}");
          if ($alter) {
            drupal_alter($default_hook, $cache[$component][$m]);
          }
        }
        elseif ($default_hook && module_exists('ctools') && _ctools_configuration_get_info()) {

          // If this is a ctools export, the file containing the hook may not be
          // loaded.  Load the file here.
          $info = _ctools_configuration_get_info();
          if (isset($info[$component])) {
            $function = $module_name . '_configuration_' . $info[$component]['default_hook'];
            if (function_exists($function)) {
              $cache[$component][$m] = call_user_func($function);
            }
            if ($alter) {
              drupal_alter($default_hook, $cache[$component][$m]);
            }
          }
        }
        else {
          $cache[$component][$m] = FALSE;
        }
      }
    }
  }

  // A specific module was specified. Retrieve only its components.
  if (isset($module_name)) {
    return isset($cache[$component][$module_name]) ? $cache[$component][$module_name] : FALSE;
  }

  // No module was specified. Retrieve all components.
  $all_defaults = array();
  if (isset($cache[$component])) {
    foreach (array_filter($cache[$component]) as $module_components) {
      $all_defaults = array_merge($all_defaults, $module_components);
    }
  }
  return $all_defaults;
}