function NodeBulkUpdate::batchFinished

Reports the 'finished' status of batch operation the node bulk update.

Parameters

bool $success: A boolean indicating whether the batch mass update operation successfully concluded.

string[] $results: An array of rendered links to nodes updated via the batch mode process.

See also

self::batchProcess()

File

core/modules/node/src/NodeBulkUpdate.php, line 165

Class

NodeBulkUpdate
Provides a service to update nodes in bulk.

Namespace

Drupal\node

Code

public static function batchFinished(bool $success, array $results) : void {
  $messenger = \Drupal::messenger();
  if ($success) {
    $messenger->addStatus(t('The update has been performed.'));
  }
  else {
    $messenger->addError(t('An error occurred and processing did not complete.'));
    $message = \Drupal::translation()->formatPlural(count($results), '1 item successfully processed:', '@count items successfully processed:');
    $item_list = [
      '#theme' => 'item_list',
      '#items' => $results,
    ];
    $message .= \Drupal::service('renderer')->render($item_list);
    $messenger->addStatus($message);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.