You are here

public static function ContentHubExportQueueController::batchFinished in Acquia Content Hub 8

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

src/Controller/ContentHubExportQueueController.php, line 306

Class

ContentHubExportQueueController
Implements an Export Queue Controller for Content Hub.

Namespace

Drupal\acquia_contenthub\Controller

Code

public static function batchFinished($success, array $results, array $operations) {
  if ($success) {
    \Drupal::messenger()
      ->addStatus(t("The contents are successfully exported."));
  }
  else {
    $error_operation = reset($operations);
    \Drupal::messenger()
      ->addStatus(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);
  \Drupal::messenger()
    ->addStatus($queue_report);
}