Problem/Motivation

From #2281691: User interface for migration-based upgrades.

  1. +++ b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
    @@ -0,0 +1,369 @@
    +    return \Drupal::logger('migrate_drupal_ui');
    

    Could be injected?

  2. +++ b/core/modules/migrate_drupal_ui/src/MigrateUpgradeRunBatch.php
    @@ -0,0 +1,369 @@
    +  /**
    +   * Wraps the translation manager.
    +   *
    +   * @return \Drupal\Core\StringTranslation\TranslationManager
    +   *   The string translation manager.
    +   */
    +  protected static function getTranslation() {
    +    return \Drupal::translation();
    +  }
    

    Why isn't this just injected instead?

Proposed resolution

Inject the dependencies if possible.

Remaining tasks

TBD

User interface changes

N/A

API changes

Might remove redundant getTranslation() method.

Data model changes

N/A

Comments

xjm created an issue. See original summary.

tim.plunkett’s picture

Injecting the dependencies won't help if the whole thing is static.
Though why is the whole thing static? If it used ContainerInjectionInterface, we could just instantiate it.

alexpott’s picture

It's static because it is used as batch callbacks...

      $batch = [
        'title' => $this->t('Rolling back upgrade'),
        'progress_message' => '',
        'operations' => [
          [
            [MigrateUpgradeRunBatch::class, 'run'],
            [array_keys($migrations), 'rollback'],
          ],
        ],
        'finished' => [
          MigrateUpgradeRunBatch::class,
          'finished',
        ],
      ];
      batch_set($batch);

There's not a lot we can do here without completely changing the batch system imo.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mikeryan’s picture

Status: Active » Closed (works as designed)

Per @alexpott's comment, closing.