You are here

protected static function MigrateUpgradeRunBatch::displayResults in Migrate Upgrade 8

Displays counts of success/failures on the migration upgrade complete page.

Parameters

array $results: An array of result data built during the batch.

1 call to MigrateUpgradeRunBatch::displayResults()
MigrateUpgradeRunBatch::finished in src/MigrateUpgradeRunBatch.php
Implements the Batch API finished method.

File

src/MigrateUpgradeRunBatch.php, line 263
Contains \Drupal\migrate_upgrade\MigrateUpgradeRunBatch.

Class

MigrateUpgradeRunBatch
Runs a single migration batch.

Namespace

Drupal\migrate_upgrade

Code

protected static function displayResults($results) {
  $successes = $results['successes'];
  $failures = $results['failures'];

  // If we had any successes lot that for the user.
  if ($successes > 0) {
    if ($results['operation'] == 'import') {
      drupal_set_message(static::getTranslation()
        ->formatPlural($successes, 'Completed 1 upgrade task successfully', 'Completed @count upgrade tasks successfully'));
    }
    else {
      drupal_set_message(static::getTranslation()
        ->formatPlural($successes, 'Completed 1 rollback task successfully', 'Completed @count rollback tasks successfully'));
    }
  }

  // If we had failures, log them and show the migration failed.
  if ($failures > 0) {
    if ($results['operation'] == 'import') {
      drupal_set_message(static::getTranslation()
        ->formatPlural($failures, '1 upgrade failed', '@count upgrades failed'));
      drupal_set_message(t('Upgrade process not completed'), 'error');
    }
    else {
      drupal_set_message(static::getTranslation()
        ->formatPlural($failures, '1 rollback failed', '@count rollbacks failed'));
      drupal_set_message(t('Rollback process not completed'), 'error');
    }
  }
  else {
    if ($results['operation'] == 'import') {

      // Everything went off without a hitch. We may not have had successes
      // but we didn't have failures so this is fine.
      drupal_set_message(t('Congratulations, you upgraded Drupal!'));
    }
    else {
      drupal_set_message(t('Rollback of the upgrade is complete - you may now start the upgrade process from scratch.'));
    }
  }
  if (\Drupal::moduleHandler()
    ->moduleExists('dblog')) {
    $url = Url::fromRoute('migrate_upgrade.log');
    drupal_set_message(Link::fromTextAndUrl(t('Review the detailed upgrade log'), $url), $failures ? 'error' : 'status');
  }
}