You are here

public static function ContentSync::finishBatch in Content Synchronization 8

Finish batch.

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

File

src/Form/ContentSync.php, line 376

Class

ContentSync
Construct the storage changes in a content synchronization form.

Namespace

Drupal\content_sync\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', [
      '%error_operation' => $error_operation[0],
      '@arguments' => print_r($error_operation[1], TRUE),
    ]);
    drupal_set_message($message, 'error');
  }
}