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

Batch API callback. Validate the changes before attempting to sync. Reports all discovered issues in a message.

File

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

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']);
  foreach ($config_files as $config_file => $config_change_type) {
    try {
      config_sync_validate_file($config_file, $config_change_type, $context['results']['all_configs']);
    }
    catch (ConfigValidateException $e) {
      $context['results']['errors'][] = $e->getMessage();
    }
    $context['sandbox']['current_index']++;
  }

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