diff -u b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php --- b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php +++ b/core/modules/migrate_drupal_ui/src/Form/MigrateUpgradeForm.php @@ -11,7 +11,7 @@ use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drupal\migrate_drupal_ui\Batch\MigrateUpgradeImportBatch; use Drupal\migrate_drupal\MigrationConfigurationTrait; -use Drupal\migrate_drupal_ui\MigrateProviders; +use Drupal\migrate_drupal_ui\MigrationProviders; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -50,6 +50,13 @@ protected $pluginManager; /** + * The migration provider service. + * + * @var \Drupal\migrate_drupal_ui\MigrationProviders + */ + protected $migrationProviders; + + /** * Constructs the MigrateUpgradeForm. * * @param \Drupal\Core\State\StateInterface $state @@ -60,12 +67,15 @@ * The renderer service. * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $plugin_manager * The migration plugin manager. + * @param \Drupal\migrate_drupal_ui\MigrationProviders $migration_providers + * The migration provider service. */ - public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager) { + public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, RendererInterface $renderer, MigrationPluginManagerInterface $plugin_manager, MigrationProviders $migration_providers) { $this->state = $state; $this->dateFormatter = $date_formatter; $this->renderer = $renderer; $this->pluginManager = $plugin_manager; + $this->migrationProviders = $migration_providers; } /** @@ -76,7 +86,8 @@ $container->get('state'), $container->get('date.formatter'), $container->get('renderer'), - $container->get('plugin.manager.migration') + $container->get('plugin.manager.migration'), + $container->get('migrate_drupal_ui.providers') ); } @@ -398,9 +409,8 @@ $migrations = $this->getMigrations('migrate_drupal_' . $version, $version); $table_data = []; - $migrateProviders = new MigrateProviders(); foreach ($migrations as $migration) { - $providers = $migrateProviders->getProviders($migration); + $providers = $this->migrationProviders->getProviders($migration); list($source_module, $destination_module) = $providers; $migration_id = $migration->getPluginId(); if (!$source_module) { reverted: --- b/core/modules/migrate_drupal_ui/src/MigrateProviders.php +++ /dev/null @@ -1,51 +0,0 @@ -getSourceConfiguration(); - $source_module = (!empty($source_configuration['provider'])) ? $source_configuration['provider'] : NULL; - if (!$source_module) { - // Get the source_provider from the plugin definition. - $plugin_definition = $migration->getSourcePlugin()->getPluginDefinition(); - $source_module = (!empty($plugin_definition['source_provider'])) ? $plugin_definition['source_provider'] : NULL; - } - - // Determine the destination provider, looking in configuration first. - $destination_configuration = $migration->getDestinationConfiguration(); - $destination_module = (!empty($destination_configuration['provider'])) ? $destination_configuration['provider'] : NULL; - if (!$destination_module) { - $destination_plugin = $migration->getDestinationPlugin(); - if ($destination_plugin->getPluginId() == 'config') { - // For configuration destinations pull out the module name from the - // configuration destination string. - $configuration_destination = (!empty($destination_configuration['config_name'])) ? $destination_configuration['config_name'] : NULL; - if ($configuration_destination) { - $destination_module = explode('.', $configuration_destination, 2)[0]; - } - } - else { - // If not a config destination, the destination module is simply - // the provider of the plugin. - $destination_module = $destination_plugin->getPluginDefinition()['provider']; - } - } - return ([$source_module, $destination_module]); - } -} diff -u b/core/modules/migrate_drupal_ui/tests/src/Kernel/ProvidersExistTest.php b/core/modules/migrate_drupal_ui/tests/src/Kernel/ProvidersExistTest.php --- b/core/modules/migrate_drupal_ui/tests/src/Kernel/ProvidersExistTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Kernel/ProvidersExistTest.php @@ -4,11 +4,11 @@ Use Drupal\Component\Render\FormattableMarkup; use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase; -use Drupal\migrate_drupal_ui\MigrateProviders; + /** * Tests that providers exist for all source and destination plugins. * - * @group migrate_drupal + * @group migrate_drupal_ui */ class ProvidersExistTest extends MigrateDrupalTestBase { @@ -97,14 +97,13 @@ */ public function testProvidersExist() { /** @var \Drupal\migrate\Plugin\MigrationPluginManager $manager */ - $pluginManager = \Drupal::service('plugin.manager.migration'); - $migrateProviders = new MigrateProviders(); - + $pluginManager = $this->container->get('plugin.manager.migration'); + $migrationProviders = $this->container->get('migrate_drupal_ui.providers'); // Get all the migrations $migrations = $pluginManager->createInstances(array_keys($pluginManager->getDefinitions())); /** @var \Drupal\migrate\Plugin\Migration $migration */ foreach ($migrations as $migration) { - $providers = $migrateProviders->getProviders($migration); + $providers = $migrationProviders->getProviders($migration); list($source_module, $destination_module) = $providers; $migration_id = $migration->getPluginId(); if ($migration_id == 'provider_test') { only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate_drupal_ui/migrate_drupal_ui.services.yml @@ -0,0 +1,5 @@ +services: + migrate_drupal_ui.providers: + class: Drupal\migrate_drupal_ui\MigrationProviders + arguments: + - migration only in patch2: unchanged: --- /dev/null +++ b/core/modules/migrate_drupal_ui/src/MigrationProviders.php @@ -0,0 +1,51 @@ +getSourceConfiguration(); + $source_module = (!empty($source_configuration['provider'])) ? $source_configuration['provider'] : NULL; + if (!$source_module) { + // Get the source_provider from the plugin definition. + $plugin_definition = $migration->getSourcePlugin()->getPluginDefinition(); + $source_module = (!empty($plugin_definition['source_provider'])) ? $plugin_definition['source_provider'] : NULL; + } + + // Determine the destination provider, looking in configuration first. + $destination_configuration = $migration->getDestinationConfiguration(); + $destination_module = (!empty($destination_configuration['provider'])) ? $destination_configuration['provider'] : NULL; + if (!$destination_module) { + $destination_plugin = $migration->getDestinationPlugin(); + if ($destination_plugin->getPluginId() == 'config') { + // For configuration destinations pull out the module name from the + // configuration destination string. + $configuration_destination = (!empty($destination_configuration['config_name'])) ? $destination_configuration['config_name'] : NULL; + if ($configuration_destination) { + $destination_module = explode('.', $configuration_destination, 2)[0]; + } + } + else { + // If not a config destination, the destination module is simply + // the provider of the plugin. + $destination_module = $destination_plugin->getPluginDefinition()['provider']; + } + } + return ([$source_module, $destination_module]); + } +}