diff --git a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php index b14ca5506c..8dad5fb9b1 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -19,13 +20,27 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface { /** - * The migration process plugin, configured for lookups in d6_custom_block - * and d7_custom_block. + * The migration process plugin. + * + * The plugin is configured for lookups in d6_custom_block and + * d7_custom_block. * * @var \Drupal\migrate\Plugin\MigrateProcessInterface + * + * @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use + * migrateLookup instead. + * + * @see https://www.drupal.org/node/3047268 */ protected $migrationPlugin; + /** + * The migrate lookup service. + * + * @var \Drupal\migrate\MigrateLookupInterface + */ + protected $migrateLookup; + /** * The block_content entity storage handler. * @@ -34,12 +49,32 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI protected $blockContentStorage; /** - * {@inheritdoc} + * Constructs a BlockPluginId object. + * + * @param array $configuration + * The plugin configuration. + * @param string $plugin_id + * The plugin ID. + * @param mixed $plugin_definition + * The plugin definition. + * @param \Drupal\Core\Entity\EntityStorageInterface $storage + * The block content storage object. + * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup + * The migrate lookup service. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageInterface $storage, MigrateProcessInterface $migration_plugin) { + // @codingStandardsIgnoreLine + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageInterface $storage, $migrate_lookup) { parent::__construct($configuration, $plugin_id, $plugin_definition); + if ($migrate_lookup instanceof MigrateProcessInterface) { + @trigger_error('Passing a migration process plugin as the fifth argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268', E_USER_DEPRECATED); + $this->migrationPlugin = $migrate_lookup; + $migrate_lookup = \Drupal::service('migrate.lookup'); + } + elseif (!$migrate_lookup instanceof MigrateLookupInterface) { + throw new \InvalidArgumentException("The fifth argument to " . __METHOD__ . " must be an instance of MigrateLookupInterface."); + } $this->blockContentStorage = $storage; - $this->migrationPlugin = $migration_plugin; + $this->migrateLookup = $migrate_lookup; } /** @@ -47,18 +82,12 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { $entity_type_manager = $container->get('entity_type.manager'); - $migration_configuration = [ - 'migration' => [ - 'd6_custom_block', - 'd7_custom_block', - ], - ]; return new static( $configuration, $plugin_id, $plugin_definition, $entity_type_manager->getDefinition('block_content') ? $entity_type_manager->getStorage('block_content') : NULL, - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration) + $container->get('migrate.lookup') ); } @@ -69,25 +98,37 @@ public static function create(ContainerInterface $container, array $configuratio */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { if (is_array($value)) { - list($module, $delta) = $value; + [$module, $delta] = $value; switch ($module) { case 'aggregator': - list($type, $id) = explode('-', $delta); + [$type, $id] = explode('-', $delta); if ($type == 'feed') { return 'aggregator_feed_block'; } break; + case 'menu': return "system_menu_block:$delta"; + case 'block': if ($this->blockContentStorage) { - $block_id = $this->migrationPlugin - ->transform($delta, $migrate_executable, $row, $destination_property); - if ($block_id) { + if ($this->migrationPlugin) { + $block_id = $this->migrationPlugin + ->transform($delta, $migrate_executable, $row, $destination_property); + } + else { + $lookup_result = $this->migrateLookup->lookup(['d6_custom_block', 'd7_custom_block'], [$delta]); + if ($lookup_result) { + $block_id = $lookup_result[0]['id']; + } + } + + if (!empty($block_id)) { return 'block_content:' . $this->blockContentStorage->load($block_id)->uuid(); } } break; + default: break; } diff --git a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php index 271edd48c3..f4c299eca8 100644 --- a/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php +++ b/core/modules/block/src/Plugin/migrate/process/BlockVisibility.php @@ -4,6 +4,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipRowException; @@ -27,13 +28,27 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi protected $moduleHandler; /** - * The migration process plugin, configured for lookups in the d6_user_role - * and d7_user_role migrations. + * The migration process plugin. + * + * The plugin is configured for lookups in the d6_user_role and d7_user_role + * migrations. * * @var \Drupal\migrate\Plugin\MigrateProcessInterface + * + * @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use + * migrateLookup instead. + * + * @see https://www.drupal.org/node/3047268 */ protected $migrationPlugin; + /** + * The migrate lookup service. + * + * @var \Drupal\migrate\MigrateLookupInterface + */ + protected $migrateLookup; + /** * Whether or not to skip blocks that use PHP for visibility. Only applies * if the PHP module is not enabled. @@ -43,12 +58,32 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi protected $skipPHP = FALSE; /** - * {@inheritdoc} + * Constructs a BlockVisibility object. + * + * @param array $configuration + * The plugin configuration. + * @param string $plugin_id + * The plugin ID. + * @param mixed $plugin_definition + * The plugin definition. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler service. + * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup + * The migrate lookup service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, MigrateProcessInterface $migration_plugin) { + // @codingStandardsIgnoreLine + public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, $migrate_lookup) { parent::__construct($configuration, $plugin_id, $plugin_definition); + if ($migrate_lookup instanceof MigrateProcessInterface) { + @trigger_error('Passing a migration process plugin as the fifth argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268', E_USER_DEPRECATED); + $this->migrationPlugin = $migrate_lookup; + $migrate_lookup = \Drupal::service('migrate.lookup'); + } + elseif (!$migrate_lookup instanceof MigrateLookupInterface) { + throw new \InvalidArgumentException("The fifth argument to " . __METHOD__ . " must be an instance of MigrateLookupInterface."); + } $this->moduleHandler = $module_handler; - $this->migrationPlugin = $migration_plugin; + $this->migrateLookup = $migrate_lookup; if (isset($configuration['skip_php'])) { $this->skipPHP = $configuration['skip_php']; @@ -59,18 +94,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - $migration_configuration = [ - 'migration' => [ - 'd6_user_role', - 'd7_user_role', - ], - ]; return new static( $configuration, $plugin_id, $plugin_definition, $container->get('module_handler'), - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration) + $container->get('migrate.lookup') ); } @@ -78,7 +107,7 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($old_visibility, $pages, $roles) = $value; + [$old_visibility, $pages, $roles] = $value; $visibility = []; @@ -94,7 +123,16 @@ public function transform($value, MigrateExecutableInterface $migrate_executable ]; foreach ($roles as $key => $role_id) { - $roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property); + if ($this->migrationPlugin) { + $roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property); + } + else { + $lookup_result = $this->migrateLookup->lookup(['d6_user_role', 'd7_user_role'], [$role_id]); + if ($lookup_result) { + $roles[$key] = $lookup_result[0]['id']; + } + } + } $visibility['user_role']['roles'] = array_combine($roles, $roles); } diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php index 3f7eeca0c2..d3649b77a7 100644 --- a/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php @@ -4,8 +4,8 @@ use Drupal\block\Plugin\migrate\process\BlockVisibility; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\MigrateSkipRowException; -use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase; /** @@ -29,8 +29,8 @@ class BlockVisibilityTest extends MigrateProcessTestCase { protected function setUp() { parent::setUp(); $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class); - $migration_plugin = $this->prophesize(MigrateProcessInterface::class); - $this->plugin = new BlockVisibility([], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); + $migrate_lookup = $this->prophesize(MigrateLookupInterface::class); + $this->plugin = new BlockVisibility([], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migrate_lookup->reveal()); } /** @@ -86,7 +86,7 @@ public function testTransformPhpDisabled() { */ public function testTransformException() { $this->moduleHandler->moduleExists('php')->willReturn(FALSE); - $migration_plugin = $this->prophesize(MigrateProcessInterface::class); + $migrate_lookup = $this->prophesize(MigrateLookupInterface::class); $this->row = $this->getMockBuilder('Drupal\migrate\Row') ->disableOriginalConstructor() ->setMethods(['getSourceProperty']) @@ -94,7 +94,7 @@ public function testTransformException() { $this->row->expects($this->exactly(2)) ->method('getSourceProperty') ->willReturnMap([['bid', 99], ['module', 'foobar']]); - $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); + $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migrate_lookup->reveal()); $this->expectException(MigrateSkipRowException::class); $this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration."); $this->plugin->transform([2, 'migrateExecutable, $this->row, 'destinationproperty'); diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockPluginIdTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockPluginIdTest.php new file mode 100644 index 0000000000..d6d672822d --- /dev/null +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockPluginIdTest.php @@ -0,0 +1,50 @@ +prophesize(MigrateLookupInterface::class); + $container = new ContainerBuilder(); + $container->set('migrate.lookup', $migrate_lookup->reveal()); + \Drupal::setContainer($container); + } + + /** + * Tests legacy construction. + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockPluginId::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testConstruct() { + $process_plugin = $this->prophesize(MigrateProcessInterface::class); + $process_plugin->transform(1, $this->migrateExecutable, $this->row, 'destination_property')->willReturn(3); + $block = $this->prophesize(BlockContent::class); + $block->uuid()->willReturn('123456789'); + $storage = $this->prophesize(EntityStorageInterface::class); + $storage->load(3)->willReturn($block->reveal()); + $plugin = new BlockPluginId([], '', [], $storage->reveal(), $process_plugin->reveal()); + $this->assertSame('block_content:123456789', $plugin->transform(['block', 1], $this->migrateExecutable, $this->row, 'destination_property')); + } + +} diff --git a/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockVisibilityTest.php b/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockVisibilityTest.php new file mode 100644 index 0000000000..30c7f8b7d6 --- /dev/null +++ b/core/modules/block/tests/src/Unit/Plugin/migrate/process/LegacyBlockVisibilityTest.php @@ -0,0 +1,135 @@ +prophesize(MigrateLookupInterface::class); + $container = new ContainerBuilder(); + $container->set('migrate.lookup', $migrate_lookup->reveal()); + \Drupal::setContainer($container); + $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class); + $migration_plugin = $this->prophesize(MigrateProcessInterface::class); + $this->plugin = new BlockVisibility([], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); + } + + /** + * Tests Transform. + * + * @covers ::transform + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testTransformNoData() { + $transformed_value = $this->plugin->transform([0, '', []], $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertEmpty($transformed_value); + } + + /** + * Tests Transform. + * + * @covers ::transform + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testTransformSinglePageWithFront() { + $visibility = $this->plugin->transform([0, '', []], $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertSame('request_path', $visibility['request_path']['id']); + $this->assertTrue($visibility['request_path']['negate']); + $this->assertSame('', $visibility['request_path']['pages']); + } + + /** + * Tests Transform. + * + * @covers ::transform + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testTransformMultiplePagesWithFront() { + $visibility = $this->plugin->transform([1, "foo\n/bar\rbaz\r\n", []], $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertSame('request_path', $visibility['request_path']['id']); + $this->assertFalse($visibility['request_path']['negate']); + $this->assertSame("/foo\n/bar\n/baz\n", $visibility['request_path']['pages']); + } + + /** + * Tests Transform. + * + * @covers ::transform + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testTransformPhpEnabled() { + $this->moduleHandler->moduleExists('php')->willReturn(TRUE); + $visibility = $this->plugin->transform([2, 'migrateExecutable, $this->row, 'destinationproperty'); + $this->assertSame('php', $visibility['php']['id']); + $this->assertFalse($visibility['php']['negate']); + $this->assertSame('moduleHandler->moduleExists('php')->willReturn(FALSE); + $transformed_value = $this->plugin->transform([2, 'migrateExecutable, $this->row, 'destinationproperty'); + $this->assertEmpty($transformed_value); + } + + /** + * Tests Transform. + * + * @covers ::transform + * + * @expectedDeprecation Passing a migration process plugin as the fifth argument to Drupal\block\Plugin\migrate\process\BlockVisibility::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testTransformException() { + $this->moduleHandler->moduleExists('php')->willReturn(FALSE); + $migration_plugin = $this->prophesize(MigrateProcessInterface::class); + $this->row = $this->getMockBuilder('Drupal\migrate\Row') + ->disableOriginalConstructor() + ->setMethods(['getSourceProperty']) + ->getMock(); + $this->row->expects($this->exactly(2)) + ->method('getSourceProperty') + ->willReturnMap([['bid', 99], ['module', 'foobar']]); + $this->plugin = new BlockVisibility(['skip_php' => TRUE], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); + $this->expectException(MigrateSkipRowException::class); + $this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration."); + $this->plugin->transform([2, 'migrateExecutable, $this->row, 'destinationproperty'); + } + +} diff --git a/core/modules/content_translation/migrations/d6_taxonomy_term_localized_translation.yml b/core/modules/content_translation/migrations/d6_taxonomy_term_localized_translation.yml index 980baf4ae6..2521ee9a2a 100644 --- a/core/modules/content_translation/migrations/d6_taxonomy_term_localized_translation.yml +++ b/core/modules/content_translation/migrations/d6_taxonomy_term_localized_translation.yml @@ -13,7 +13,7 @@ process: tid: tid langcode: language vid: - plugin: migration + plugin: migration_lookup migration: d6_taxonomy_vocabulary source: vid name: diff --git a/core/modules/content_translation/migrations/d6_taxonomy_term_translation.yml b/core/modules/content_translation/migrations/d6_taxonomy_term_translation.yml index 96ccd8d569..37856b6f06 100644 --- a/core/modules/content_translation/migrations/d6_taxonomy_term_translation.yml +++ b/core/modules/content_translation/migrations/d6_taxonomy_term_translation.yml @@ -13,7 +13,7 @@ process: tid: tid langcode: language vid: - plugin: migration + plugin: migration_lookup migration: d6_taxonomy_vocabulary source: vid name: name @@ -26,7 +26,7 @@ process: method: process source: parent - - plugin: migration + plugin: migration_lookup migration: d6_taxonomy_term parent: plugin: default_value diff --git a/core/modules/content_translation/migrations/d7_taxonomy_term_localized_translation.yml b/core/modules/content_translation/migrations/d7_taxonomy_term_localized_translation.yml index d0b238567e..f0b790c9a8 100644 --- a/core/modules/content_translation/migrations/d7_taxonomy_term_localized_translation.yml +++ b/core/modules/content_translation/migrations/d7_taxonomy_term_localized_translation.yml @@ -14,7 +14,7 @@ process: # Use the language from the locales_target table. langcode: ltlanguage vid: - plugin: migration + plugin: migration_lookup migration: d7_taxonomy_vocabulary source: vid name: diff --git a/core/modules/content_translation/migrations/d7_taxonomy_term_translation.yml b/core/modules/content_translation/migrations/d7_taxonomy_term_translation.yml index 206df0e46b..2a5a0df846 100644 --- a/core/modules/content_translation/migrations/d7_taxonomy_term_translation.yml +++ b/core/modules/content_translation/migrations/d7_taxonomy_term_translation.yml @@ -25,7 +25,7 @@ process: tid: tid langcode: language vid: - plugin: migration + plugin: migration_lookup migration: d7_taxonomy_vocabulary source: vid name: name @@ -39,7 +39,7 @@ process: method: process source: parent - - plugin: migration + plugin: migration_lookup migration: d7_taxonomy_term parent: plugin: default_value diff --git a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php index 3b907a3607..671a604c24 100644 --- a/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php +++ b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php @@ -3,6 +3,7 @@ namespace Drupal\file\Plugin\migrate\process\d6; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -21,9 +22,21 @@ class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInter * The migration process plugin, configured for lookups in d6_file. * * @var \Drupal\migrate\Plugin\MigrateProcessInterface + * + * @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use + * migrateLookup instead. + * + * @see https://www.drupal.org/node/3047268 */ protected $migrationPlugin; + /** + * The migrate lookup service. + * + * @var \Drupal\migrate\MigrateLookupInterface + */ + protected $migrateLookup; + /** * Constructs a FieldFile plugin instance. * @@ -35,32 +48,36 @@ class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInter * The plugin definition. * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The current migration. - * @param \Drupal\migrate\Plugin\MigrateProcessInterface $migration_plugin - * An instance of the 'migration' process plugin. + * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup + * The migrate lookup service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) { + // @codingStandardsIgnoreLine + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, $migrate_lookup) { parent::__construct($configuration, $plugin_id, $plugin_definition); + + if ($migrate_lookup instanceof MigrateProcessInterface) { + @trigger_error('Passing a migration process plugin as the fourth argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268', E_USER_DEPRECATED); + $this->migrationPlugin = $migrate_lookup; + $migrate_lookup = \Drupal::service('migrate.lookup'); + } + elseif (!$migrate_lookup instanceof MigrateLookupInterface) { + throw new \InvalidArgumentException("The fifth argument to " . __METHOD__ . " must be an instance of MigrateLookupInterface."); + } $this->migration = $migration; - $this->migrationPlugin = $migration_plugin; + $this->migrateLookup = $migrate_lookup; + } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - // Configure the migration process plugin to look up migrated IDs from - // a d6 file migration. - $migration_plugin_configuration = $configuration + [ - 'migration' => 'd6_file', - 'source' => ['fid'], - ]; - return new static( $configuration, $plugin_id, $plugin_definition, $migration, - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_plugin_configuration, $migration) + $container->get('migrate.lookup') ); } @@ -75,7 +92,19 @@ public function transform($value, MigrateExecutableInterface $migrate_executable // some reason -- file migration is notoriously brittle -- and we do NOT // want to send invalid file references into the field system (it causes // fatals), so return an empty item instead. - if ($fid = $this->migrationPlugin->transform($value['fid'], $migrate_executable, $row, $destination_property)) { + // This BC layer is included because if the plugin constructor was called + // with a migration process plugin, it may have been preconfigured with a + // different migration to look up against. + if ($this->migrationPlugin) { + $fid = $this->migrationPlugin->transform($value['fid'], $migrate_executable, $row, $destination_property); + } + else { + $lookup_result = $this->migrateLookup->lookup('d6_file', [$value['fid']]); + if ($lookup_result) { + $fid = $lookup_result[0]['fid']; + } + } + if (!empty($fid)) { return [ 'target_id' => $fid, 'display' => $value['list'], diff --git a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php index 0ab8ba44fd..826cbfc56f 100644 --- a/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php +++ b/core/modules/file/tests/src/Kernel/Migrate/process/d6/CckFileTest.php @@ -25,8 +25,7 @@ class CckFileTest extends MigrateDrupalTestBase { public function testConfigurableFileMigration() { $migration = Migration::create($this->container, [], 'custom_migration', []); $cck_file_migration = CckFile::create($this->container, ['migration' => 'custom_file'], 'custom_file', [], $migration); - $migration_plugin = $this->readAttribute($cck_file_migration, 'migrationPlugin'); - $config = $this->readAttribute($migration_plugin, 'configuration'); + $config = $this->readAttribute($cck_file_migration, 'configuration'); $this->assertEquals($config['migration'], 'custom_file'); } diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php index 8781ef11b4..e26849a677 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php @@ -2,7 +2,9 @@ namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\file\Plugin\migrate\process\d6\CckFile; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -21,6 +23,10 @@ class CckFileTest extends UnitTestCase { * @expectedDeprecation CckFile is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\file\Plugin\migrate\process\d6\FieldFile instead. */ public function testTransformAltTitle() { + $migrate_lookup = $this->prophesize(MigrateLookupInterface::class); + $container = new ContainerBuilder(); + $container->set('migrate.lookup', $migrate_lookup->reveal()); + \Drupal::setContainer($container); $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal(); $row = $this->prophesize(Row::class)->reveal(); $migration = $this->prophesize(MigrationInterface::class)->reveal(); diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FieldFileTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FieldFileTest.php index e57821c0a7..4ee95841b1 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FieldFileTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FieldFileTest.php @@ -2,7 +2,9 @@ namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\file\Plugin\migrate\process\d6\FieldFile; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -22,6 +24,49 @@ public function testTransformAltTitle() { $row = $this->prophesize(Row::class)->reveal(); $migration = $this->prophesize(MigrationInterface::class)->reveal(); + $migrate_lookup = $this->prophesize(MigrateLookupInterface::class); + $migrate_lookup->lookup('d6_file', [1])->willReturn([['fid' => 1]]); + + $plugin = new FieldFile([], 'd6_file', [], $migration, $migrate_lookup->reveal()); + + $options = [ + 'alt' => 'Foobaz', + 'title' => 'Wambooli', + ]; + $value = [ + 'fid' => 1, + 'list' => TRUE, + 'data' => serialize($options), + ]; + + $transformed = $plugin->transform($value, $executable, $row, 'foo'); + $expected = [ + 'target_id' => 1, + 'display' => TRUE, + 'description' => '', + 'alt' => 'Foobaz', + 'title' => 'Wambooli', + ]; + $this->assertSame($expected, $transformed); + } + + /** + * Tests that alt and title attributes are included in transformed values. + * + * @group legacy + * + * @expectedDeprecation Passing a migration process plugin as the fourth argument to Drupal\file\Plugin\migrate\process\d6\FieldFile::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testLegacyTransformAltTitle() { + $migrate_lookup = $this->prophesize(MigrateLookupInterface::class); + $container = new ContainerBuilder(); + $container->set('migrate.lookup', $migrate_lookup->reveal()); + \Drupal::setContainer($container); + + $executable = $this->prophesize(MigrateExecutableInterface::class)->reveal(); + $row = $this->prophesize(Row::class)->reveal(); + $migration = $this->prophesize(MigrationInterface::class)->reveal(); + $migration_plugin = $this->prophesize(MigrateProcessInterface::class); $migration_plugin->transform(1, $executable, $row, 'foo')->willReturn(1); diff --git a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php index ae8fb9da64..166df49102 100644 --- a/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php +++ b/core/modules/filter/src/Plugin/migrate/process/d6/FilterFormatPermission.php @@ -3,6 +3,7 @@ namespace Drupal\filter\Plugin\migrate\process\d6; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -21,19 +22,52 @@ class FilterFormatPermission extends ProcessPluginBase implements ContainerFactoryPluginInterface { /** - * The migration plugin. + * The Migration process plugin. * * @var \Drupal\migrate\Plugin\MigrateProcessInterface + * + * @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use + * migrateLookup instead. + * + * @see https://www.drupal.org/node/3047268 */ protected $migrationPlugin; /** - * {@inheritdoc} + * The migrate lookup service. + * + * @var \Drupal\migrate\MigrateLookupInterface + */ + protected $migrateLookup; + + /** + * Constructs a FilterFormatPermission plugin instance. + * + * @param array $configuration + * The plugin configuration. + * @param string $plugin_id + * The plugin ID. + * @param mixed $plugin_definition + * The plugin definition. + * @param \Drupal\migrate\Plugin\MigrationInterface $migration + * The current migration. + * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup + * The migrate lookup service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, MigrateProcessInterface $migration_plugin) { + // @codingStandardsIgnoreLine + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, $migrate_lookup) { parent::__construct($configuration, $plugin_id, $plugin_definition); + if ($migrate_lookup instanceof MigrateProcessInterface) { + @trigger_error('Passing a migration process plugin as the fourth argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268', E_USER_DEPRECATED); + $this->migrationPlugin = $migrate_lookup; + $migrate_lookup = \Drupal::service('migrate.lookup'); + } + elseif (!$migrate_lookup instanceof MigrateLookupInterface) { + throw new \InvalidArgumentException("The fifth argument to " . __METHOD__ . " must be an instance of MigrateLookupInterface."); + } $this->migration = $migration; - $this->migrationPlugin = $migration_plugin; + $this->migrateLookup = $migrate_lookup; + } /** @@ -49,7 +83,7 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $migration, - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_plugin_configuration, $migration) + $container->get('migrate.lookup') ); } @@ -60,10 +94,23 @@ public static function create(ContainerInterface $container, array $configuratio */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $rid = $row->getSourceProperty('rid'); + $migration = isset($this->configuration['migration']) ? $this->configuration['migration'] : 'd6_filter_format'; if ($formats = $row->getSourceProperty("filter_permissions:$rid")) { foreach ($formats as $format) { - $new_id = $this->migrationPlugin->transform($format, $migrate_executable, $row, $destination_property); - if ($new_id) { + + // This BC layer is included because if the plugin constructor was called + // with a migration process plugin, it may have been preconfigured with a + // different migration to look up against. + if ($this->migrationPlugin) { + $new_id = $this->migrationPlugin->transform($format, $migrate_executable, $row, $destination_property); + } + else { + $lookup_result = $this->migrateLookup->lookup($migration, [$format]); + if ($lookup_result) { + $new_id = $lookup_result[0]['format']; + } + } + if (!empty($new_id)) { $value[] = 'use text format ' . $new_id; } } diff --git a/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php b/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php index 80b0c7d811..e1fec476cf 100644 --- a/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php +++ b/core/modules/filter/tests/src/Kernel/Migrate/d6/FilterFormatPermissionTest.php @@ -3,7 +3,9 @@ namespace Drupal\Tests\filter\Kernel\Migrate\d6; use Drupal\filter\Plugin\migrate\process\d6\FilterFormatPermission; +use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Plugin\Migration; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase; /** @@ -23,10 +25,21 @@ class FilterFormatPermissionTest extends MigrateDrupalTestBase { public function testConfigurableFilterFormat() { $migration = Migration::create($this->container, [], 'custom_migration', []); $filterFormatPermissionMigration = FilterFormatPermission::create($this->container, ['migration' => 'custom_filter_format'], 'custom_filter_format', [], $migration); - $migrationPlugin = $this->readAttribute($filterFormatPermissionMigration, 'migrationPlugin'); - $config = $this->readAttribute($migrationPlugin, 'configuration'); - + $config = $this->readAttribute($filterFormatPermissionMigration, 'configuration'); $this->assertEquals($config['migration'], 'custom_filter_format'); } + /** + * Tests legacy plugin usage. + * + * @group legacy + * + * @expectedDeprecation Passing a migration process plugin as the fourth argument to Drupal\filter\Plugin\migrate\process\d6\FilterFormatPermission::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testLegacyConstruct() { + $process_plugin = $this->prophesize(MigrateProcessInterface::class)->reveal(); + $plugin = new FilterFormatPermission([], '', [], $this->prophesize(MigrationInterface::class)->reveal(), $process_plugin); + $this->assertSame($process_plugin, $this->readAttribute($plugin, 'migrationPlugin')); + } + } diff --git a/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php b/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php index 9101442313..48757a8516 100644 --- a/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php +++ b/core/modules/migrate/src/Plugin/migrate/process/MenuLinkParent.php @@ -7,6 +7,7 @@ use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Url; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateSkipRowException; @@ -30,21 +31,70 @@ class MenuLinkParent extends ProcessPluginBase implements ContainerFactoryPlugin protected $menuLinkManager; /** + * The Migration process plugin. + * * @var \Drupal\migrate\Plugin\MigrateProcessInterface + * + * @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use + * migrateLookup instead. + * + * @see https://www.drupal.org/node/3047268 */ protected $migrationPlugin; + /** + * The currently running migration. + * + * @var \Drupal\migrate\Plugin\MigrationInterface + */ + protected $migration; + + /** + * The migrate lookup service. + * + * @var \Drupal\migrate\MigrateLookupInterface + */ + protected $migrateLookup; + /** * @var \Drupal\Core\Entity\EntityStorageInterface */ protected $menuLinkStorage; /** - * {@inheritdoc} + * Constructs a MenuLinkParent object. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param mixed $plugin_definition + * The plugin implementation definition. + * @param \Drupal\migrate\MigrateLookupInterface $migrate_lookup + * The migrate lookup service. + * @param \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager + * The menu link manager. + * @param \Drupal\Core\Entity\EntityStorageInterface $menu_link_storage + * The menu link storage object. + * @param \Drupal\migrate\Plugin\MigrationInterface $migration + * The currently running migration. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrateProcessInterface $migration_plugin, MenuLinkManagerInterface $menu_link_manager, EntityStorageInterface $menu_link_storage) { + // @codingStandardsIgnoreLine + public function __construct(array $configuration, $plugin_id, $plugin_definition, $migrate_lookup, MenuLinkManagerInterface $menu_link_manager, EntityStorageInterface $menu_link_storage, MigrationInterface $migration = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition); - $this->migrationPlugin = $migration_plugin; + if ($migrate_lookup instanceof MigrateProcessInterface) { + @trigger_error('Passing a migration process plugin as the fourth argument to ' . __METHOD__ . ' is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268', E_USER_DEPRECATED); + $this->migrationPlugin = $migrate_lookup; + $migrate_lookup = \Drupal::service('migrate.lookup'); + } + elseif (!$migrate_lookup instanceof MigrateLookupInterface) { + throw new \InvalidArgumentException("The fourth argument to " . __METHOD__ . " must be an instance of MigrateLookupInterface."); + } + elseif (!$migration instanceof MigrationInterface) { + throw new \InvalidArgumentException("The seventh argument to " . __METHOD__ . " must be an instance of MigrationInterface."); + } + $this->migration = $migration; + $this->migrateLookup = $migrate_lookup; $this->menuLinkManager = $menu_link_manager; $this->menuLinkStorage = $menu_link_storage; } @@ -58,9 +108,10 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration), + $container->get('migrate.lookup'), $container->get('plugin.manager.menu.link'), - $container->get('entity_type.manager')->getStorage('menu_link_content') + $container->get('entity_type.manager')->getStorage('menu_link_content'), + $migration ); } @@ -75,16 +126,27 @@ public function transform($value, MigrateExecutableInterface $migrate_executable // Top level item. return ''; } - try { - $already_migrated_id = $this - ->migrationPlugin - ->transform($parent_id, $migrate_executable, $row, $destination_property); - if ($already_migrated_id && ($link = $this->menuLinkStorage->load($already_migrated_id))) { - return $link->getPluginId(); + // This BC layer is included because if the plugin constructor was called + // with a migration process plugin, it may have been preconfigured with a + // different migration to look up against. + if ($this->migrationPlugin) { + try { + $already_migrated_id = $this + ->migrationPlugin + ->transform($parent_id, $migrate_executable, $row, $destination_property); + } + catch (MigrateSkipRowException $e) { + } + } + else { + $lookup_result = $this->migrateLookup->lookup($this->migration->id(), [$parent_id]); + if ($lookup_result) { + $already_migrated_id = $lookup_result[0]['id']; } } - catch (MigrateSkipRowException $e) { + if (!empty($already_migrated_id) && ($link = $this->menuLinkStorage->load($already_migrated_id))) { + return $link->getPluginId(); } if (isset($value[1])) { diff --git a/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php b/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php index 238362a0ad..d207be0c06 100644 --- a/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php +++ b/core/modules/migrate/tests/src/Unit/process/MenuLinkParentTest.php @@ -3,12 +3,15 @@ namespace Drupal\Tests\migrate\Unit\process; use Drupal\Component\Plugin\PluginInspectionInterface; +use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\menu_link_content\MenuLinkContentInterface; +use Drupal\migrate\MigrateLookupInterface; use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\Plugin\migrate\process\MenuLinkParent; use Drupal\migrate\Plugin\MigrateProcessInterface; +use Drupal\migrate\Plugin\MigrationInterface; /** * Tests the menu link parent process plugin. @@ -18,24 +21,58 @@ */ class MenuLinkParentTest extends MigrateProcessTestCase { + /** + * A MigrationInterface prophecy. + * + * @var \Prophecy\Prophecy\ObjectProphecy + */ + protected $migration; + + /** + * A MigrateLookupInterface prophecy. + * + * @var \Prophecy\Prophecy\ObjectProphecy + */ + protected $migrateLookup; + + /** + * A MigrationInterface prophecy. + * + * @var \Prophecy\Prophecy\ObjectProphecy + */ + protected $menuLinkManager; + + /** + * A MigrationInterface prophecy. + * + * @var \Prophecy\Prophecy\ObjectProphecy + */ + protected $menuLinkStorage; + /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); - $migration_plugin = $this->prophesize(MigrateProcessInterface::class); - $menu_link_manager = $this->prophesize(MenuLinkManagerInterface::class); - $menu_link_storage = $this->prophesize(EntityStorageInterface::class); - $this->plugin = new MenuLinkParent([], 'map', [], $migration_plugin->reveal(), $menu_link_manager->reveal(), $menu_link_storage->reveal()); + $this->migration = $this->prophesize(MigrationInterface::class); + $this->migrateLookup = $this->prophesize(MigrateLookupInterface::class); + $this->migrateLookup->lookup(NULL, [1])->willReturn([]); + $this->menuLinkManager = $this->prophesize(MenuLinkManagerInterface::class); + $this->menuLinkStorage = $this->prophesize(EntityStorageInterface::class); + $container = new ContainerBuilder(); + $container->set('migrate.lookup', $this->migrateLookup->reveal()); + \Drupal::setContainer($container); + } /** * @covers ::transform */ public function testTransformException() { + $plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup->reveal(), $this->menuLinkManager->reveal(), $this->menuLinkStorage->reveal(), $this->migration->reveal()); $this->expectException(MigrateSkipRowException::class); $this->expectExceptionMessage("No parent link found for plid '1' in menu 'admin'."); - $this->plugin->transform([1, 'admin', NULL], $this->migrateExecutable, $this->row, 'destinationproperty'); + $plugin->transform([1, 'admin', NULL], $this->migrateExecutable, $this->row, 'destinationproperty'); } /** @@ -44,6 +81,31 @@ public function testTransformException() { * @covers ::transform */ public function testTransformExternal() { + $menu_link_content = $this->prophesize(MenuLinkContentInterface::class); + $menu_link_content->getPluginId()->willReturn('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27'); + $this->menuLinkStorage->loadByProperties([ + 'link__uri' => 'http://example.com', + ])->willReturn([ + 9054 => $menu_link_content, + ]); + $plugin = $this->prophesize(PluginInspectionInterface::class); + $this->menuLinkManager->createInstance('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27')->willReturn($plugin->reveal()); + $plugin = new MenuLinkParent([], 'map', [], $this->migrateLookup->reveal(), $this->menuLinkManager->reveal(), $this->menuLinkStorage->reveal(), $this->migration->reveal()); + + $result = $plugin->transform([1, 'admin', 'http://example.com'], $this->migrateExecutable, $this->row, 'destinationproperty'); + $this->assertEquals('menu_link_content:fe151460-dfa2-4133-8864-c1746f28ab27', $result); + } + + /** + * Tests the plugin when the parent is an external link. + * + * @covers ::transform + * + * @group legacy + * + * @expectedDeprecation Passing a migration process plugin as the fourth argument to Drupal\migrate\Plugin\migrate\process\MenuLinkParent::__construct is deprecated in drupal:8.8.0 and will throw an error in drupal:9.0.0. Pass the migrate.lookup service instead. See https://www.drupal.org/node/3047268 + */ + public function testLegacyTransformExternal() { $migration_plugin = $this->prophesize(MigrateProcessInterface::class); $menu_link_manager = $this->prophesize(MenuLinkManagerInterface::class); $menu_link_storage = $this->prophesize(EntityStorageInterface::class); diff --git a/core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php b/core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php index cc2fb8c373..83ae30e908 100644 --- a/core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/d6/FieldDiscoveryTest.php @@ -246,7 +246,7 @@ public function testAddFields() { 'method' => 'process', ], 2 => [ - 'plugin' => 'migration', + 'plugin' => 'migration_lookup', 'migration' => [ 0 => 'd6_filter_format', 1 => 'd7_filter_format', diff --git a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php index dba6398a06..6eeb95f6d0 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -80,7 +80,7 @@ public function defineValueProcessPipeline(MigrationInterface $migration, $field 'method' => 'process', ], [ - 'plugin' => 'migration', + 'plugin' => 'migration_lookup', 'migration' => [ 'd6_filter_format', 'd7_filter_format', diff --git a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php index 807b9f16e5..6e1381e03f 100644 --- a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php +++ b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php @@ -66,7 +66,7 @@ public function testProcessFilteredTextFieldValues() { // Ensure that filter format IDs will be looked up in the filter format // migrations. $lookup = $process['process']['format'][2]; - $this->assertSame('migration', $lookup['plugin']); + $this->assertSame('migration_lookup', $lookup['plugin']); $this->assertContains('d6_filter_format', $lookup['migration']); $this->assertContains('d7_filter_format', $lookup['migration']); $this->assertSame('format', $lookup['source']); @@ -89,7 +89,7 @@ public function testFilteredTextValueProcessPipeline() { // Ensure that filter format IDs will be looked up in the filter format // migrations. $lookup = $process['process']['format'][2]; - $this->assertSame('migration', $lookup['plugin']); + $this->assertSame('migration_lookup', $lookup['plugin']); $this->assertContains('d6_filter_format', $lookup['migration']); $this->assertContains('d7_filter_format', $lookup['migration']); $this->assertSame('format', $lookup['source']); diff --git a/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php index c6970f4d95..5f8dc9c66a 100644 --- a/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php +++ b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php @@ -61,7 +61,7 @@ public function testProcessFilteredTextFieldValues($method = 'defineValueProcess // Ensure that filter format IDs will be looked up in the filter format // migrations. $lookup = $process['process']['format'][2]; - $this->assertSame('migration', $lookup['plugin']); + $this->assertSame('migration_lookup', $lookup['plugin']); $this->assertContains('d6_filter_format', $lookup['migration']); $this->assertContains('d7_filter_format', $lookup['migration']); $this->assertSame('format', $lookup['source']); diff --git a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php index 742b13ed12..0773adc0e0 100644 --- a/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php +++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php @@ -122,7 +122,6 @@ public static function getSkippedDeprecations() { 'MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.', 'MigrateCckFieldPluginManagerInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManagerInterface instead.', 'The "plugin.manager.migrate.cckfield" service is deprecated. You should use the \'plugin.manager.migrate.field\' service instead. See https://www.drupal.org/node/2751897', - 'The Drupal\migrate\Plugin\migrate\process\Migration is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Instead, use Drupal\migrate\Plugin\migrate\process\MigrationLookup', 'Passing in arguments the legacy way is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.0. Provide the right parameter names in the method, similar to controllers. See https://www.drupal.org/node/2894819', 'The "serializer.normalizer.file_entity.hal" normalizer service is deprecated: it is obsolete, it only remains available for backwards compatibility.', 'The Symfony\Component\ClassLoader\ApcClassLoader class is deprecated since Symfony 3.3 and will be removed in 4.0. Use `composer install --apcu-autoloader` instead.',