diff -u b/core/modules/block_content/migration_templates/d6_custom_block.yml b/core/modules/block_content/migration_templates/d6_custom_block.yml --- b/core/modules/block_content/migration_templates/d6_custom_block.yml +++ b/core/modules/block_content/migration_templates/d6_custom_block.yml @@ -14,7 +14,7 @@ 'body/value': body destination: plugin: entity:block_content - bundle: basic + default_bundle: basic no_stub: true migration_dependencies: required: diff -u b/core/modules/block_content/migration_templates/d7_custom_block.yml b/core/modules/block_content/migration_templates/d7_custom_block.yml --- b/core/modules/block_content/migration_templates/d7_custom_block.yml +++ b/core/modules/block_content/migration_templates/d7_custom_block.yml @@ -14,7 +14,7 @@ 'body/value': body destination: plugin: entity:block_content - bundle: basic + default_bundle: basic no_stub: true migration_dependencies: required: diff -u b/core/modules/menu_link_content/migration_templates/menu_links.yml b/core/modules/menu_link_content/migration_templates/menu_links.yml --- b/core/modules/menu_link_content/migration_templates/menu_links.yml +++ b/core/modules/menu_link_content/migration_templates/menu_links.yml @@ -46,7 +46,7 @@ changed: updated destination: plugin: entity:menu_link_content - bundle: menu_link_content + default_bundle: menu_link_content no_stub: true migration_dependencies: required: diff -u b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php --- b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -89,13 +89,20 @@ } /** - * Finds the entity bundle from configuration. + * Set the default entity bundle from configuration. * - * @return string - * The entity bundle - empty string if the bundle was omitted. + * @param \Drupal\migrate\Row $row + * The row object. */ - protected function getEntityBundleId() { - return isset($this->configuration['bundle']) ? $this->configuration['bundle'] : ''; + protected function getBundle(Row $row) { + $default_bundle = isset($this->configuration['default_bundle']) ? $this->configuration['default_bundle'] : ''; + if ($default_bundle) { + $bundle_key = $this->getKey('bundle'); + // Apply the default bundle if the bundle has not already been set. + if (empty($row->getDestinationProperty($bundle_key))) { + $row->setDestinationProperty($bundle_key, $default_bundle); + } + } } /** @@ -122,11 +129,7 @@ $this->updateEntity($entity, $row); } else { - $bundle_key = $this->getKey('bundle'); - // Apply any configured bundle if the bundle has not already been set. - if (($bundle = $this->getEntityBundleId()) && empty($row->getDestinationProperty($bundle_key))) { - $row->setDestinationProperty($bundle_key, $bundle); - } + $this->getBundle($row); // Stubs might need some required fields filled in. if ($row->isStub()) { diff -u b/core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php b/core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php --- b/core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php +++ b/core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php @@ -18,7 +18,7 @@ * * @var array */ - public static $modules = ['field', 'taxonomy', 'text']; + public static $modules = ['taxonomy', 'text']; /** * {@inheritdoc} @@ -55,7 +55,7 @@ ], 'destination' => [ 'plugin' => 'entity:taxonomy_term', - 'bundle' => 'categories', + 'default_bundle' => 'categories', ], 'migration_dependencies' => [], ]; @@ -135,7 +135,7 @@ 'destination' => [ 'plugin' => 'entity:taxonomy_term', // When no vocab is provided, the destination bundle is applied. - 'bundle' => 'tags', + 'default_bundle' => 'tags', ], 'migration_dependencies' => [], ]; diff -u b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php --- b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php @@ -98,7 +98,7 @@ '@type' => $node_type, ]); $values['source']['node_type'] = $node_type; - $values['destination']['bundle'] = $node_type; + $values['destination']['default_bundle'] = $node_type; // If this migration is based on the d6_node_revision migration, it // should explicitly depend on the corresponding d6_node variant. diff -u b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php --- b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php @@ -92,7 +92,7 @@ '@type' => $row->getSourceProperty('name'), ]); $values['source']['node_type'] = $node_type; - $values['destination']['bundle'] = $node_type; + $values['destination']['default_bundle'] = $node_type; $migration = \Drupal::service('plugin.manager.migration')->createStubMigration($values); if (isset($fields[$node_type])) {