diff --git a/commerce_migrate.services.yml b/commerce_migrate.services.yml index 5c53503..e728d95 100644 --- a/commerce_migrate.services.yml +++ b/commerce_migrate.services.yml @@ -7,8 +7,3 @@ services: class: Drupal\commerce_migrate\EventSubscriber\MigrateOrderItem tags: - { name: event_subscriber } - commerce_migrate.migrate_tax_type: - class: Drupal\commerce_migrate\EventSubscriber\MigrateTaxType - arguments: [ '@uuid' ] - tags: - - { name: event_subscriber } diff --git a/modules/ubercart/migration_templates/d6_ubercart_tax.yml b/modules/ubercart/migration_templates/d6_ubercart_tax.yml index fbca6fb..95cf3a0 100644 --- a/modules/ubercart/migration_templates/d6_ubercart_tax.yml +++ b/modules/ubercart/migration_templates/d6_ubercart_tax.yml @@ -21,6 +21,7 @@ process: length: 32 label: name 'plugin': 'constants/plugin' + 'configuration/rates/0/id': '@id' 'configuration/rates/0/label': name 'configuration/rates/0/amount': rate destination: diff --git a/src/EventSubscriber/MigrateTaxType.php b/src/EventSubscriber/MigrateTaxType.php deleted file mode 100644 index 8059f64..0000000 --- a/src/EventSubscriber/MigrateTaxType.php +++ /dev/null @@ -1,64 +0,0 @@ -uuidGenerator = $uuid_generator; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() { - $events[MigrateEvents::POST_ROW_SAVE][] = 'postRowSave'; - return $events; - } - - /** - * Reacts to the POST_ROW_SAVE event. - * - * @param \Drupal\migrate\Event\MigratePostRowSaveEvent $event - * The event. - */ - public function postRowSave(MigratePostRowSaveEvent $event) { - $destination_config = $event->getMigration()->getDestinationConfiguration(); - - // If the destination is a tax type we need to give its rate a uuid for its - // id. - if ($destination_config['plugin'] == 'entity:commerce_tax_type') { - $tax_type = TaxType::load($event->getRow()->getDestinationProperty('id')); - $configuration = $tax_type->getPluginConfiguration(); - - // Add a uuid as the rate's id if the id hasn't already been defined. - if (!empty($configuration['rates'])) { - foreach ($configuration['rates'] as &$rate) { - if (empty($rate['id'])) { - $rate['id'] = $this->uuidGenerator->generate(); - } - } - - $tax_type->setPluginConfiguration($configuration); - $tax_type->save(); - } - } - } - -} diff --git a/tests/src/Kernel/CommerceMigrateTestTrait.php b/tests/src/Kernel/CommerceMigrateTestTrait.php index c53e4b2..7ad72e7 100644 --- a/tests/src/Kernel/CommerceMigrateTestTrait.php +++ b/tests/src/Kernel/CommerceMigrateTestTrait.php @@ -335,7 +335,7 @@ trait CommerceMigrateTestTrait { $this->assertSame($expected_plugin, $tax->getPluginId()); $tax_config = $tax->getPluginConfiguration(); - $this->assertNotEmpty($tax_config['rates'][0]['id']); + $this->assertSame($id, $tax_config['rates'][0]['id']); $this->assertSame($expected_label, $tax_config['rates'][0]['label']); $this->assertSame($rate, $tax_config['rates'][0]['amount']); }