You are here

function _configuration_restore in Configuration Management 7

Restore the specified modules to the default state.

4 calls to _configuration_restore()
configuration_disable_configuration in ./configuration.module
Wrapper around _configuration_restore().
configuration_enable_configuration in ./configuration.module
Wrapper around _configuration_restore().
configuration_rebuild in ./configuration.module
Wrapper around _configuration_restore().
configuration_revert in ./configuration.module
Wrapper around _configuration_restore().

File

./configuration.module, line 815
Module file for the configuration module, which enables the capture and management of configuration in Drupal.

Code

function _configuration_restore($op, $items = array(), $module_name = 'configuration') {
  module_load_include('inc', 'configuration', 'configuration.export');
  configuration_include();
  switch ($op) {
    case 'revert':

      // $restore_states = array(FEATURES_OVERRIDDEN, FEATURES_REBUILDABLE, FEATURES_NEEDS_REVIEW);
      $restore_hook = 'configuration_revert';
      $log_action = 'Revert';
      break;
    case 'rebuild':

      // $restore_states = array(FEATURES_REBUILDABLE);
      $restore_hook = 'configuration_rebuild';
      $log_action = 'Rebuild';
      break;
    case 'disable':
      $restore_hook = 'configuration_disable_configuration';
      $log_action = 'Disable';
      break;
    case 'enable':
      $restore_hook = 'configuration_enable_configuration';
      $log_action = 'Enable';
      break;
  }
  if (empty($items)) {

    // Drush may execute a whole chain of commands that may trigger configuration
    // rebuilding multiple times during a single request. Make sure we do not
    // rebuild the same cached list of modules over and over again by setting
    // $reset to TRUE.
    // Note: this may happen whenever more than one configuration will be enabled
    // in chain, for example also using configuration_install_modules().
    $states = configuration_get_component_states(array(), $op == 'rebuild', defined('DRUSH_BASE_PATH'));
    foreach ($states as $module_name => $components) {
      foreach ($components as $component => $state) {
        if (in_array($state, $restore_states)) {
          $items[$module_name][] = $component;
        }
      }
    }
  }
  foreach ($items as $component => $checked) {
    if (configuration_hook($component, $restore_hook)) {
      $selected = array_filter($checked);

      // Set a semaphore to prevent other instances of the same script from running concurrently.
      watchdog('configuration', '@actioning @module_name / @component.', array(
        '@action' => $log_action,
        '@component' => $component,
        '@module_name' => $module_name,
      ));
      configuration_semaphore('set', $component);
      configuration_invoke($component, $restore_hook, array_keys($selected), $module_name);

      // If the script completes, remove the semaphore and set the code signature.
      configuration_semaphore('del', $component);
      configuration_set_signature($module_name, $component);
      watchdog('configuration', '@action completed for @module_name / @component.', array(
        '@action' => $log_action,
        '@component' => $component,
        '@module_name' => $module_name,
      ));
    }
  }
}