You are here

function update_manager_download_batch_finished in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/update/update.manager.inc \update_manager_download_batch_finished()
  2. 7 modules/update/update.manager.inc \update_manager_download_batch_finished()

Batch callback: Performs actions when the download batch is completed.

Parameters

$success: TRUE if the batch operation was successful, FALSE if there were errors.

$results: An associative array of results from the batch operation.

1 string reference to 'update_manager_download_batch_finished'
UpdateManagerUpdate::submitForm in core/modules/update/src/Form/UpdateManagerUpdate.php
Form submission handler.

File

core/modules/update/update.manager.inc, line 52
Administrative screens and processing functions of the Update Manager module.

Code

function update_manager_download_batch_finished($success, $results) {
  if (!empty($results['errors'])) {
    $item_list = [
      '#theme' => 'item_list',
      '#title' => t('Downloading updates failed:'),
      '#items' => $results['errors'],
    ];
    \Drupal::messenger()
      ->addError(\Drupal::service('renderer')
      ->render($item_list));
  }
  elseif ($success) {
    \Drupal::messenger()
      ->addStatus(t('Updates downloaded successfully.'));
    \Drupal::request()
      ->getSession()
      ->set('update_manager_update_projects', $results['projects']);
    return new RedirectResponse(Url::fromRoute('update.confirmation_page', [], [
      'absolute' => TRUE,
    ])
      ->toString());
  }
  else {

    // Ideally we're catching all Exceptions, so they should never see this,
    // but just in case, we have to tell them something.
    \Drupal::messenger()
      ->addError(t('Fatal error trying to download.'));
  }
}