You are here

public function BatchGenerator::batchFinished in User Merge 2.x

Batch callback called when the batch finishes.

Parameters

bool $success: TRUE if batch successfully completed.

array $results: Batch results.

array $operations: An array of methods run in the batch.

File

src/BatchGenerator.php, line 200

Class

BatchGenerator
Class BatchGenerator.

Namespace

Drupal\usermerge

Code

public function batchFinished($success, array $results, array $operations) {
  if (isset($results['error'])) {
    $this->messenger
      ->addError($results['error']);
    return;
  }
  if ($success) {
    $this->messenger
      ->addMessage($this
      ->t('Operations completed.'));
  }
  else {

    // An error occurred.
    // $operations contains the operations that remained unprocessed.
    $error_operation = reset($operations);
    $this->messenger
      ->addError($this
      ->t('An error occurred while processing @operation with arguments: @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    ]));
  }
}