diff --git a/core/modules/file/src/Plugin/migrate/cckfield/d6/FileField.php b/core/modules/file/src/Plugin/migrate/cckfield/d6/FileField.php index ea794c9..f326104 100644 --- a/core/modules/file/src/Plugin/migrate/cckfield/d6/FileField.php +++ b/core/modules/file/src/Plugin/migrate/cckfield/d6/FileField.php @@ -17,7 +17,7 @@ * ) * * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use - * \Drupal\file\Plugin\migrate\process\d6\FieldFile instead. + * \Drupal\file\Plugin\migrate\field\d6\FileField instead. */ class FileField extends CckFieldPluginBase { diff --git a/core/modules/file/src/Plugin/migrate/cckfield/d7/FileField.php b/core/modules/file/src/Plugin/migrate/cckfield/d7/FileField.php index 8967b53..99633d1 100644 --- a/core/modules/file/src/Plugin/migrate/cckfield/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/cckfield/d7/FileField.php @@ -17,7 +17,7 @@ * ) * * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use - * \Drupal\file\Plugin\migrate\process\d7\FieldFile instead. + * \Drupal\file\Plugin\migrate\field\d7\FileField instead. */ class FileField extends CckFieldPluginBase { diff --git a/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php b/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php index fdbfad1..999d203 100644 --- a/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php +++ b/core/modules/file/src/Plugin/migrate/cckfield/d7/ImageField.php @@ -16,7 +16,7 @@ * ) * * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use - * \Drupal\file\Plugin\migrate\process\d7\ImageField instead. + * \Drupal\file\Plugin\migrate\field\d7\ImageField instead. */ class ImageField extends CckFieldPluginBase { diff --git a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php index 8430c8b..4243d43 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php @@ -2,9 +2,8 @@ namespace Drupal\file\Plugin\migrate\field\d7; +use Drupal\file\Plugin\migrate\field\d6\FileField as D6FileField; use Drupal\migrate\Plugin\MigrationInterface; -use Drupal\migrate\Row; -use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase; /** * @MigrateField( @@ -12,30 +11,7 @@ * core = {7} * ) */ -class FileField extends FieldPluginBase { - - /** - * {@inheritdoc} - */ - public function getFieldWidgetMap() { - return [ - 'filefield_widget' => 'file_generic', - ]; - } - - /** - * {@inheritdoc} - */ - public function getFieldFormatterMap() { - return [ - 'default' => 'file_default', - 'url_plain' => 'file_url_plain', - 'path_plain' => 'file_url_plain', - 'image_plain' => 'image', - 'image_nodelink' => 'image', - 'image_imagelink' => 'image', - ]; - } +class FileField extends D6FileField { /** * {@inheritdoc} @@ -53,11 +29,4 @@ public function processFieldValues(MigrationInterface $migration, $field_name, $ $migration->mergeProcessOfProperty($field_name, $process); } - /** - * {@inheritdoc} - */ - public function getFieldType(Row $row) { - return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file'; - } - } diff --git a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php index 0ce3618..b12d0a3 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php @@ -3,7 +3,7 @@ namespace Drupal\link\Plugin\migrate\cckfield; @trigger_error('LinkField is deprecated in Drupal 8.4.x and will be -be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d7\FileField +be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\LinkField instead.', E_USER_DEPRECATED); use Drupal\migrate\Plugin\MigrationInterface; @@ -19,7 +19,7 @@ * ) * * @deprecated in Drupal 8.4.x and will be removed in Drupal 9.0.x. Use - * \Drupal\link\Plugin\migrate\field\d7\FileField instead. + * \Drupal\link\Plugin\migrate\field\d6\LinkField instead. */ class LinkField extends CckFieldPluginBase { diff --git a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php index 482b167..89ace8d 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php @@ -3,7 +3,7 @@ namespace Drupal\link\Plugin\migrate\cckfield\d7; @trigger_error('LinkField is deprecated in Drupal 8.4.x and will be -be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d6\FileField +be removed before Drupal 9.0.x. Use \Drupal\link\Plugin\migrate\field\d7\LinkField instead.', E_USER_DEPRECATED); use Drupal\link\Plugin\migrate\cckfield\LinkField as D6LinkField; @@ -21,6 +21,9 @@ * This plugin provides the exact same functionality as the Drupal 6 "link" * plugin with the exception that the plugin ID "link_field" is used in the * field type map. + * + * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use + * \Drupal\link\Plugin\migrate\field\d7\LinkField instead. */ class LinkField extends D6LinkField { diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php index 6065157..2b33c85 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php @@ -7,7 +7,7 @@ use Drupal\migrate\Plugin\MigrationInterface; /** - * Plugin manager for migrate cckfield plugins. + * Plugin manager for migrate field plugins. * * @see \Drupal\migrate_drupal\Plugin\MigrateFieldInterface * @see \Drupal\migrate\Annotation\MigrateField 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 79a65a7..cc394d7 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php @@ -12,7 +12,7 @@ /** * The base class for all field plugins. * - * @deprecated in Drupal 8.3.x, to be removed before Drupal 9.0.x. Use + * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use * \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead. * * @ingroup migration diff --git a/core/modules/migrate_drupal/tests/modules/migrate_field_plugin_manager_test/migrate_field_plugin_manager_test.module b/core/modules/migrate_drupal/tests/modules/migrate_field_plugin_manager_test/migrate_field_plugin_manager_test.module index 9f9da0d..eec16ef 100644 --- a/core/modules/migrate_drupal/tests/modules/migrate_field_plugin_manager_test/migrate_field_plugin_manager_test.module +++ b/core/modules/migrate_drupal/tests/modules/migrate_field_plugin_manager_test/migrate_field_plugin_manager_test.module @@ -5,10 +5,10 @@ * Module for Migrate Field Plugin Manager testing. */ -use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6\FileField; +use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\field\D6FileField; function migrate_field_plugin_manager_test_migrate_field_info_alter(array &$definitions) { if (isset($definitions['filefield'])) { - $definitions['filefield']['class'] = FileField::class; + $definitions['filefield']['class'] = D6FileField::class; } } diff --git a/core/modules/migrate_drupal/tests/src/Kernel/CckFieldBackwardsCompatibilityTest.php b/core/modules/migrate_drupal/tests/src/Kernel/CckFieldBackwardsCompatibilityTest.php index 11dceec..bb314b4 100644 --- a/core/modules/migrate_drupal/tests/src/Kernel/CckFieldBackwardsCompatibilityTest.php +++ b/core/modules/migrate_drupal/tests/src/Kernel/CckFieldBackwardsCompatibilityTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\migrate_drupal\Kernel; -use Drupal\migrate_field_plugin_manager_test\Plugin\migrate\cckfield\d6\FileField; +use Drupal\migrate_cckfield_plugin_manager_test\Plugin\migrate\cckfield\D6FileField; use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase; /** @@ -13,7 +13,7 @@ class CckFieldBackwardsCompatibilityTest extends MigrateDrupal6TestBase { /** * {@inheritdoc} */ - public static $modules = ['file', 'migrate_field_plugin_manager_test']; + public static $modules = ['file', 'migrate_cckfield_plugin_manager_test']; /** * Ensures that the cckfield backwards compatibility layer is invoked. @@ -23,7 +23,7 @@ public function testBackwardsCompatibility() { ->get('plugin.manager.migration') ->getDefinition('d6_node:story'); - $this->assertSame(FileField::class, $migration['process']['field_test_filefield']['class']); + $this->assertSame(D6FileField::class, $migration['process']['field_test_filefield']['class']); } } diff --git a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php index 90780fb..6f4c11b 100644 --- a/core/modules/text/src/Plugin/migrate/cckfield/TextField.php +++ b/core/modules/text/src/Plugin/migrate/cckfield/TextField.php @@ -3,8 +3,8 @@ namespace Drupal\text\Plugin\migrate\cckfield; @trigger_error('TextField is deprecated in Drupal 8.4.x and will be removed -before Drupal 9.0.x. Use \Drupal\text\Plugin\migrate\field\TextField -instead.', E_USER_DEPRECATED); +before Drupal 9.0.x. Use \Drupal\text\Plugin\migrate\field\d6\TextField or +\Drupal\text\Plugin\migrate\field\d7\TextField instead.', E_USER_DEPRECATED); use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Row; @@ -22,7 +22,8 @@ * ) * * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use - * \Drupal\text\Plugin\migrate\field\TextField instead. + * \Drupal\text\Plugin\migrate\field\d6\TextField or + * \Drupal\text\Plugin\migrate\field\d7\TextField instead. */ class TextField extends CckFieldPluginBase { diff --git a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php index dabaa72..b18b383 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -1,6 +1,6 @@ 'text_textfield', - ]; - } - - /** - * {@inheritdoc} - */ - public function getFieldFormatterMap() { - return [ - 'default' => 'text_default', - 'trimmed' => 'text_trimmed', - 'plain' => 'basic_string', - ]; - } - - /** - * {@inheritdoc} - */ - public function processFieldValues(MigrationInterface $migration, $field_name, $field_info) { - if ($field_info['widget_type'] == 'optionwidgets_onoff') { - $process = [ - 'value' => [ - 'plugin' => 'static_map', - 'source' => 'value', - 'default_value' => 0, - ], - ]; - - $checked_value = explode("\n", $field_info['global_settings']['allowed_values'])[1]; - if (strpos($checked_value, '|') !== FALSE) { - $checked_value = substr($checked_value, 0, strpos($checked_value, '|')); - } - $process['value']['map'][$checked_value] = 1; - } - else { - // See \Drupal\migrate_drupal\Plugin\migrate\source\d6\User::baseFields(), - // signature_format for an example of the YAML that represents this - // process array. - $process = [ - 'value' => 'value', - 'format' => [ - [ - 'plugin' => 'static_map', - 'bypass' => TRUE, - 'source' => 'format', - 'map' => [0 => NULL], - ], - [ - 'plugin' => 'skip_on_empty', - 'method' => 'process', - ], - [ - 'plugin' => 'migration', - 'migration' => [ - 'd6_filter_format', - 'd7_filter_format', - ], - 'source' => 'format', - ], - ], - ]; - } - - $process = [ - 'plugin' => 'iterator', - 'source' => $field_name, - 'process' => $process, - ]; - $migration->setProcessOfProperty($field_name, $process); - } - - /** - * {@inheritdoc} - */ - public function getFieldType(Row $row) { - $widget_type = $row->getSourceProperty('widget_type'); - $settings = $row->getSourceProperty('global_settings'); - - if ($widget_type == 'text_textfield') { - $field_type = $settings['text_processing'] ? 'text' : 'string'; - if (empty($settings['max_length']) || $settings['max_length'] > 255) { - $field_type .= '_long'; - } - return $field_type; - } - - if ($widget_type == 'text_textarea') { - $field_type = $settings['text_processing'] ? 'text_long' : 'string_long'; - return $field_type; - } - - switch ($widget_type) { - case 'optionwidgets_buttons': - case 'optionwidgets_select': - return 'list_string'; - case 'optionwidgets_onoff': - return 'boolean'; - default: - return parent::getFieldType($row); - } - } - -} +class TextField extends D6TextField {}