diff --git a/core/modules/field/migration_templates/d7_field_formatter_settings.yml b/core/modules/field/migration_templates/d7_field_formatter_settings.yml index 75355df6a01cc557458bf367e11b8032e382f024..14cdd661ab3a142094a4aea20cd660aedce42a8b 100644 --- a/core/modules/field/migration_templates/d7_field_formatter_settings.yml +++ b/core/modules/field/migration_templates/d7_field_formatter_settings.yml @@ -51,7 +51,7 @@ process: - plugin: static_map bypass: true - source: type + source: formatter_type map: date_default: datetime_default email_default: email_mailto diff --git a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php index 17d4e183c390c39627addb17816ca332808fe85a..72a845bcaf0cd8bc60b5f8f046ac64f1ad44480b 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php @@ -24,8 +24,15 @@ protected function initializeIterator() { $data = unserialize($field_instance['data']); // We don't need to include the serialized data in the returned rows. unset($field_instance['data']); + foreach ($data['display'] as $view_mode => $info) { - $rows[] = array_merge($field_instance, $info, array('view_mode' => $view_mode)); + // Rename type to formatter_type in the info array. + $info['formatter_type'] = $info['type']; + unset($info['type']); + + $rows[] = array_merge($field_instance, $info, [ + 'view_mode' => $view_mode, + ]); } } return new \ArrayIterator($rows); @@ -35,8 +42,11 @@ protected function initializeIterator() { * {@inheritdoc} */ public function query() { - return $this->select('field_config_instance', 'fci') - ->fields('fci', array('entity_type', 'bundle', 'field_name', 'data')); + $query = $this->select('field_config_instance', 'fci') + ->fields('fci', ['entity_type', 'bundle', 'field_name', 'data']) + ->fields('fc', ['type']); + $query->join('field_config', 'fc', 'fc.field_name = fci.field_name'); + return $query; } /** @@ -49,7 +59,8 @@ public function fields() { 'field_name' => $this->t('Machine name of the field.'), 'view_mode' => $this->t('The original machine name of the view mode.'), 'label' => $this->t('The display label of the field.'), - 'type' => $this->t('The formatter ID.'), + 'type' => $this->t('The field ID.'), + 'formatter_type' => $this->t('The formatter ID.'), 'settings' => $this->t('Array of formatter-specific settings.'), 'module' => $this->t('The module providing the formatter.'), 'weight' => $this->t('Display weight of the field.'), diff --git a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php index 6ed72e43c8e0ee9b049a3647488851cd44e8cf2e..ff5993e6231ce4ce48ca23bf7cfde5f1045b5bfd 100644 --- a/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php +++ b/core/modules/field/tests/src/Kernel/Plugin/migrate/source/d7/FieldInstancePerViewModeTest.php @@ -41,6 +41,24 @@ public function providerSource() { ], ]; + $tests[0]['source_data']['field_config'] = [ + [ + 'id' => '2', + 'field_name' => 'body', + 'type' => 'text_with_summary', + 'module' => 'text', + 'active' => '1', + 'storage_type' => 'field_sql_storage', + 'storage_module' => 'field_sql_storage', + 'storage_active' => '1', + 'locked' => '0', + 'data' => 'a:7:{s:12:"entity_types";a:1:{i:0;s:4:"node";}s:7:"indexes";a:1:{s:6:"format";a:1:{i:0;s:6:"format";}}s:8:"settings";a:0:{}s:12:"translatable";i:0;s:12:"foreign keys";a:1:{s:6:"format";a:2:{s:5:"table";s:13:"filter_format";s:7:"columns";a:1:{s:6:"format";s:6:"format";}}}s:7:"storage";a:4:{s:4:"type";s:17:"field_sql_storage";s:8:"settings";a:0:{}s:6:"module";s:17:"field_sql_storage";s:6:"active";s:1:"1";}s:2:"id";s:2:"25";}', + 'cardinality' => '1', + 'translatable' => '0', + 'deleted' => '0', + ], + ]; + // The expected results. $tests[0]['expected_data'] = [ [ @@ -48,7 +66,8 @@ public function providerSource() { 'bundle' => 'page', 'field_name' => 'body', 'label' => 'hidden', - 'type' => 'text_default', + 'type' => 'text_with_summary', + 'formatter_type' => 'text_default', 'settings' => [], 'module' => 'text', 'weight' => 0, @@ -59,7 +78,8 @@ public function providerSource() { 'bundle' => 'page', 'field_name' => 'body', 'label' => 'hidden', - 'type' => 'text_summary_or_trimmed', + 'type' => 'text_with_summary', + 'formatter_type' => 'text_summary_or_trimmed', 'settings' => [ 'trim_length' => 600, ],