diff --git a/core/.phpstan-baseline.php b/core/.phpstan-baseline.php index 31cea8ca47f4a234d6bd4bfb4cae939f0e2f30f7..6bfcd63daeb051786ecd2d8a74486703b73b2e83 100644 --- a/core/.phpstan-baseline.php +++ b/core/.phpstan-baseline.php @@ -26365,12 +26365,6 @@ 'count' => 1, 'path' => __DIR__ . '/modules/migrate/src/Plugin/migrate/destination/Entity.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:fields\\(\\) should return array but return statement is missing\\.$#', - 'identifier' => 'return.missing', - 'count' => 1, - 'path' => __DIR__ . '/modules/migrate/src/Plugin/migrate/destination/Entity.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Drupal\\\\migrate\\\\Plugin\\\\migrate\\\\destination\\\\Entity\\:\\:processStubRow\\(\\) has no return type specified\\.$#', 'identifier' => 'missingType.return', diff --git a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php index 474d1cad41e21d391a0bd4e53f1141a96bd456b6..45ba7394399f0b8f524f7978532e78084c6383ec 100644 --- a/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php +++ b/core/modules/comment/src/Plugin/migrate/destination/EntityComment.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\Core\State\StateInterface; @@ -56,9 +57,11 @@ class EntityComment extends EntityContentBase { * The state storage object. * @param \Drupal\Core\Session\AccountSwitcherInterface|null $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state, ?AccountSwitcherInterface $account_switcher = NULL) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, StateInterface $state, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); $this->state = $state; } @@ -77,7 +80,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), $container->get('state'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); } diff --git a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php index 382aeb2bb7f5048fcaa0788860b0fb97ad2ab298..403f39f3768c40cb54e16be3e18584ce2ec74cab 100644 --- a/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php +++ b/core/modules/migrate/src/Plugin/MigrateDestinationInterface.php @@ -86,6 +86,9 @@ public function getIds(); * @return array * - Keys: machine names of the fields * - Values: Human-friendly descriptions of the fields. + * + * @throws \Drupal\migrate\MigrateException + * Thrown when the destination plugin is not configured correctly. */ public function fields(); diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index b41fe489ce365a35739f1edc946082ba15032e45..ecc6dba4d6da1c29afbc61607a28ef93d5617e09 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -23,7 +23,8 @@ * * Available configuration keys: * - default_bundle: (optional) The bundle to use for this row if 'bundle' is - * not defined on the row. + * not defined on the row. Setting this also allows the fields() method to + * return bundle fields as well as base fields. * * Examples: * @@ -149,7 +150,7 @@ public function getBundle(Row $row) { * {@inheritdoc} */ public function fields() { - // @todo Implement fields() method. + return []; } /** diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php index 63daca44246044826de163318c4ad5f164fa29ab..0a7409afd259f0daaf83356eadc706adecd3642b 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityContentBase.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; @@ -113,6 +114,13 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal */ protected $accountSwitcher; + /** + * Entity type bundle info. + * + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface + */ + protected EntityTypeBundleInfoInterface $entityTypeBundleInfo; + /** * Constructs a content entity. * @@ -134,12 +142,19 @@ class EntityContentBase extends Entity implements HighestIdInterface, MigrateVal * The field type plugin manager service. * @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ?AccountSwitcherInterface $account_switcher = NULL) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles); $this->entityFieldManager = $entity_field_manager; $this->fieldTypeManager = $field_type_manager; $this->accountSwitcher = $account_switcher; + if ($entity_type_bundle_info === NULL) { + @trigger_error('Calling ' . __NAMESPACE__ . '\EntityContentBase::__construct() without the $entity_type_bundle_info argument is deprecated in drupal:11.2.0 and will be required in drupal:12.0.0. See https://www.drupal.org/node/3476634', E_USER_DEPRECATED); + $entity_type_bundle_info = \Drupal::service('entity_type.bundle.info'); + } + $this->entityTypeBundleInfo = $entity_type_bundle_info; } /** @@ -156,7 +171,8 @@ public static function create(ContainerInterface $container, array $configuratio array_keys($container->get('entity_type.bundle.info')->getBundleInfo($entity_type)), $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); } @@ -401,4 +417,48 @@ public function getHighestId() { return (int) current($values); } + /** + * {@inheritdoc} + */ + public function fields(): array { + $entity_type = $this->storage->getEntityType(); + // Retrieving fields from a non-fieldable content entity will return a + // LogicException. Return an empty list of fields instead. + if (!$entity_type->entityClassImplements(FieldableEntityInterface::class)) { + return []; + } + + // Try to determine the bundle to use when getting fields. + $bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type->id()); + + if (!empty($this->configuration['default_bundle'])) { + // If the migration destination configuration specifies a default_bundle, + // then use that. + $bundle = $this->configuration['default_bundle']; + + if (!isset($bundle_info[$bundle])) { + throw new MigrateException(sprintf("The default_bundle value '%s' is not a valid bundle for the destination entity type '%s'.", $bundle, $entity_type->id())); + } + } + elseif (count($bundle_info) === 1) { + // If the destination entity type has only one bundle, use that. + $bundle = array_key_first($bundle_info); + } + + if (isset($bundle)) { + // If we have a bundle, get all the fields. + $field_definitions = $this->entityFieldManager->getFieldDefinitions($entity_type->id(), $bundle); + } + else { + // Without a bundle, we can only get the base fields. + $field_definitions = $this->entityFieldManager->getBaseFieldDefinitions($entity_type->id()); + } + + $fields = []; + foreach ($field_definitions as $field_name => $definition) { + $fields[$field_name] = (string) $definition->getLabel(); + } + return $fields; + } + } diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php index fcf5148c90df89f50e256437a15f1ea9c363ff22..ec18083c9ef7e17ad94b44ea251aaf8dcf4a20a4 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityRevision.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; @@ -116,11 +117,11 @@ class EntityRevision extends EntityContentBase { /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, AccountSwitcherInterface $account_switcher) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, AccountSwitcherInterface $account_switcher, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { $plugin_definition += [ 'label' => new TranslatableMarkup('@entity_type revisions', ['@entity_type' => $storage->getEntityType()->getSingularLabel()]), ]; - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); } /** diff --git a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php index a21bca9c8682529bd69f96f5e298e02e06239c04..c4f0c4f6229fb56bed67465fe7ff5dca251fc72a 100644 --- a/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateEntityContentBaseTest.php @@ -6,6 +6,8 @@ use Drupal\Core\Entity\EntityFieldManager; use Drupal\entity_test\Entity\EntityTestMul; +use Drupal\field\Entity\FieldConfig; +use Drupal\field\Entity\FieldStorageConfig; use Drupal\KernelTests\KernelTestBase; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\migrate\MigrateExecutable; @@ -28,7 +30,13 @@ class MigrateEntityContentBaseTest extends KernelTestBase { /** * {@inheritdoc} */ - protected static $modules = ['migrate', 'user', 'language', 'entity_test']; + protected static $modules = [ + 'entity_test', + 'field', + 'language', + 'migrate', + 'user', + ]; /** * The storage for entity_test_mul. @@ -56,6 +64,9 @@ protected function setUp(): void { \Drupal::state()->set('entity_test.required_multi_default_field', TRUE); $this->installEntitySchema('entity_test_mul'); + $this->installEntitySchema('entity_test_with_bundle'); + $this->installEntitySchema('entity_test_no_bundle'); + ConfigurableLanguage::createFromLangcode('en')->save(); ConfigurableLanguage::createFromLangcode('fr')->save(); @@ -100,7 +111,8 @@ protected function createDestination(array $configuration): void { [], $this->container->get('entity_field.manager'), $this->container->get('plugin.manager.field.field_type'), - $this->container->get('account_switcher') + $this->container->get('account_switcher'), + $this->container->get('entity_type.bundle.info'), ); } @@ -352,4 +364,84 @@ public function getFieldDefinitions($entity_type_id, $bundle) { $this->createEntityStub('migrate_string_id_entity_test'); } + /** + * Test destination fields() method. + */ + public function testFields(): void { + $entity_type_manager = $this->container->get('entity_type.manager'); + // Create two bundles for the entity_test_with_bundle entity type. + $bundle_storage = $entity_type_manager->getStorage('entity_test_bundle'); + $bundle_storage->create([ + 'id' => 'test_bundle_no_fields', + 'label' => 'Test bundle without fields', + ])->save(); + $bundle_storage->create([ + 'id' => 'test_bundle_with_fields', + 'label' => 'Test bundle with fields', + ])->save(); + + // Create a mock migration and get the destination plugin manager. + $migration = $this->prophesize(MigrationInterface::class)->reveal(); + /** @var \Drupal\migrate\Plugin\MigrateDestinationPluginManager $manager */ + $manager = \Drupal::service('plugin.manager.migrate.destination'); + + // Test with an entity type with no bundles. + $destination_plugin = $manager->createInstance('entity:entity_test_no_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + // Confirm the test field is not found. + $this->assertArrayNotHasKey('field_text', $fields); + + // Create a text field attached to the entity with no bundles. + FieldStorageConfig::create([ + 'type' => 'string', + 'entity_type' => 'entity_test_no_bundle', + 'field_name' => 'field_text', + ])->save(); + + FieldConfig::create([ + 'entity_type' => 'entity_test_no_bundle', + 'bundle' => 'entity_test_no_bundle', + 'field_name' => 'field_text', + ])->save(); + + // Confirm that the 'field_text' is now found. + $destination_plugin = $manager->createInstance('entity:entity_test_no_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayHasKey('field_text', $fields); + + // Repeat the test with an entity with bundles. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayNotHasKey('field_text', $fields); + + // Create a text field attached to the entity with bundles. + FieldStorageConfig::create([ + 'type' => 'string', + 'entity_type' => 'entity_test_with_bundle', + 'field_name' => 'field_text', + ])->save(); + + FieldConfig::create([ + 'entity_type' => 'entity_test_with_bundle', + 'bundle' => 'test_bundle_with_fields', + 'field_name' => 'field_text', + ])->save(); + + // Confirm that the 'field_text' is found when the default bundle is set. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', ['default_bundle' => 'test_bundle_with_fields'], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayHasKey('field_text', $fields); + + // Confirm that the 'field_text' is not found when the default bundle is not + // set. + $destination_plugin = $manager->createInstance('entity:entity_test_with_bundle', [], $migration); + $fields = $destination_plugin->fields(); + $this->assertArrayHasKey('id', $fields); + $this->assertArrayNotHasKey('field_text', $fields); + } + } diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php index 95c8b752c91dbc05e3ebd43debc87fec2dc9850f..6b18a1bacb830dff395b6c63e8affa12e263d2d0 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityContentBaseTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination; use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; use Drupal\migrate\MigrateException; @@ -34,7 +35,8 @@ public function testImport(): void { $bundles, $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $entity = $this->prophesize(ContentEntityInterface::class); $entity->isValidationRequired() @@ -68,7 +70,8 @@ public function testImportEntityLoadFailure(): void { $bundles, $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $destination->setEntity(FALSE); $this->expectException(MigrateException::class); @@ -95,7 +98,8 @@ public function testUntranslatable(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support translations.'); diff --git a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php index 0b7c220dcdddc74abf428053fd4bc0263b943066..610f5dbb5bf5f75618a43da0a4b4e5fff6947381 100644 --- a/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/Plugin/migrate/destination/EntityRevisionTest.php @@ -5,6 +5,7 @@ namespace Drupal\Tests\migrate\Unit\Plugin\migrate\destination; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Session\AccountSwitcherInterface; @@ -57,7 +58,8 @@ public function testNoRevisionSupport(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support revisions.'); @@ -86,7 +88,8 @@ public function testUntranslatable(): void { [], $this->entityFieldManager->reveal(), $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(), - $this->prophesize(AccountSwitcherInterface::class)->reveal() + $this->prophesize(AccountSwitcherInterface::class)->reveal(), + $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(), ); $this->expectException(MigrateException::class); $this->expectExceptionMessage('The "foo" entity type does not support translations.'); diff --git a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php index 9883ceb413f07066b8769bc05c7fd085d39ebf0e..5c2258df3d8a938f131495aa5f556a308c0f55ec 100644 --- a/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php +++ b/core/modules/migrate/tests/src/Unit/destination/EntityRevisionTest.php @@ -7,6 +7,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Entity\RevisionableStorageInterface; @@ -52,6 +53,11 @@ class EntityRevisionTest extends UnitTestCase { */ protected AccountSwitcherInterface $accountSwitcher; + /** + * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface + */ + protected EntityTypeBundleInfoInterface $entityTypeBundle; + /** * {@inheritdoc} */ @@ -72,6 +78,7 @@ protected function setUp(): void { $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class)->reveal(); $this->fieldTypeManager = $this->prophesize(FieldTypePluginManagerInterface::class)->reveal(); $this->accountSwitcher = $this->prophesize(AccountSwitcherInterface::class)->reveal(); + $this->entityTypeBundle = $this->prophesize(EntityTypeBundleInfoInterface::class)->reveal(); } /** @@ -199,6 +206,7 @@ protected function getEntityRevisionDestination(array $configuration = [], $plug $this->entityFieldManager, $this->fieldTypeManager, $this->accountSwitcher, + $this->entityTypeBundle, ); } diff --git a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php index 52c679d8a3e60ba9129097521328e288caa3a95a..29b2985ffc255dc2295513b8e9afac9282c42431 100644 --- a/core/modules/user/src/Plugin/migrate/destination/EntityUser.php +++ b/core/modules/user/src/Plugin/migrate/destination/EntityUser.php @@ -5,6 +5,7 @@ use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityFieldManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\Plugin\Field\FieldType\EmailItem; use Drupal\Core\Password\PasswordInterface; @@ -96,9 +97,11 @@ class EntityUser extends EntityContentBase { * The password service. * @param \Drupal\Core\Session\AccountSwitcherInterface|null $account_switcher * The account switcher service. + * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface|null $entity_type_bundle_info + * The entity type bundle info service. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password, ?AccountSwitcherInterface $account_switcher = NULL) { - parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher); + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityFieldManagerInterface $entity_field_manager, FieldTypePluginManagerInterface $field_type_manager, PasswordInterface $password, ?AccountSwitcherInterface $account_switcher = NULL, ?EntityTypeBundleInfoInterface $entity_type_bundle_info = NULL) { + parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_field_manager, $field_type_manager, $account_switcher, $entity_type_bundle_info); $this->password = $password; } @@ -117,7 +120,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('entity_field.manager'), $container->get('plugin.manager.field.field_type'), $container->get('password'), - $container->get('account_switcher') + $container->get('account_switcher'), + $container->get('entity_type.bundle.info'), ); }