You are here

public static function OrderReportGenerateForm::finishBatch in Commerce Reporting 8

Batch finished callback: display batch statistics.

Parameters

bool $success: Indicates whether the batch has completed successfully.

mixed[] $results: The array of results gathered by the batch processing.

string[] $operations: If $success is FALSE, contains the operations that remained unprocessed.

File

src/Form/OrderReportGenerateForm.php, line 183

Class

OrderReportGenerateForm
Profides a form for bulk generating order reports.

Namespace

Drupal\commerce_reports\Form

Code

public static function finishBatch($success, array $results, array $operations) {
  if ($success) {
    \Drupal::messenger()
      ->addMessage(\Drupal::translation()
      ->formatPlural($results['total_generated'], 'Generated reports for 1 order.', 'Generated reports for @count orders.'));
  }
  else {
    $error_operation = reset($operations);
    \Drupal::messenger()
      ->addError(t('An error occurred while processing @operation with arguments: @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    ]));
  }
}