You are here

public function ContentHubExportQueue::batchFinished in Acquia Content Hub 8.2

Batch finished callback.

Parameters

bool $success: Whether the batch process succeeded or not.

array $results: The results array.

array $operations: An array of operations.

File

modules/acquia_contenthub_publisher/src/ContentHubExportQueue.php, line 158

Class

ContentHubExportQueue
Implements an Export Queue for Content Hub.

Namespace

Drupal\acquia_contenthub_publisher

Code

public function batchFinished($success, array $results, array $operations) {
  if ($success) {
    $this->messenger
      ->addMessage(t("The contents are successfully exported."));
  }
  else {
    $error_operation = reset($operations);
    $this->messenger
      ->addMessage(t('An error occurred while processing @operation with arguments : @args', [
      '@operation' => $error_operation[0],
      '@args' => print_r($error_operation[0], TRUE),
    ]));
  }

  // Providing a report on the items processed by the queue.
  $elements = [
    '#theme' => 'item_list',
    '#type' => 'ul',
    '#items' => $results,
  ];
  $queue_report = \Drupal::service('renderer')
    ->render($elements);
  $this->messenger
    ->addMessage($queue_report);
}