1 config.sync.inc _config_sync_validate(&$context)

Batch API callback. Validate the changes before attempting to sync.

File

core/modules/config/config.sync.inc, line 40

Code

function _config_sync_validate(&$context) {
  if (!isset($context['sandbox']['batch_size'])) {
    $context['sandbox']['batch_size'] = config_get('system.core', 'config_sync_batch_size');
    $context['sandbox']['total_size'] = count($context['results']['pending_changes']);
    $context['sandbox']['current_index'] = 0;
  }

  $config_files = array_slice($context['results']['pending_changes'], $context['sandbox']['current_index'], $context['sandbox']['batch_size']);
  try {
    foreach ($config_files as $config_file => $config_change_type) {
      config_sync_validate_file($config_file, $config_change_type, $context['results']['all_configs']);
      $context['sandbox']['current_index']++;
    }
  }
  catch (ConfigValidateException $e) {
    $context['results']['errors'][] = $e->getMessage();
    $context['finished'] = 1;
    return;
  }

  $context['finished'] = $context['sandbox']['total_size'] ? $context['sandbox']['current_index'] / $context['sandbox']['total_size'] : 1;
}