diff --git a/core/modules/migrate_drupal/migration_templates/d6_field_formatter_settings.yml b/core/modules/migrate_drupal/migration_templates/d6_field_formatter_settings.yml index ba39824d2c58dae2fcc950f4b9d7db2fdb66cd96..425e7d4f0c689a6a4e36dc0ecd589810b631761e 100644 --- a/core/modules/migrate_drupal/migration_templates/d6_field_formatter_settings.yml +++ b/core/modules/migrate_drupal/migration_templates/d6_field_formatter_settings.yml @@ -52,10 +52,6 @@ process: - type - 'display_settings/format' map: - text: - default: text_default - trimmed: text_trimmed - plain: basic_string number_integer: default: number_integer us_0: number_integer diff --git a/core/modules/migrate_drupal/migration_templates/d6_field_instance_widget_settings.yml b/core/modules/migrate_drupal/migration_templates/d6_field_instance_widget_settings.yml index ed0acdbbba917382252b8d0cdbd512c4185e6a41..3299d5c8637e14808b6ecb55d2f65b23056a500d 100644 --- a/core/modules/migrate_drupal/migration_templates/d6_field_instance_widget_settings.yml +++ b/core/modules/migrate_drupal/migration_templates/d6_field_instance_widget_settings.yml @@ -36,7 +36,6 @@ process: bypass: true source: widget_type map: - text_textfield: text_textfield number: number email_textfield: email_default date_select: datetime_default diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/TextField.php b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/TextField.php new file mode 100644 index 0000000000000000000000000000000000000000..268ea606cde9a5f714b0ec31080fcda1fe7214c3 --- /dev/null +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/TextField.php @@ -0,0 +1,71 @@ +<?php + +/** + * @file + * Contains \Drupal\migrate_drupal\Plugin\migrate\cckfield\TextField. + */ + +namespace Drupal\migrate_drupal\Plugin\migrate\cckfield; + +use Drupal\migrate\Entity\MigrationInterface; + +/** + * @PluginID("text") + */ +class TextField extends CckFieldPluginBase { + + /** + * {@inheritdoc} + */ + public function getFieldWidgetMap() { + return [ + 'text_textfield' => 'text_textfield', + ]; + } + + /** + * {@inheritdoc} + */ + public function getFieldFormatterMap() { + return [ + 'default' => 'text_default', + 'trimmed' => 'text_trimmed', + 'plain' => 'basic_string', + ]; + } + + /** + * {@inheritdoc} + */ + public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) { + // The data is stored differently depending on whether we're using + // db storage. + $value_key = $data['db_storage'] ? $field_name : "$field_name/value"; + $format_key = $data['db_storage'] ? $field_name . '_format' : "$field_name/format" ; + + $migration->setProcessOfProperty("$field_name/value", $value_key); + + // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(), + // signature_format for an example of the YAML that represents this + // process array. + $process = [ + [ + 'plugin' => 'static_map', + 'bypass' => TRUE, + 'source' => $format_key, + 'map' => [0 => NULL] + ], + [ + 'plugin' => 'skip_on_empty', + 'method' => 'process', + ], + [ + 'plugin' => 'migration', + 'migration' => 'd6_filter_format', + 'source' => $format_key, + ], + ]; + $migration->mergeProcessOfProperty("$field_name/format", $process); + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php index 14a2c9b6ee5f4149135bac804ea0adf3765a8bbb..9edbcd075d79e46b6f43fe2830b84cc4d713b28d 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/load/LoadEntity.php @@ -87,13 +87,7 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N if ($source_plugin instanceof CckFieldMigrateSourceInterface) { foreach ($source_plugin->fieldData() as $field_name => $data) { - switch ($data['type']) { - case 'text': - $this->processTextField($field_name, $data, $migration); - break; - default: - $migration->setProcessOfProperty($field_name, $field_name); - } + $migration->setProcessOfProperty($field_name, $field_name); } } else { @@ -110,45 +104,4 @@ public function loadMultiple(EntityStorageInterface $storage, array $sub_ids = N return $migrations; } - /** - * Manipulate text fields with any per field type processing. - * - * @param string $field_name - * The field we're processing. - * @param array $field_data - * The an array of field type data from the source. - * @param \Drupal\migrate\Entity\MigrationInterface $migration - * The migration entity. - */ - protected function processTextField($field_name, $field_data, MigrationInterface $migration) { - // The data is stored differently depending on whether we're using - // db storage. - $value_key = $field_data['db_storage'] ? $field_name : "$field_name/value"; - $format_key = $field_data['db_storage'] ? $field_name . '_format' : "$field_name/format" ; - - $migration->setProcessOfProperty("$field_name/value", $value_key); - - // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(), - // signature_format for an example of the YAML that represents this - // process array. - $process = [ - [ - 'plugin' => 'static_map', - 'bypass' => TRUE, - 'source' => $format_key, - 'map' => [0 => NULL] - ], - [ - 'plugin' => 'skip_on_empty', - 'method' => 'process', - ], - [ - 'plugin' => 'migration', - 'migration' => 'd6_filter_format', - 'source' => $format_key, - ], - ]; - $migration->mergeProcessOfProperty("$field_name/format", $process); - } - }