You are here

public static function ConfigSync::finishBatch in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Form/ConfigSync.php \Drupal\config\Form\ConfigSync::finishBatch()

Finish batch.

This function is a static function to avoid serializing the ConfigSync object unnecessarily.

File

core/modules/config/src/Form/ConfigSync.php, line 397
Contains \Drupal\config\Form\ConfigSync.

Class

ConfigSync
Construct the storage changes in a configuration synchronization form.

Namespace

Drupal\config\Form

Code

public static function finishBatch($success, $results, $operations) {
  if ($success) {
    if (!empty($results['errors'])) {
      foreach ($results['errors'] as $error) {
        drupal_set_message($error, 'error');
        \Drupal::logger('config_sync')
          ->error($error);
      }
      drupal_set_message(\Drupal::translation()
        ->translate('The configuration was imported with errors.'), 'warning');
    }
    else {
      drupal_set_message(\Drupal::translation()
        ->translate('The configuration was imported successfully.'));
    }
  }
  else {

    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    $message = \Drupal::translation()
      ->translate('An error occurred while processing %error_operation with arguments: @arguments', array(
      '%error_operation' => $error_operation[0],
      '@arguments' => print_r($error_operation[1], TRUE),
    ));
    drupal_set_message($message, 'error');
  }
}