Commit 2c35bee1 authored by catch's avatar catch

Issue #2666650 by alexpott, benjy: Inject migration and source plugin managers...

Issue #2666650 by alexpott, benjy: Inject migration and source plugin managers into the migration plugins
parent 8a8fc5b5
...@@ -7,11 +7,13 @@ ...@@ -7,11 +7,13 @@
namespace Drupal\migrate\Plugin; namespace Drupal\migrate\Plugin;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Plugin\PluginBase; use Drupal\Core\Plugin\PluginBase;
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateException; use Drupal\migrate\MigrateException;
use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\MigrateSkipRowException;
use Drupal\Component\Utility\NestedArray; use Drupal\Component\Utility\NestedArray;
use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Defines the Migration plugin. * Defines the Migration plugin.
...@@ -20,7 +22,7 @@ ...@@ -20,7 +22,7 @@
* container for the information about a single migration such as the source, * container for the information about a single migration such as the source,
* process and destination plugins. * process and destination plugins.
*/ */
class Migration extends PluginBase implements MigrationInterface, RequirementsInterface { class Migration extends PluginBase implements MigrationInterface, RequirementsInterface, ContainerFactoryPluginInterface {
/** /**
* The migration ID (machine name). * The migration ID (machine name).
...@@ -217,6 +219,33 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn ...@@ -217,6 +219,33 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
*/ */
protected $migrationPluginManager; protected $migrationPluginManager;
/**
* The source plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $sourcePluginManager;
/**
* Thep process plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $processPluginManager;
/**
* The destination plugin manager.
*
* @var \Drupal\migrate\Plugin\MigrateDestinationPluginManager
*/
protected $destinationPluginManager;
/**
* The ID map plugin manager.
*
* @var \Drupal\migrate\Plugin\MigratePluginManager
*/
protected $idMapPluginManager;
/** /**
* Labels corresponding to each defined status. * Labels corresponding to each defined status.
...@@ -232,15 +261,54 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn ...@@ -232,15 +261,54 @@ class Migration extends PluginBase implements MigrationInterface, RequirementsIn
]; ];
/** /**
* {@inheritdoc} * Constructs a Migration.
*/ *
public function __construct(array $configuration, $plugin_id, $plugin_definition) { * @param array $configuration
* Plugin configuration.
* @param string $plugin_id
* The plugin ID.
* @param mixed $plugin_definition
* The plugin definition.
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
* The migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
* The source migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
* The process migration plugin manager.
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
* The destination migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
* The ID map migration plugin manager.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->migrationPluginManager = $migration_plugin_manager;
$this->sourcePluginManager = $source_plugin_manager;
$this->processPluginManager = $process_plugin_manager;
$this->destinationPluginManager = $destination_plugin_manager;
$this->idMapPluginManager = $idmap_plugin_manager;
foreach ($plugin_definition as $key => $value) { foreach ($plugin_definition as $key => $value) {
$this->$key = $value; $this->$key = $value;
} }
} }
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('plugin.manager.migration'),
$container->get('plugin.manager.migrate.source'),
$container->get('plugin.manager.migrate.process'),
$container->get('plugin.manager.migrate.destination'),
$container->get('plugin.manager.migrate.id_map')
);
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
...@@ -283,7 +351,7 @@ public function getIdMapPlugin() { ...@@ -283,7 +351,7 @@ public function getIdMapPlugin() {
*/ */
public function getSourcePlugin() { public function getSourcePlugin() {
if (!isset($this->sourcePlugin)) { if (!isset($this->sourcePlugin)) {
$this->sourcePlugin = \Drupal::service('plugin.manager.migrate.source')->createInstance($this->source['plugin'], $this->source, $this); $this->sourcePlugin = $this->sourcePluginManager->createInstance($this->source['plugin'], $this->source, $this);
} }
return $this->sourcePlugin; return $this->sourcePlugin;
} }
...@@ -302,11 +370,11 @@ public function getProcessPlugins(array $process = NULL) { ...@@ -302,11 +370,11 @@ public function getProcessPlugins(array $process = NULL) {
$this->processPlugins[$index][$property] = array(); $this->processPlugins[$index][$property] = array();
foreach ($configurations as $configuration) { foreach ($configurations as $configuration) {
if (isset($configuration['source'])) { if (isset($configuration['source'])) {
$this->processPlugins[$index][$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance('get', $configuration, $this); $this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance('get', $configuration, $this);
} }
// Get is already handled. // Get is already handled.
if ($configuration['plugin'] != 'get') { if ($configuration['plugin'] != 'get') {
$this->processPlugins[$index][$property][] = \Drupal::service('plugin.manager.migrate.process')->createInstance($configuration['plugin'], $configuration, $this); $this->processPlugins[$index][$property][] = $this->processPluginManager->createInstance($configuration['plugin'], $configuration, $this);
} }
if (!$this->processPlugins[$index][$property]) { if (!$this->processPlugins[$index][$property]) {
throw new MigrateException("Invalid process configuration for $property"); throw new MigrateException("Invalid process configuration for $property");
...@@ -351,7 +419,7 @@ public function getDestinationPlugin($stub_being_requested = FALSE) { ...@@ -351,7 +419,7 @@ public function getDestinationPlugin($stub_being_requested = FALSE) {
throw new MigrateSkipRowException; throw new MigrateSkipRowException;
} }
if (!isset($this->destinationPlugin)) { if (!isset($this->destinationPlugin)) {
$this->destinationPlugin = \Drupal::service('plugin.manager.migrate.destination')->createInstance($this->destination['plugin'], $this->destination, $this); $this->destinationPlugin = $this->destinationPluginManager->createInstance($this->destination['plugin'], $this->destination, $this);
} }
return $this->destinationPlugin; return $this->destinationPlugin;
} }
...@@ -363,7 +431,7 @@ public function getIdMap() { ...@@ -363,7 +431,7 @@ public function getIdMap() {
if (!isset($this->idMapPlugin)) { if (!isset($this->idMapPlugin)) {
$configuration = $this->idMap; $configuration = $this->idMap;
$plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql'; $plugin = isset($configuration['plugin']) ? $configuration['plugin'] : 'sql';
$this->idMapPlugin = \Drupal::service('plugin.manager.migrate.id_map')->createInstance($plugin, $configuration, $this); $this->idMapPlugin = $this->idMapPluginManager->createInstance($plugin, $configuration, $this);
} }
return $this->idMapPlugin; return $this->idMapPlugin;
} }
...@@ -434,9 +502,6 @@ public function checkRequirements() { ...@@ -434,9 +502,6 @@ public function checkRequirements() {
* The plugin manager. * The plugin manager.
*/ */
protected function getMigrationPluginManager() { protected function getMigrationPluginManager() {
if (!isset($this->migrationPluginManager)) {
$this->migrationPluginManager = \Drupal::service('plugin.manager.migration');
}
return $this->migrationPluginManager; return $this->migrationPluginManager;
} }
......
...@@ -31,7 +31,7 @@ public static function getSourcePlugin($source_plugin_id) { ...@@ -31,7 +31,7 @@ public static function getSourcePlugin($source_plugin_id) {
'plugin' => 'null', 'plugin' => 'null',
], ],
]; ];
return (new Migration([], uniqid(), $definition))->getSourcePlugin(); return \Drupal::service('plugin.manager.migration')->createStubMigration($definition)->getSourcePlugin();
} }
} }
...@@ -223,4 +223,12 @@ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids) ...@@ -223,4 +223,12 @@ protected function addDependency(array &$graph, $id, $dependency, $dynamic_ids)
$graph[$id]['edges'] += array_combine($dependencies, $dependencies); $graph[$id]['edges'] += array_combine($dependencies, $dependencies);
} }
/**
* {@inheritdoc}
*/
public function createStubMigration(array $definition) {
$id = isset($definition['id']) ? $definition['id'] : uniqid();
return Migration::create(\Drupal::getContainer(), [], $id, $definition);
}
} }
...@@ -33,4 +33,16 @@ interface MigrationPluginManagerInterface extends PluginManagerInterface { ...@@ -33,4 +33,16 @@ interface MigrationPluginManagerInterface extends PluginManagerInterface {
*/ */
public function createInstances($id, array $configuration = array()); public function createInstances($id, array $configuration = array());
/**
* Creates a stub migration plugin from a definition array.
*
* @param array $definition
* The migration definition. If an 'id' key is set then this will be used as
* the migration ID, if not a random ID will be assigned.
*
* @return \Drupal\migrate\Plugin\Migration
* The stub migration.
*/
public function createStubMigration(array $definition);
} }
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\migrate\Plugin\Migration;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
/** /**
...@@ -44,7 +43,7 @@ public function testEmbeddedData() { ...@@ -44,7 +43,7 @@ public function testEmbeddedData() {
'destination' => ['plugin' => 'null'], 'destination' => ['plugin' => 'null'],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$source = $migration->getSourcePlugin(); $source = $migration->getSourcePlugin();
// Validate the plugin returns the source data that was provided. // Validate the plugin returns the source data that was provided.
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
use Drupal\migrate\MigrateMessage; use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Event\MigrateEvents; use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\MigrateExecutable; use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\Migration;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
/** /**
...@@ -80,7 +79,7 @@ public function testMigrateEvents() { ...@@ -80,7 +79,7 @@ public function testMigrateEvents() {
'destination' => ['plugin' => 'dummy'], 'destination' => ['plugin' => 'dummy'],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage()); $executable = new MigrateExecutable($migration, new MigrateMessage());
// As the import runs, events will be dispatched, recording the received // As the import runs, events will be dispatched, recording the received
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Event\MigratePostRowSaveEvent; use Drupal\migrate\Event\MigratePostRowSaveEvent;
use Drupal\migrate\MigrateMessage; use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
...@@ -60,7 +59,7 @@ public function testMigrateEvents() { ...@@ -60,7 +59,7 @@ public function testMigrateEvents() {
'destination' => ['plugin' => 'dummy'], 'destination' => ['plugin' => 'dummy'],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage()); $executable = new MigrateExecutable($migration, new MigrateMessage());
// When the import runs, the first row imported will trigger an // When the import runs, the first row imported will trigger an
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\Event\MigrateEvents; use Drupal\migrate\Event\MigrateEvents;
use Drupal\migrate\Event\MigrateIdMapMessageEvent; use Drupal\migrate\Event\MigrateIdMapMessageEvent;
...@@ -76,7 +75,7 @@ protected function setUp() { ...@@ -76,7 +75,7 @@ protected function setUp() {
], ],
]; ];
$this->migration = new Migration([], uniqid(), $definition); $this->migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
} }
/** /**
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\MigrateExecutable; use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Row; use Drupal\migrate\Row;
...@@ -66,7 +65,7 @@ public function testRollback() { ...@@ -66,7 +65,7 @@ public function testRollback() {
'destination' => ['plugin' => 'entity:taxonomy_vocabulary'], 'destination' => ['plugin' => 'entity:taxonomy_vocabulary'],
]; ];
$vocabulary_migration = new Migration([], uniqid(), $definition); $vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$vocabulary_id_map = $vocabulary_migration->getIdMap(); $vocabulary_id_map = $vocabulary_migration->getIdMap();
$this->assertTrue($vocabulary_migration->getDestinationPlugin()->supportsRollback()); $this->assertTrue($vocabulary_migration->getDestinationPlugin()->supportsRollback());
...@@ -107,7 +106,7 @@ public function testRollback() { ...@@ -107,7 +106,7 @@ public function testRollback() {
'migration_dependencies' => ['required' => ['vocabularies']], 'migration_dependencies' => ['required' => ['vocabularies']],
]; ];
$term_migration = new Migration([], uniqid(), $definition); $term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$term_id_map = $term_migration->getIdMap(); $term_id_map = $term_migration->getIdMap();
$this->assertTrue($term_migration->getDestinationPlugin()->supportsRollback()); $this->assertTrue($term_migration->getDestinationPlugin()->supportsRollback());
...@@ -180,7 +179,7 @@ public function testRollback() { ...@@ -180,7 +179,7 @@ public function testRollback() {
'migration_dependencies' => ['required' => ['vocabularies']], 'migration_dependencies' => ['required' => ['vocabularies']],
]; ];
$settings_migration = new Migration([], uniqid(), $definition); $settings_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$this->assertFalse($settings_migration->getDestinationPlugin()->supportsRollback()); $this->assertFalse($settings_migration->getDestinationPlugin()->supportsRollback());
} }
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutable; use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\Plugin\MigrateIdMapInterface; use Drupal\migrate\Plugin\MigrateIdMapInterface;
use Drupal\migrate\Plugin\Migration;
/** /**
* Tests row skips triggered during hook_migrate_prepare_row(). * Tests row skips triggered during hook_migrate_prepare_row().
...@@ -54,7 +53,7 @@ public function testPrepareRowSkip() { ...@@ -54,7 +53,7 @@ public function testPrepareRowSkip() {
'load' => ['plugin' => 'null'], 'load' => ['plugin' => 'null'],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$executable = new MigrateExecutable($migration, new MigrateMessage()); $executable = new MigrateExecutable($migration, new MigrateMessage());
$result = $executable->import(); $result = $executable->import();
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
/** /**
...@@ -32,7 +31,7 @@ public function testStatus() { ...@@ -32,7 +31,7 @@ public function testStatus() {
], ],
'process' => ['foo' => 'bar'], 'process' => ['foo' => 'bar'],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
// Default status is idle. // Default status is idle.
$status = $migration->getStatus(); $status = $migration->getStatus();
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
namespace Drupal\Tests\migrate\Kernel; namespace Drupal\Tests\migrate\Kernel;
use Drupal\KernelTests\KernelTestBase; use Drupal\KernelTests\KernelTestBase;
use Drupal\migrate\Plugin\Migration;
/** /**
* Tests the migration plugin. * Tests the migration plugin.
...@@ -32,7 +31,7 @@ class MigrationTest extends KernelTestBase { ...@@ -32,7 +31,7 @@ class MigrationTest extends KernelTestBase {
* @covers ::set * @covers ::set
*/ */
public function testSetInvalidation() { public function testSetInvalidation() {
$migration = new Migration([], uniqid(), [ $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([
'source' => ['plugin' => 'empty'], 'source' => ['plugin' => 'empty'],
'destination' => ['plugin' => 'entity:entity_view_mode'], 'destination' => ['plugin' => 'entity:entity_view_mode'],
]); ]);
......
...@@ -2,21 +2,25 @@ ...@@ -2,21 +2,25 @@
/** /**
* @file * @file
* Contains \Drupal\Tests\migrate\Unit\Entity\MigrationTest. * Contains \Drupal\Tests\migrate\Kernel\Plugin\MigrationTest.
*/ */
namespace Drupal\Tests\migrate\Unit\Entity; namespace Drupal\Tests\migrate\Kernel\Plugin;
use Drupal\migrate\Plugin\Migration; use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\UnitTestCase;
/** /**
* Tests the migrate entity. * Tests the migration plugin.
* *
* @coversDefaultClass \Drupal\migrate\Plugin\Migration * @coversDefaultClass \Drupal\migrate\Plugin\Migration
* @group migrate * @group migrate
*/ */
class MigrationTest extends UnitTestCase { class MigrationTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate'];
/** /**
* Tests Migration::getProcessPlugins() * Tests Migration::getProcessPlugins()
...@@ -24,7 +28,7 @@ class MigrationTest extends UnitTestCase { ...@@ -24,7 +28,7 @@ class MigrationTest extends UnitTestCase {
* @covers ::getProcessPlugins * @covers ::getProcessPlugins
*/ */
public function testGetProcessPlugins() { public function testGetProcessPlugins() {
$migration = new Migration([], uniqid(), []); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration([]);
$this->assertEquals([], $migration->getProcessPlugins([])); $this->assertEquals([], $migration->getProcessPlugins([]));
} }
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\MigrateExecutable; use Drupal\migrate\MigrateExecutable;
use Drupal\migrate\MigrateMessage; use Drupal\migrate\MigrateMessage;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\RequirementsInterface; use Drupal\migrate\Plugin\RequirementsInterface;
/** /**
...@@ -43,7 +42,7 @@ function migrate_drupal_migration_plugins_alter(&$definitions) { ...@@ -43,7 +42,7 @@ function migrate_drupal_migration_plugins_alter(&$definitions) {
'plugin' => 'null', 'plugin' => 'null',
], ],
]; ];
$vocabulary_migration = new Migration([], uniqid(), $vocabulary_migration_definition); $vocabulary_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($vocabulary_migration_definition);
try { try {
$source_plugin = $vocabulary_migration->getSourcePlugin(); $source_plugin = $vocabulary_migration->getSourcePlugin();
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\MigrateDestinationPluginManager;
use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Plugin\MigratePluginManager;
use Drupal\migrate\Plugin\Migration; use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface; use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
...@@ -41,13 +42,6 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface ...@@ -41,13 +42,6 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
*/ */
protected $cckPluginCache; protected $cckPluginCache;
/**
* The migration plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $migrationPluginManager;
/** /**
* Constructs a CckMigration. * Constructs a CckMigration.
* *
...@@ -61,11 +55,18 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface ...@@ -61,11 +55,18 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface
* The cckfield plugin manager. * The cckfield plugin manager.
* @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager * @param \Drupal\migrate\Plugin\MigrationPluginManagerInterface $migration_plugin_manager
* The migration plugin manager. * The migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $source_plugin_manager
* The source migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $process_plugin_manager
* The process migration plugin manager.
* @param \Drupal\migrate\Plugin\MigrateDestinationPluginManager $destination_plugin_manager
* The destination migration plugin manager.
* @param \Drupal\migrate\Plugin\MigratePluginManager $idmap_plugin_manager
* The ID map migration plugin manager.
*/ */
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigratePluginManager $cck_manager, MigrationPluginManagerInterface $migration_plugin_manager) { public function __construct(array $configuration, $plugin_id, $plugin_definition, MigratePluginManager $cck_manager, MigrationPluginManagerInterface $migration_plugin_manager, MigratePluginManager $source_plugin_manager, MigratePluginManager $process_plugin_manager, MigrateDestinationPluginManager $destination_plugin_manager, MigratePluginManager $idmap_plugin_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition, $migration_plugin_manager, $source_plugin_manager, $process_plugin_manager, $destination_plugin_manager, $idmap_plugin_manager);
$this->cckPluginManager = $cck_manager; $this->cckPluginManager = $cck_manager;
$this->migrationPluginManager = $migration_plugin_manager;
} }
/** /**
...@@ -77,7 +78,11 @@ public static function create(ContainerInterface $container, array $configuratio ...@@ -77,7 +78,11 @@ public static function create(ContainerInterface $container, array $configuratio
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$container->get('plugin.manager.migrate.cckfield'), $container->get('plugin.manager.migrate.cckfield'),
$container->get('plugin.manager.migration') $container->get('plugin.manager.migration'),
$container->get('plugin.manager.migrate.source'),
$container->get('plugin.manager.migrate.process'),
$container->get('plugin.manager.migrate.destination'),
$container->get('plugin.manager.migrate.id_map')
); );
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
*/ */
namespace Drupal\migrate_drupal\Tests; namespace Drupal\migrate_drupal\Tests;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Row; use Drupal\migrate\Row;
/** /**
...@@ -51,7 +51,7 @@ protected function createStub($entity_type_id) { ...@@ -51,7 +51,7 @@ protected function createStub($entity_type_id) {
'process' => [], 'process' => [],
'destination' => ['plugin' => 'entity:' . $entity_type_id], 'destination' => ['plugin' => 'entity:' . $entity_type_id],
]; ];
$migration = new Migration([], uniqid(), $definition); $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
$destination_plugin = $migration->getDestinationPlugin(TRUE); $destination_plugin = $migration->getDestinationPlugin(TRUE);
$stub_row = new Row([], [], TRUE); $stub_row = new Row([], [], TRUE);
$destination_ids = $destination_plugin->import($stub_row); $destination_ids = $destination_plugin->import($stub_row);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\DatabaseExceptionWrapper;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface; use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\migrate\Exception\RequirementsException; use Drupal\migrate\Exception\RequirementsException;
use Drupal\migrate\Plugin\Migration;
use Drupal\migrate\Plugin\MigrationDeriverTrait; use Drupal\migrate\Plugin\MigrationDeriverTrait;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;