diff --git a/core/modules/content_translation/migrations/d6_custom_block_translation.yml b/core/modules/content_translation/migrations/d6_custom_block_translation.yml index bbe7833a67..1b4f9b87c4 100644 --- a/core/modules/content_translation/migrations/d6_custom_block_translation.yml +++ b/core/modules/content_translation/migrations/d6_custom_block_translation.yml @@ -4,27 +4,35 @@ migration_tags: - Drupal 6 source: plugin: d6_box_translation - constants: - type: basic process: id: - plugin: migration + plugin: migration_lookup migration: d6_custom_block source: - bid langcode: language info: - plugin: i18n_translation - source: - - title_untranslated - - title_translated + - + plugin: callback + source: + - title_translated + - title_untranslated + callable: array_filter + - + plugin: callback + callable: reset 'body/value': - plugin: i18n_translation - source: - - body_untranslated - - body_translated + - + plugin: callback + source: + - body_translated + - body_untranslated + callable: array_filter + - + plugin: callback + callable: reset 'body/format': - plugin: migration + plugin: migration_lookup migration: d6_filter_format source: format destination: diff --git a/core/modules/content_translation/src/Plugin/migrate/process/d6/i18nTranslation.php b/core/modules/content_translation/src/Plugin/migrate/process/d6/i18nTranslation.php deleted file mode 100644 index 08a3e0546e..0000000000 --- a/core/modules/content_translation/src/Plugin/migrate/process/d6/i18nTranslation.php +++ /dev/null @@ -1,51 +0,0 @@ -getDatabase()->schema()->tableExists('i18n_strings')) && - $this->getDatabase()->schema()->tableExists('locales_target')) { + $schema = $this->getDatabase()->schema(); + if ($schema->tableExists('i18n_strings') && $schema->tableExists('locales_target')) { // Build a query based on 18n_strings table where each row has the // translation for only one property, either title or description. The - // method prepareRow() is then used to obtain the translation for the other - // property. + // method prepareRow() is then used to obtain the translation for the + // other property. $query = $this->select('boxes', 'b') ->fields('b', ['bid', 'body', 'info', 'format']) ->fields('i18n', ['lid', 'property']) @@ -62,16 +61,16 @@ public function prepareRow(Row $row) { $row->setSourceProperty($property . '_translated', $row->getSourceProperty('translation')); // Get the translation for the property not already in the row. - $property2 = ($property == 'title') ? 'body' : 'title'; + $translation = ($property == 'title') ? 'body' : 'title'; $query = $this->select('i18n_strings', 'i18n') ->fields('i18n', ['lid']) - ->condition('i18n.property', $property2) + ->condition('i18n.property', $translation) ->condition('i18n.objectid', $bid); $query->leftJoin('locales_target', 'lt', 'i18n.lid = lt.lid'); $query->condition('lt.language', $language) ->addField('lt', 'translation'); $results = $query->execute()->fetchAssoc(); - $row->setSourceProperty($property2 . '_translated', $results['translation']); + $row->setSourceProperty($translation . '_translated', $results['translation']); } /**