You are here

public static function ResaveBatch::batchFinished in Automatic Entity Label 8.3

{@inheritdoc }

File

src/Batch/ResaveBatch.php, line 50

Class

ResaveBatch
Processes entities in chunks to re-save their labels.

Namespace

Drupal\auto_entitylabel\Batch

Code

public static function batchFinished($success, array $results, array $operations) {
  $messenger = \Drupal::messenger();
  if ($success) {
    $messenger
      ->addMessage(t('Resaved @count labels.', [
      '@count' => count($results),
    ]));
  }
  else {

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