diff --git a/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php index af6229aeee..efcd7fc38c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php +++ b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php @@ -42,7 +42,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/datetime/src/Plugin/migrate/field/DateField.php b/core/modules/datetime/src/Plugin/migrate/field/DateField.php index a503fbbe6a..fb393d7615 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/DateField.php @@ -35,7 +35,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { switch ($data['type']) { case 'date': $from_format = 'Y-m-d\TH:i:s'; diff --git a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php index 4e7cd881d3..7ea04b9de6 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php @@ -40,7 +40,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { switch ($data['type']) { case 'date': $from_format = 'Y-m-d\TH:i:s'; diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php new file mode 100644 index 0000000000..94d16df09b --- /dev/null +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldLegacyTest.php @@ -0,0 +1,18 @@ +migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); - $this->plugin = new DateField([], '', []); + public function testUnknownDateType($method = 'defineValueProcessPipeline') { + $migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); + $plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); - $this->plugin->processFieldValues($this->migration, 'field_date', ['type' => 'timestamp']); + $plugin->$method($migration, 'field_date', ['type' => 'timestamp']); } } diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php new file mode 100644 index 0000000000..cec4025c23 --- /dev/null +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldLegacyTest.php @@ -0,0 +1,18 @@ +migration = $this->prophesize(MigrationInterface::class)->reveal(); + } /** * Tests an Exception is thrown when the field type is not a known date type. + * + * @expectedDeprecation DateField is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\datetime\Plugin\migrate\field\DateField instead. */ - public function testUnknownDateType() { - $this->migration = $this->prophesize('Drupal\migrate\Plugin\MigrationInterface')->reveal(); - $this->plugin = new DateField([], '', []); + public function testUnknownDateType($method = 'defineValueProcessPipeline') { + $plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); - $this->plugin->processFieldValues($this->migration, 'field_date', ['type' => 'timestamp']); + $plugin->$method($this->migration, 'field_date', ['type' => 'timestamp']); } } diff --git a/core/modules/field/migrations/d6_field.yml b/core/modules/field/migrations/d6_field.yml index 92c28b203c..b387d1fe58 100644 --- a/core/modules/field/migrations/d6_field.yml +++ b/core/modules/field/migrations/d6_field.yml @@ -3,7 +3,7 @@ label: Field configuration migration_tags: - Drupal 6 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processField +field_plugin_method: alterFieldMigration source: plugin: d6_field constants: diff --git a/core/modules/field/migrations/d6_field_formatter_settings.yml b/core/modules/field/migrations/d6_field_formatter_settings.yml index fc97ad0225..8a2406052e 100644 --- a/core/modules/field/migrations/d6_field_formatter_settings.yml +++ b/core/modules/field/migrations/d6_field_formatter_settings.yml @@ -3,7 +3,7 @@ label: Field formatter configuration migration_tags: - Drupal 6 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldFormatter +field_plugin_method: alterFieldFormatterMigration source: plugin: d6_field_instance_per_view_mode constants: diff --git a/core/modules/field/migrations/d6_field_instance.yml b/core/modules/field/migrations/d6_field_instance.yml index 3a413c14f3..9a99a7a14a 100644 --- a/core/modules/field/migrations/d6_field_instance.yml +++ b/core/modules/field/migrations/d6_field_instance.yml @@ -3,7 +3,7 @@ label: Field instance configuration migration_tags: - Drupal 6 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldInstance +field_plugin_method: alterFieldInstanceMigration source: plugin: d6_field_instance constants: diff --git a/core/modules/field/migrations/d6_field_instance_widget_settings.yml b/core/modules/field/migrations/d6_field_instance_widget_settings.yml index b5f6f6d680..a5b05543c9 100644 --- a/core/modules/field/migrations/d6_field_instance_widget_settings.yml +++ b/core/modules/field/migrations/d6_field_instance_widget_settings.yml @@ -3,7 +3,7 @@ label: Field instance widget configuration migration_tags: - Drupal 6 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldWidget +field_plugin_method: alterFieldWidgetMigration source: plugin: d6_field_instance_per_form_display constants: diff --git a/core/modules/field/migrations/d7_field.yml b/core/modules/field/migrations/d7_field.yml index 1fa00699f9..5c8028e91e 100644 --- a/core/modules/field/migrations/d7_field.yml +++ b/core/modules/field/migrations/d7_field.yml @@ -3,7 +3,7 @@ label: Field configuration migration_tags: - Drupal 7 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processField +field_plugin_method: alterFieldMigration source: plugin: d7_field constants: diff --git a/core/modules/field/migrations/d7_field_formatter_settings.yml b/core/modules/field/migrations/d7_field_formatter_settings.yml index 5c9335ca86..5f98f636df 100644 --- a/core/modules/field/migrations/d7_field_formatter_settings.yml +++ b/core/modules/field/migrations/d7_field_formatter_settings.yml @@ -3,7 +3,7 @@ label: Field formatter configuration migration_tags: - Drupal 7 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldFormatter +field_plugin_method: alterFieldFormatterMigration source: plugin: d7_field_instance_per_view_mode constants: diff --git a/core/modules/field/migrations/d7_field_instance.yml b/core/modules/field/migrations/d7_field_instance.yml index 4e1901dc4a..fbd338ec6e 100644 --- a/core/modules/field/migrations/d7_field_instance.yml +++ b/core/modules/field/migrations/d7_field_instance.yml @@ -3,7 +3,7 @@ label: Field instance configuration migration_tags: - Drupal 7 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldInstance +field_plugin_method: alterFieldInstanceMigration source: plugin: d7_field_instance constants: diff --git a/core/modules/field/migrations/d7_field_instance_widget_settings.yml b/core/modules/field/migrations/d7_field_instance_widget_settings.yml index ac281e1707..10d70a7d59 100644 --- a/core/modules/field/migrations/d7_field_instance_widget_settings.yml +++ b/core/modules/field/migrations/d7_field_instance_widget_settings.yml @@ -3,7 +3,7 @@ label: Field instance widget configuration migration_tags: - Drupal 7 class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration -field_plugin_method: processFieldWidget +field_plugin_method: alterFieldWidgetMigration source: plugin: d7_field_instance_per_form_display constants: diff --git a/core/modules/file/src/Plugin/migrate/field/d6/FileField.php b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php index 87c3bfe7ac..d532ccbe2b 100644 --- a/core/modules/file/src/Plugin/migrate/field/d6/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php @@ -42,7 +42,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'd6_field_file', 'source' => $field_name, 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 8157def995..8ca9450742 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php @@ -18,7 +18,7 @@ class FileField extends D6FileField { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php index ea2005e1c2..6d2b861051 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php @@ -18,7 +18,7 @@ class ImageField extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php index 6a393df54b..eb5fe0610f 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d6/FileCckTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php index 414d9c21d9..c9e4f6f627 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/FileCckTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php index 2175c64215..b20d3d0f41 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/cckfield/d7/ImageCckTest.php @@ -32,7 +32,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php new file mode 100644 index 0000000000..4eebf3cf3d --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldLegacyTest.php @@ -0,0 +1,19 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'd6_field_file', diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php new file mode 100644 index 0000000000..3e706b7864 --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldLegacyTest.php @@ -0,0 +1,19 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php new file mode 100644 index 0000000000..591d4dcd1e --- /dev/null +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -43,10 +43,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php index f902987c67..1a823f5506 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php @@ -29,8 +29,8 @@ class LinkField extends CckFieldPluginBase { * {@inheritdoc} */ public function getFieldFormatterMap() { - // See d6_field_formatter_settings.yml and CckFieldPluginBase - // processFieldFormatter(). + // See d6_field_formatter_settings.yml and FieldPluginBase + // alterFieldFormatterMigration(). return [ 'default' => 'link', 'plain' => 'link', 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 c4f09f25e5..a796409662 100644 --- a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php @@ -38,9 +38,9 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @inheritdoc} */ - public function processFieldInstance(MigrationInterface $migration) { + public function alterFieldInstanceMigration(MigrationInterface $migration) { $process = [ 'plugin' => 'static_map', 'source' => 'settings/title', diff --git a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php index 547e49201f..7c6fe3b600 100644 --- a/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php @@ -23,7 +23,7 @@ class LinkField extends FieldPluginBase { */ public function getFieldFormatterMap() { // See d6_field_formatter_settings.yml and FieldPluginBase - // processFieldFormatter(). + // alterFieldFormatterMigration(). return [ 'default' => 'link', 'plain' => 'link', @@ -39,7 +39,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'field_link', 'source' => $field_name, diff --git a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php index 0dcf4c64c5..4b16ed2668 100644 --- a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -33,7 +33,7 @@ public function getFieldWidgetMap() { /** * {@inheritdoc} */ - public function processFieldInstance(MigrationInterface $migration) { + public function alterFieldInstanceMigration(MigrationInterface $migration) { $process = [ 'plugin' => 'static_map', 'source' => 'settings/title', diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php new file mode 100644 index 0000000000..da4b5ceb6f --- /dev/null +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckDeprecationTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldInstance() method will call + // The plugin's alterFieldInstanceMigration() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -52,12 +52,10 @@ protected function setUp() { } /** - * @covers ::processCckFieldValues - * @expectedDeprecation CckFieldPluginBase is deprecated in Drupal 8.3.x and will be be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase instead. - * @expectedDeprecation MigrateCckFieldInterface is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateField instead. + * @covers ::alterFieldInstanceMigration */ - public function testProcessCckFieldValues() { - $this->plugin->processFieldInstance($this->migration); + public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') { + $this->plugin->$method($this->migration); $expected = [ 'plugin' => 'static_map', diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php new file mode 100644 index 0000000000..7ab9907e66 --- /dev/null +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's ProcessFieldInstance() method will call + // The plugin's alterFieldInstanceMigration() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -51,10 +51,10 @@ protected function setUp() { } /** - * @covers ::processFieldInstance + * @covers ::alterFieldInstanceMigration */ - public function testProcessFieldInstance() { - $this->plugin->processFieldInstance($this->migration); + public function testAlterFieldInstanceMigration($method = 'alterFieldInstanceMigration') { + $this->plugin->$method($this->migration); $expected = [ 'plugin' => 'static_map', diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php new file mode 100644 index 0000000000..6fda4c0829 --- /dev/null +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // mergeProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to mergeProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'field_link', diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php index 2aac5d18eb..96ed53e5c4 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php @@ -17,7 +17,7 @@ * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processField(MigrationInterface $migration); + public function alterFieldMigration(MigrationInterface $migration); /** * Apply any custom processing to the field instance migration. @@ -25,7 +25,7 @@ public function processField(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldInstance(MigrationInterface $migration); + public function alterFieldInstanceMigration(MigrationInterface $migration); /** * Apply any custom processing to the field widget migration. @@ -33,7 +33,7 @@ public function processFieldInstance(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldWidget(MigrationInterface $migration); + public function alterFieldWidgetMigration(MigrationInterface $migration); /** * Apply any custom processing to the field formatter migration. @@ -41,7 +41,7 @@ public function processFieldWidget(MigrationInterface $migration); * @param \Drupal\migrate\Plugin\MigrationInterface $migration * The migration entity. */ - public function processFieldFormatter(MigrationInterface $migration); + public function alterFieldFormatterMigration(MigrationInterface $migration); /** * Get the field formatter type from the source. @@ -57,7 +57,7 @@ public function getFieldFormatterType(Row $row); /** * Get a map between D6 formatters and D8 formatters for this field type. * - * This is used by static::processFieldFormatter() in the base class. + * This is used by static::alterFieldFormatterMigration() in the base class. * * @return array * The keys are D6 formatters and the values are D8 formatters. @@ -93,7 +93,7 @@ public function getFieldWidgetMap(); * @param array $data * The array of field data from FieldValues::fieldData(). */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data); + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data); /** * Computes the destination type of a migrated field. 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 220c8bbd6c..80ad6fa507 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php @@ -21,16 +21,9 @@ abstract class CckFieldPluginBase extends FieldPluginBase implements MigrateCckFieldInterface { /** - * Apply any custom processing to the field bundle migrations. - * - * @param \Drupal\migrate\Plugin\MigrationInterface $migration - * The migration entity. - * @param string $field_name - * The field name we're processing the value for. - * @param array $data - * The array of field data from FieldValues::fieldData(). + * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { // Provide a bridge to the old method declared on the interface and now an // abstract method in this class. return $this->processCckFieldValues($migration, $field_name, $data); diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php index dc115abc99..b7b9485f99 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php @@ -20,24 +20,63 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface { /** - * {@inheritdoc} + * Alters the migration for field definitions. + * + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldMigration() instead. + * + * @see ::alterFieldMigration() */ public function processField(MigrationInterface $migration) { + @trigger_error('Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use alterFieldMigration() instead.', E_USER_DEPRECATED); + $this->alterFieldMigration($migration); + } + + /** + * {@inheritdoc} + */ + public function alterFieldMigration(MigrationInterface $migration) { $process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId; $migration->mergeProcessOfProperty('type', $process); } /** - * {@inheritdoc} + * Alert field instance migration. + * + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldInstanceMigration() instead. + * + * @see ::alterFieldInstanceMigration() */ public function processFieldInstance(MigrationInterface $migration) { - // Nothing to do by default with field instances. + @trigger_error('Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use alterFieldInstanceMigration() instead.', E_USER_DEPRECATED); + $this->alterFieldInstanceMigration($migration); } /** * {@inheritdoc} */ + public function alterFieldInstanceMigration(MigrationInterface $migration) { + // Nothing to do by default with field instances. + } + + /** + * Alter field widget migration. + * + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldWidgetMigration() instead. + * + * @see ::alterFieldWidgetMigration() + */ public function processFieldWidget(MigrationInterface $migration) { + @trigger_error('Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use alterFieldWidgetMigration() instead.', E_USER_DEPRECATED); + $this->alterFieldWidgetMigration($migration); + } + + /** + * {@inheritdoc} + */ + public function alterFieldWidgetMigration(MigrationInterface $migration) { $process = []; foreach ($this->getFieldWidgetMap() as $source_widget => $destination_widget) { $process['type']['map'][$source_widget] = $destination_widget; @@ -77,11 +116,23 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * Alter field formatter migration. + * + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldFormatterMigration() instead. + * + * @see ::processFieldFormatter() */ public function processFieldFormatter(MigrationInterface $migration) { - $process = []; + @trigger_error('Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use alterFieldFormatterMigration() instead.', E_USER_DEPRECATED); + $this->alterFieldFormatterMigration($migration); + } + /** + * {@inheritdoc} + */ + public function alterFieldFormatterMigration(MigrationInterface $migration) { + $process = []; // Some migrate field plugin IDs are prefixed with 'd6_' or 'd7_'. Since the // plugin ID is used in the static map as the module name, we have to remove // this prefix from the plugin ID. @@ -93,9 +144,22 @@ public function processFieldFormatter(MigrationInterface $migration) { } /** - * {@inheritdoc} + * Defines the process pipeline for field values. + * + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. + * + * @see ::defineValueProcessPipeline() */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + @trigger_error('Deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use defineValueProcessPipeline() instead.', E_USER_DEPRECATED); + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'get', 'source' => $field_name, diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php index e8c2dd5e6d..403464304e 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php @@ -20,7 +20,7 @@ class NodeReference extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php index b42d94cba3..4a60f450de 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php @@ -20,7 +20,7 @@ class UserReference extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php index 536303e956..94c759bea4 100644 --- a/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D6NodeDeriver.php @@ -165,7 +165,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 6], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php index 28c61b8340..25099cf178 100644 --- a/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php +++ b/core/modules/node/src/Plugin/migrate/D7NodeDeriver.php @@ -168,7 +168,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 7], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php index 561a9afe80..566cf3b3da 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php +++ b/core/modules/taxonomy/src/Plugin/migrate/D7TaxonomyTermDeriver.php @@ -137,7 +137,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($plugin_id, ['core' => 7], $migration); } $this->fieldPluginCache[$field_type] - ->processFieldValues($migration, $field_name, $info); + ->defineValueProcessPipeline($migration, $field_name, $info); } catch (PluginNotFoundException $ex) { try { diff --git a/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php index 2f41e51a7c..08e1df1dcc 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php +++ b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php @@ -21,7 +21,7 @@ class TaxonomyTermReference extends FieldPluginBase { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) { $process = [ 'plugin' => 'sub_process', 'source' => $field_name, diff --git a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php new file mode 100644 index 0000000000..a17aff758e --- /dev/null +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckLegacyTest.php @@ -0,0 +1,18 @@ +migration = $migration->reveal(); } + public function testProcessCckFieldValues() { + $this->testDefineValueProcessPipeline('processCckFieldValues'); + } + /** - * @covers ::processCckFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessCckFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', diff --git a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php new file mode 100644 index 0000000000..e2660fe85f --- /dev/null +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldLegacyTest.php @@ -0,0 +1,18 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -44,10 +44,10 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFieldValues() { - $this->plugin->processFieldValues($this->migration, 'somefieldname', []); + public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') { + $this->plugin->$method($this->migration, 'somefieldname', []); $expected = [ 'plugin' => 'sub_process', 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 aa324b6f77..dba6398a06 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -44,7 +44,7 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processFieldValues(MigrationInterface $migration, $field_name, $field_info) { + public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $field_info) { $widget_type = isset($field_info['widget_type']) ? $field_info['widget_type'] : $field_info['widget']['type']; if ($widget_type == 'optionwidgets_onoff') { diff --git a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php index 8bf5d2a2d0..be90e169fb 100644 --- a/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php +++ b/core/modules/text/tests/src/Unit/Migrate/d6/TextFieldTest.php @@ -33,7 +33,7 @@ protected function setUp() { $migration = $this->prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -46,7 +46,11 @@ protected function setUp() { } /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testFilteredTextValueProcessPipeline */ public function testProcessFilteredTextFieldValues() { $field_info = [ @@ -69,7 +73,34 @@ public function testProcessFilteredTextFieldValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testFilteredTextValueProcessPipeline() { + $field_info = [ + 'widget_type' => 'text_textfield', + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'body', $field_info); + + $process = $this->migration->getProcess(); + $this->assertSame('sub_process', $process['plugin']); + $this->assertSame('body', $process['source']); + $this->assertSame('value', $process['process']['value']); + + // Ensure that filter format IDs will be looked up in the filter format + // migrations. + $lookup = $process['process']['format'][2]; + $this->assertSame('migration', $lookup['plugin']); + $this->assertContains('d6_filter_format', $lookup['migration']); + $this->assertContains('d7_filter_format', $lookup['migration']); + $this->assertSame('format', $lookup['source']); + } + + /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testBooleanTextImplicitValueProcessPipeline */ public function testProcessBooleanTextImplicitValues() { $info = [ @@ -94,7 +125,36 @@ public function testProcessBooleanTextImplicitValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testBooleanTextImplicitValueProcessPipeline() { + $info = [ + 'widget_type' => 'optionwidgets_onoff', + 'global_settings' => [ + 'allowed_values' => "foo\nbar", + ] + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'field', $info); + + $expected = [ + 'value' => [ + 'plugin' => 'static_map', + 'source' => 'value', + 'default_value' => 0, + 'map' => [ + 'bar' => 1, + ], + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()['process']); + } + + /** + * Calls the deprecated processFieldValues() method to test BC. + * * @covers ::processFieldValues + * + * @depends testBooleanTextExplicitValueProcessPipeline */ public function testProcessBooleanTextExplicitValues() { $info = [ @@ -119,6 +179,31 @@ public function testProcessBooleanTextExplicitValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testBooleanTextExplicitValueProcessPipeline() { + $info = [ + 'widget_type' => 'optionwidgets_onoff', + 'global_settings' => [ + 'allowed_values' => "foo|Foo\nbaz|Baz", + ] + ]; + $this->plugin->defineValueProcessPipeline($this->migration, 'field', $info); + + $expected = [ + 'value' => [ + 'plugin' => 'static_map', + 'source' => 'value', + 'default_value' => 0, + 'map' => [ + 'baz' => 1, + ], + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()['process']); + } + + /** * Data provider for testGetFieldType(). */ public function getFieldTypeProvider() { diff --git a/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php new file mode 100644 index 0000000000..1859cbf3bb --- /dev/null +++ b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldLegacyTest.php @@ -0,0 +1,36 @@ +prophesize(MigrationInterface::class); - // The plugin's processFieldValues() method will call + // The plugin's defineValueProcessPipeline() method will call // setProcessOfProperty() and return nothing. So, in order to examine the // process pipeline created by the plugin, we need to ensure that // getProcess() always returns the last input to setProcessOfProperty(). @@ -45,13 +45,13 @@ protected function setUp() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessFilteredTextFieldValues() { + public function testProcessFilteredTextFieldValues($method = 'defineValueProcessPipeline') { $field_info = [ 'widget_type' => 'text_textfield', ]; - $this->plugin->processFieldValues($this->migration, 'body', $field_info); + $this->plugin->$method($this->migration, 'body', $field_info); $process = $this->migration->getProcess(); $this->assertSame('sub_process', $process['plugin']); @@ -68,16 +68,16 @@ public function testProcessFilteredTextFieldValues() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessBooleanTextImplicitValues() { + public function testProcessBooleanTextImplicitValues($method = 'defineValueProcessPipeline') { $info = [ 'widget_type' => 'optionwidgets_onoff', 'global_settings' => [ 'allowed_values' => "foo\nbar", ] ]; - $this->plugin->processFieldValues($this->migration, 'field', $info); + $this->plugin->$method($this->migration, 'field', $info); $expected = [ 'value' => [ @@ -93,16 +93,16 @@ public function testProcessBooleanTextImplicitValues() { } /** - * @covers ::processFieldValues + * @covers ::defineValueProcessPipeline */ - public function testProcessBooleanTextExplicitValues() { + public function testProcessBooleanTextExplicitValues($method = 'defineValueProcessPipeline') { $info = [ 'widget_type' => 'optionwidgets_onoff', 'global_settings' => [ 'allowed_values' => "foo|Foo\nbaz|Baz", ] ]; - $this->plugin->processFieldValues($this->migration, 'field', $info); + $this->plugin->$method($this->migration, 'field', $info); $expected = [ 'value' => [ diff --git a/core/modules/user/src/Plugin/migrate/User.php b/core/modules/user/src/Plugin/migrate/User.php index 5316259abd..d918932ddc 100644 --- a/core/modules/user/src/Plugin/migrate/User.php +++ b/core/modules/user/src/Plugin/migrate/User.php @@ -37,7 +37,7 @@ public function getProcess() { } $info = $row->getSource(); $this->fieldPluginCache[$field_type] - ->processFieldValues($this, $field_name, $info); + ->defineValueProcessPipeline($this, $field_name, $info); } else { if ($this->cckPluginManager->hasDefinition($field_type)) {