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 ee07ec4..3a6c7e1 100644 --- a/core/modules/field/migration_templates/d7_field_formatter_settings.yml +++ b/core/modules/field/migration_templates/d7_field_formatter_settings.yml @@ -4,6 +4,7 @@ migration_tags: - Drupal 7 class: Drupal\migrate_drupal\Plugin\migrate\CckMigration cck_plugin_method: processFieldFormatter +cck_plugin_field_type_property_name: field_type source: plugin: d7_field_instance_per_view_mode constants: 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 b586f3a..1fd2616 100644 --- a/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php +++ b/core/modules/field/src/Plugin/migrate/source/d7/FieldInstancePerViewMode.php @@ -25,7 +25,10 @@ protected function initializeIterator() { // 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), array('field_type' => $field_instance['type'])); + $rows[] = array_merge($field_instance, $info, [ + 'view_mode' => $view_mode, + 'field_type' => $field_instance['type'] + ]); } } return new \ArrayIterator($rows); @@ -52,6 +55,7 @@ public function fields() { '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.'), + 'field_type' => $this->t('The type of this field.'), '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/migrate_drupal/src/Plugin/migrate/CckMigration.php b/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php index 3c31870..11c40b1 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php @@ -28,7 +28,7 @@ class CckMigration extends Migration implements ContainerFactoryPluginInterface * * @var string[] */ - protected $processedSourcePlugins = []; + protected $processedFieldTypes = []; /** * Already-instantiated cckfield plugins, keyed by ID. @@ -104,17 +104,20 @@ public function getProcess() { $source_plugin = []; } } + + $field_type_property_name = !empty($this->pluginDefinition['cck_plugin_field_type_property_name']) ? + $this->pluginDefinition['cck_plugin_field_type_property_name'] : + 'type'; foreach ($source_plugin as $row) { - $plugin_name = $row->getSourceProperty('type'); - $field_type = $row->getSourceProperty('field_type') ?: $plugin_name; - if (!isset($this->processedSourcePlugins[$plugin_name]) && $this->cckPluginManager->hasDefinition($field_type)) { - $this->processedSourcePlugins[$plugin_name] = TRUE; + $field_type = $row->getSourceProperty($field_type_property_name); + if (!isset($this->processedFieldTypes[$field_type]) && $this->cckPluginManager->hasDefinition($field_type)) { + $this->processedFieldTypes[$field_type] = TRUE; // Allow the cckfield plugin to alter the migration as necessary so // that it knows how to handle fields of this type. if (!isset($this->cckPluginCache[$field_type])) { $this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this); - call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this); } + call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this); } } } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php index 44f30a1..29eff21 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php @@ -61,7 +61,6 @@ public function getFieldWidgetMap() { public function processFieldFormatter(MigrationInterface $migration) { $process = []; foreach ($this->getFieldFormatterMap() as $source_format => $destination_format) { - //$process[0]['map'][$this->pluginId][$source_format] = $destination_format; $process[0]['map'][$source_format] = $destination_format; } $migration->mergeProcessOfProperty('options/type', $process); diff --git a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php index 5f44ded..cc4c1ec 100644 --- a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php +++ b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php @@ -35,7 +35,7 @@ public function getFieldFormatterMap() { return [ 'default' => 'text_default', 'trimmed' => 'text_trimmed', - 'text_plain' => 'basic_string', + 'plain' => 'basic_string', ]; }