diff --git a/core/modules/block_content/migration_templates/d6_custom_block.yml b/core/modules/block_content/migration_templates/d6_custom_block.yml index be99072..f1f58a1 100644 --- a/core/modules/block_content/migration_templates/d6_custom_block.yml +++ b/core/modules/block_content/migration_templates/d6_custom_block.yml @@ -4,11 +4,8 @@ migration_tags: - Drupal 6 source: plugin: d6_box - constants: - type: basic process: id: bid - type: 'constants/type' info: info 'body/format': plugin: migration @@ -17,6 +14,7 @@ process: 'body/value': body destination: plugin: entity:block_content + bundle: basic no_stub: true migration_dependencies: required: diff --git a/core/modules/block_content/migration_templates/d7_custom_block.yml b/core/modules/block_content/migration_templates/d7_custom_block.yml index f63ca93..f5c9a97 100644 --- a/core/modules/block_content/migration_templates/d7_custom_block.yml +++ b/core/modules/block_content/migration_templates/d7_custom_block.yml @@ -4,11 +4,8 @@ migration_tags: - Drupal 7 source: plugin: d7_block_custom - constants: - type: basic process: id: bid - type: 'constants/type' info: info 'body/format': plugin: migration @@ -17,6 +14,7 @@ process: 'body/value': body destination: plugin: entity:block_content + bundle: basic no_stub: true migration_dependencies: required: diff --git a/core/modules/menu_link_content/migration_templates/menu_links.yml b/core/modules/menu_link_content/migration_templates/menu_links.yml index 7b818c6..1bf95f4 100644 --- a/core/modules/menu_link_content/migration_templates/menu_links.yml +++ b/core/modules/menu_link_content/migration_templates/menu_links.yml @@ -5,11 +5,8 @@ migration_tags: - Drupal 7 source: plugin: menu_link - constants: - bundle: menu_link_content process: id: mlid - bundle: 'constants/bundle' title: link_title description: description menu_name: @@ -49,6 +46,7 @@ process: changed: updated destination: plugin: entity:menu_link_content + bundle: menu_link_content no_stub: true migration_dependencies: required: diff --git a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php index 55c59fc..207c208 100644 --- a/core/modules/migrate/src/Plugin/migrate/destination/Entity.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/Entity.php @@ -6,6 +6,7 @@ use Drupal\Core\Entity\DependencyTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Drupal\migrate\MigrateException; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -82,6 +83,8 @@ public static function create(ContainerInterface $container, array $configuratio * * @return string * The entity type. + * + * @throws \Drupal\migrate\MigrateException */ protected static function getEntityTypeId($plugin_id) { // Remove "entity:". @@ -89,6 +92,16 @@ protected static function getEntityTypeId($plugin_id) { } /** + * Finds the entity bundle from configuration. + * + * @return string + * The entity bundle - empty string if the bundle was omitted. + */ + protected function getEntityBundleId() { + return isset($this->configuration['bundle']) ? $this->configuration['bundle'] : ''; + } + + /** * {@inheritdoc} */ public function fields(MigrationInterface $migration = NULL) { @@ -112,6 +125,10 @@ protected function getEntity(Row $row, array $old_destination_id_values) { $this->updateEntity($entity, $row); } else { + if ($bundle = $this->getEntityBundleId()) { + $row->setDestinationProperty($this->getKey('bundle'), $bundle); + } + // Stubs might need some required fields filled in. if ($row->isStub()) { $this->processStubRow($row);