Commit 3946cf35 authored by alexpott's avatar alexpott

Issue #3004929 by mikelutz, heddn: Fix 'The...

Issue #3004929 by mikelutz, heddn: Fix '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'

(cherry picked from commit efc4dd97)
parent c6b0f769
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Plugin\MigrateProcessInterface;
...@@ -19,13 +20,27 @@ ...@@ -19,13 +20,27 @@
class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface { class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginInterface {
/** /**
* The migration process plugin, configured for lookups in d6_custom_block * The migration process plugin.
* and d7_custom_block. *
* The plugin is configured for lookups in d6_custom_block and
* d7_custom_block.
* *
* @var \Drupal\migrate\Plugin\MigrateProcessInterface * @var \Drupal\migrate\Plugin\MigrateProcessInterface
*
* @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use
* the migrate.lookup service instead.
*
* @see https://www.drupal.org/node/3047268
*/ */
protected $migrationPlugin; protected $migrationPlugin;
/**
* The migrate lookup service.
*
* @var \Drupal\migrate\MigrateLookupInterface
*/
protected $migrateLookup;
/** /**
* The block_content entity storage handler. * The block_content entity storage handler.
* *
...@@ -34,12 +49,32 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI ...@@ -34,12 +49,32 @@ class BlockPluginId extends ProcessPluginBase implements ContainerFactoryPluginI
protected $blockContentStorage; 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); 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->blockContentStorage = $storage;
$this->migrationPlugin = $migration_plugin; $this->migrateLookup = $migrate_lookup;
} }
/** /**
...@@ -47,18 +82,12 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi ...@@ -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) { public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
$entity_type_manager = $container->get('entity_type.manager'); $entity_type_manager = $container->get('entity_type.manager');
$migration_configuration = [
'migration' => [
'd6_custom_block',
'd7_custom_block',
],
];
return new static( return new static(
$configuration, $configuration,
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$entity_type_manager->getDefinition('block_content') ? $entity_type_manager->getStorage('block_content') : NULL, $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')
); );
} }
...@@ -77,17 +106,35 @@ public function transform($value, MigrateExecutableInterface $migrate_executable ...@@ -77,17 +106,35 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
return 'aggregator_feed_block'; return 'aggregator_feed_block';
} }
break; break;
case 'menu': case 'menu':
return "system_menu_block:$delta"; return "system_menu_block:$delta";
case 'block': case 'block':
if ($this->blockContentStorage) { if ($this->blockContentStorage) {
$block_id = $this->migrationPlugin // This BC layer is included because if the plugin constructor was
->transform($delta, $migrate_executable, $row, $destination_property); // called in the legacy way with a migration_lookup process plugin,
if ($block_id) { // it may have been preconfigured with a different migration to
// look up against. While this is unlikely, for maximum BC we will
// continue to use the plugin to do the lookup if it is provided,
// and support for this will be removed in Drupal 9.
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(); return 'block_content:' . $this->blockContentStorage->load($block_id)->uuid();
} }
} }
break; break;
default: default:
break; break;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\MigrateSkipRowException;
...@@ -27,13 +28,27 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi ...@@ -27,13 +28,27 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
protected $moduleHandler; protected $moduleHandler;
/** /**
* The migration process plugin, configured for lookups in the d6_user_role * The migration process plugin.
* and d7_user_role migrations. *
* The plugin is configured for lookups in the d6_user_role and d7_user_role
* migrations.
* *
* @var \Drupal\migrate\Plugin\MigrateProcessInterface * @var \Drupal\migrate\Plugin\MigrateProcessInterface
*
* @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use
* the migrate.lookup service instead.
*
* @see https://www.drupal.org/node/3047268
*/ */
protected $migrationPlugin; 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 * Whether or not to skip blocks that use PHP for visibility. Only applies
* if the PHP module is not enabled. * if the PHP module is not enabled.
...@@ -43,12 +58,32 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi ...@@ -43,12 +58,32 @@ class BlockVisibility extends ProcessPluginBase implements ContainerFactoryPlugi
protected $skipPHP = FALSE; 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); 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->moduleHandler = $module_handler;
$this->migrationPlugin = $migration_plugin; $this->migrateLookup = $migrate_lookup;
if (isset($configuration['skip_php'])) { if (isset($configuration['skip_php'])) {
$this->skipPHP = $configuration['skip_php']; $this->skipPHP = $configuration['skip_php'];
...@@ -59,18 +94,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition ...@@ -59,18 +94,12 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
* {@inheritdoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { 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( return new static(
$configuration, $configuration,
$plugin_id, $plugin_id,
$plugin_definition, $plugin_definition,
$container->get('module_handler'), $container->get('module_handler'),
$container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_configuration, $migration) $container->get('migrate.lookup')
); );
} }
...@@ -94,7 +123,22 @@ public function transform($value, MigrateExecutableInterface $migrate_executable ...@@ -94,7 +123,22 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
]; ];
foreach ($roles as $key => $role_id) { foreach ($roles as $key => $role_id) {
$roles[$key] = $this->migrationPlugin->transform($role_id, $migrate_executable, $row, $destination_property); // This BC layer is included because if the plugin constructor was
// called in the legacy way with a migration_lookup process plugin, it
// may have been preconfigured with a different migration to look up
// against. While this is unlikely, for maximum BC we will continue to
// use the plugin to do the lookup if it is provided, and support for
// this will be removed in Drupal 9.
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); $visibility['user_role']['roles'] = array_combine($roles, $roles);
} }
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
use Drupal\block\Plugin\migrate\process\BlockVisibility; use Drupal\block\Plugin\migrate\process\BlockVisibility;
use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\MigrateSkipRowException; use Drupal\migrate\MigrateSkipRowException;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase; use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
/** /**
...@@ -29,8 +29,8 @@ class BlockVisibilityTest extends MigrateProcessTestCase { ...@@ -29,8 +29,8 @@ class BlockVisibilityTest extends MigrateProcessTestCase {
protected function setUp() { protected function setUp() {
parent::setUp(); parent::setUp();
$this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class); $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
$migration_plugin = $this->prophesize(MigrateProcessInterface::class); $migrate_lookup = $this->prophesize(MigrateLookupInterface::class);
$this->plugin = new BlockVisibility([], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migration_plugin->reveal()); $this->plugin = new BlockVisibility([], 'block_visibility_pages', [], $this->moduleHandler->reveal(), $migrate_lookup->reveal());
} }
/** /**
...@@ -86,7 +86,7 @@ public function testTransformPhpDisabled() { ...@@ -86,7 +86,7 @@ public function testTransformPhpDisabled() {
*/ */
public function testTransformException() { public function testTransformException() {
$this->moduleHandler->moduleExists('php')->willReturn(FALSE); $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') $this->row = $this->getMockBuilder('Drupal\migrate\Row')
->disableOriginalConstructor() ->disableOriginalConstructor()
->setMethods(['getSourceProperty']) ->setMethods(['getSourceProperty'])
...@@ -94,7 +94,7 @@ public function testTransformException() { ...@@ -94,7 +94,7 @@ public function testTransformException() {
$this->row->expects($this->exactly(2)) $this->row->expects($this->exactly(2))
->method('getSourceProperty') ->method('getSourceProperty')
->willReturnMap([['bid', 99], ['module', 'foobar']]); ->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->expectException(MigrateSkipRowException::class);
$this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration."); $this->expectExceptionMessage("The block with bid '99' from module 'foobar' will have no PHP or request_path visibility configuration.");
$this->plugin->transform([2, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty'); $this->plugin->transform([2, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty');
......
<?php
namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
use Drupal\block\Plugin\migrate\process\BlockPluginId;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface;
use Drupal\Tests\migrate\Unit\process\MigrateProcessTestCase;
/**
* Tests legacy usage of BlockPluginId.
*
* @group block
* @group legacy
*
* @coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockPluginId
*/
class LegacyBlockPluginIdTest extends MigrateProcessTestCase {
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$migrate_lookup = $this->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'));
}
}
<?php
namespace Drupal\Tests\block\Unit\Plugin\migrate\process;
use Drupal\block\Plugin\migrate\process\BlockVisibility;
use Drupal\Core\DependencyInjection\ContainerBuilder;
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;
/**
* Tests the block_visibility process plugin.
*
* @coversDefaultClass \Drupal\block\Plugin\migrate\process\BlockVisibility
*
* @group block
* @group legacy
*/
class LegacyBlockVisibilityTest extends MigrateProcessTestCase {
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$migrate_lookup = $this->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, '<front>', []], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('request_path', $visibility['request_path']['id']);
$this->assertTrue($visibility['request_path']['negate']);
$this->assertSame('<front>', $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<front>", []], $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<front>", $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, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty');
$this->assertSame('php', $visibility['php']['id']);
$this->assertFalse($visibility['php']['negate']);
$this->assertSame('<?php', $visibility['php']['php']);
}
/**
* 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 testTransformPhpDisabled() {
$this->moduleHandler->moduleExists('php')->willReturn(FALSE);
$transformed_value = $this->plugin->transform([2, '<?php', []], $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 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, '<?php', []], $this->migrateExecutable, $this->row, 'destinationproperty');
}
}
...@@ -13,7 +13,7 @@ process: ...@@ -13,7 +13,7 @@ process:
tid: tid tid: tid
langcode: language langcode: language
vid: vid:
plugin: migration plugin: migration_lookup
migration: d6_taxonomy_vocabulary migration: d6_taxonomy_vocabulary
source: vid source: vid
name: name:
......
...@@ -13,7 +13,7 @@ process: ...@@ -13,7 +13,7 @@ process:
tid: tid tid: tid
langcode: language langcode: language
vid: vid:
plugin: migration plugin: migration_lookup
migration: d6_taxonomy_vocabulary migration: d6_taxonomy_vocabulary
source: vid source: vid
name: name name: name
...@@ -26,7 +26,7 @@ process: ...@@ -26,7 +26,7 @@ process:
method: process method: process
source: parent source: parent
- -
plugin: migration plugin: migration_lookup
migration: d6_taxonomy_term migration: d6_taxonomy_term
parent: parent:
plugin: default_value plugin: default_value
......
...@@ -14,7 +14,7 @@ process: ...@@ -14,7 +14,7 @@ process:
# Use the language from the locales_target table. # Use the language from the locales_target table.
langcode: ltlanguage langcode: ltlanguage
vid: vid:
plugin: migration plugin: migration_lookup
migration: d7_taxonomy_vocabulary migration: d7_taxonomy_vocabulary
source: vid source: vid
name: name:
......
...@@ -25,7 +25,7 @@ process: ...@@ -25,7 +25,7 @@ process:
tid: tid tid: tid
langcode: language langcode: language
vid: vid:
plugin: migration plugin: migration_lookup
migration: d7_taxonomy_vocabulary migration: d7_taxonomy_vocabulary
source: vid source: vid
name: name name: name
...@@ -39,7 +39,7 @@ process: ...@@ -39,7 +39,7 @@ process:
method: process method: process
source: parent source: parent
- -
plugin: migration plugin: migration_lookup
migration: d7_taxonomy_term migration: d7_taxonomy_term
parent: parent:
plugin: default_value plugin: default_value
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Drupal\file\Plugin\migrate\process\d6; namespace Drupal\file\Plugin\migrate\process\d6;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\migrate\MigrateLookupInterface;
use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\MigrateExecutableInterface;
use Drupal\migrate\Plugin\MigrateProcessInterface; use Drupal\migrate\Plugin\MigrateProcessInterface;
...@@ -21,9 +22,21 @@ class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInter ...@@ -21,9 +22,21 @@ class FieldFile extends ProcessPluginBase implements ContainerFactoryPluginInter
* The migration process plugin, configured for lookups in d6_file. * The migration process plugin, configured for lookups in d6_file.
* *
* @var \Drupal\migrate\Plugin\MigrateProcessInterface * @var \Drupal\migrate\Plugin\MigrateProcessInterface
*
* @deprecated in drupal:8.8.x and is removed from drupal:9.0.0. Use
* the migrate.lookup service instead.
*
* @see https://www.drupal.org/node/3047268
*/ */
protected $migrationPlugin; protected $migrationPlugin;
/**
* The migrate lookup service.
*
* @var \Drupal\migrate\MigrateLookupInterface
*/
protected $migrateLookup;
/**