function MigrateUpgradeImportBatch::finished

Same name in other branches
  1. 9 core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php \Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch::finished()
  2. 8.9.x core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php \Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch::finished()
  3. 11.x core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php \Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch::finished()

Callback executed when the Migrate Upgrade Import batch process completes.

Parameters

bool $success: TRUE if batch successfully completed.

array $results: Batch results.

array $operations: An array of methods run in the batch.

string $elapsed: The time to run the batch.

File

core/modules/migrate_drupal_ui/src/Batch/MigrateUpgradeImportBatch.php, line 261

Class

MigrateUpgradeImportBatch
Runs a single migration batch.

Namespace

Drupal\migrate_drupal_ui\Batch

Code

public static function finished($success, $results, $operations, $elapsed) {
    $successes = $results['successes'];
    $failures = $results['failures'];
    // If we had any successes log that for the user.
    if ($successes > 0) {
        \Drupal::messenger()->addStatus(\Drupal::translation()->formatPlural($successes, 'Completed 1 upgrade task successfully', 'Completed @count upgrade tasks successfully'));
    }
    // If we had failures, log them and show the migration failed.
    if ($failures > 0) {
        \Drupal::messenger()->addError(\Drupal::translation()->formatPlural($failures, '1 upgrade failed', '@count upgrades failed'));
        \Drupal::messenger()->addError(t('Upgrade process not completed'));
    }
    else {
        // Everything went off without a hitch. We may not have had successes
        // but we didn't have failures so this is fine.
        \Drupal::messenger()->addStatus(t('Congratulations, you upgraded Drupal!'));
    }
    if (\Drupal::moduleHandler()->moduleExists('dblog')) {
        $url = Url::fromRoute('migrate_drupal_ui.log');
        \Drupal::messenger()->addMessage(Link::fromTextAndUrl(new TranslatableMarkup('Review the detailed upgrade log'), $url), $failures ? 'error' : 'status');
    }
}

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