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 af6229a..d34a0e6 100644 --- a/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php +++ b/core/lib/Drupal/Core/Field/Plugin/migrate/field/Email.php @@ -40,9 +40,17 @@ public function getFieldFormatterMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 a503fbb..82b0c11 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/DateField.php @@ -33,9 +33,17 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 4e7cd88..2c1d25e 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php @@ -38,9 +38,17 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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/DateFieldTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php index 6b7f137..794d788 100644 --- a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/DateFieldTest.php @@ -29,6 +29,10 @@ public function testUnknownDateType() { $this->plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); + $this->plugin->defineValueProcessPipeline($this->migration, 'field_date', ['type' => 'timestamp']); + + // Retain backwards compatibility testing. + $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']); } diff --git a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php index 7e67881..056e0fe 100644 --- a/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php +++ b/core/modules/datetime/tests/src/Unit/Plugin/migrate/field/d6/DateFieldTest.php @@ -30,6 +30,10 @@ public function testUnknownDateType() { $this->plugin = new DateField([], '', []); $this->setExpectedException(MigrateException::class, "Field field_date of type 'timestamp' is an unknown date field type."); + $this->plugin->defineValueProcessPipeline($this->migration, 'field_date', ['type' => 'timestamp']); + + // Retain backwards compatibility testing. + $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']); } diff --git a/core/modules/field/migrations/d6_field.yml b/core/modules/field/migrations/d6_field.yml index 92c28b2..b387d1f 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 fc97ad0..8a24060 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 3a413c1..9a99a7a 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 b5f6f6d..a5b0554 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 1fa0069..5c8028e 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 5c9335c..5f98f63 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 4e1901d..fbd338e 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 ac281e1..10d70a7 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 87c3bfe..2cb8d7c 100644 --- a/core/modules/file/src/Plugin/migrate/field/d6/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php @@ -40,9 +40,17 @@ public function getFieldFormatterMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 8157def..72000c1 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php @@ -16,9 +16,17 @@ class FileField extends D6FileField { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 ea2005e..6cbd157 100644 --- a/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php @@ -16,9 +16,17 @@ class ImageField extends FieldPluginBase { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 6a393df..eb5fe06 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 414d9c2..c9e4f6f 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 2175c64..b20d3d0 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/FileFieldTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldTest.php index 70f6d60..937cd7d 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d6/FileFieldTest.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(). @@ -57,6 +57,19 @@ public function testProcessFieldValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'd6_field_file', + 'source' => 'somefieldname', + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + + /** * Data provider for testGetFieldType(). */ public function getFieldTypeProvider() { diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldTest.php index 36ca6a4..1e1ad76 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/FileFieldTest.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(). @@ -62,6 +62,24 @@ public function testProcessFieldValues() { } /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'iterator', + 'source' => 'somefieldname', + 'process' => [ + 'target_id' => 'fid', + 'display' => 'display', + 'description' => 'description', + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + + /** * Data provider for testGetFieldType(). */ public function getFieldTypeProvider() { diff --git a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php index 3cab353..0d96a9e 100644 --- a/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php +++ b/core/modules/file/tests/src/Unit/Plugin/migrate/field/d7/ImageFieldTest.php @@ -31,7 +31,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(). @@ -62,4 +62,24 @@ public function testProcessFieldValues() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'iterator', + 'source' => 'somefieldname', + 'process' => [ + 'target_id' => 'fid', + 'alt' => 'alt', + 'title' => 'title', + 'width' => 'width', + 'height' => 'height', + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } diff --git a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php b/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php index f902987..1a823f5 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 c4f09f2..802bf9a 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,14 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldInstanceMigration() instead. */ public function processFieldInstance(MigrationInterface $migration) { + $this->alterFieldInstanceMigration($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 547e492..a948ef8 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', @@ -37,9 +37,17 @@ public function getFieldFormatterMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 0dcf4c6..317d3c1 100644 --- a/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -31,9 +31,14 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldInstanceMigration() instead. */ public function processFieldInstance(MigrationInterface $migration) { + $this->alterFieldInstanceMigration($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/LinkCckTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php index 14345a6..9268c2e 100644 --- a/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/cckfield/d7/LinkCckTest.php @@ -39,7 +39,7 @@ protected function setUp() { $migration = $this->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(). @@ -72,4 +72,23 @@ public function testProcessCckFieldValues() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::alterFieldInstanceMigration + */ + public function testAlterFieldInstanceMigration() { + $this->plugin->alterFieldInstanceMigration($this->migration); + + $expected = [ + 'plugin' => 'static_map', + 'source' => 'settings/title', + 'bypass' => TRUE, + 'map' => [ + 'disabled' => DRUPAL_DISABLED, + 'optional' => DRUPAL_OPTIONAL, + 'required' => DRUPAL_REQUIRED, + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } diff --git a/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldTest.php b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldTest.php index 494aa02..10ce553 100644 --- a/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldTest.php +++ b/core/modules/link/tests/src/Kernel/Plugin/migrate/field/d7/LinkFieldTest.php @@ -38,7 +38,7 @@ protected function setUp() { $migration = $this->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(). @@ -69,4 +69,23 @@ public function testProcessFieldInstance() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::alterFieldInstanceMigration + */ + public function testAlterFieldInstanceMigration() { + $this->plugin->alterFieldInstanceMigration($this->migration); + + $expected = [ + 'plugin' => 'static_map', + 'source' => 'settings/title', + 'bypass' => TRUE, + 'map' => [ + 'disabled' => DRUPAL_DISABLED, + 'optional' => DRUPAL_OPTIONAL, + 'required' => DRUPAL_REQUIRED, + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } diff --git a/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldTest.php b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldTest.php index 0dbc741..013062b 100644 --- a/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldTest.php +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/field/d6/LinkFieldTest.php @@ -31,7 +31,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(). @@ -56,4 +56,17 @@ public function testProcessFieldValues() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'field_link', + 'source' => 'somefieldname', + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php index 2aac5d1..96ed53e 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 220c8bb..104c137 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php @@ -21,6 +21,14 @@ abstract class CckFieldPluginBase extends FieldPluginBase implements MigrateCckFieldInterface { /** + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** * Apply any custom processing to the field bundle migrations. * * @param \Drupal\migrate\Plugin\MigrationInterface $migration @@ -30,7 +38,7 @@ * @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) { // 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 dc115ab..ba89e12 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,39 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldMigration() instead. */ public function processField(MigrationInterface $migration) { + $this->alterFieldMigration($migration); + } + + public function alterFieldMigration(MigrationInterface $migration) { $process[0]['map'][$this->pluginId][$this->pluginId] = $this->pluginId; $migration->mergeProcessOfProperty('type', $process); } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldInstanceMigration() instead. */ public function processFieldInstance(MigrationInterface $migration) { + $this->alterFieldInstanceMigration($migration); + } + + public function alterFieldInstanceMigration(MigrationInterface $migration) { // Nothing to do by default with field instances. } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldWidgetMigration() instead. */ public function processFieldWidget(MigrationInterface $migration) { + $this->alterFieldWidgetMigration($migration); + } + + public function alterFieldWidgetMigration(MigrationInterface $migration) { $process = []; foreach ($this->getFieldWidgetMap() as $source_widget => $destination_widget) { $process['type']['map'][$source_widget] = $destination_widget; @@ -77,9 +92,14 @@ public function getFieldWidgetMap() { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * alterFieldFormatterMigration() instead. */ public function processFieldFormatter(MigrationInterface $migration) { + $this->alterFieldFormatterMigration($migration); + } + + public function alterFieldFormatterMigration(MigrationInterface $migration) { $process = []; // Some migrate field plugin IDs are prefixed with 'd6_' or 'd7_'. Since the @@ -93,9 +113,17 @@ public function processFieldFormatter(MigrationInterface $migration) { } /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + 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 e8c2dd5..6183958 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php @@ -18,9 +18,17 @@ class NodeReference extends FieldPluginBase { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 b42d94c..d2d1593 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php @@ -18,9 +18,17 @@ class UserReference extends FieldPluginBase { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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 536303e..94c759b 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 28c61b8..25099cf 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 561a9af..566cf3b 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 2f41e51..1febdd8 100644 --- a/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php +++ b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php @@ -19,9 +19,17 @@ class TaxonomyTermReference extends FieldPluginBase { /** - * {@inheritdoc} + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. */ public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** + * {@inheritdoc} + */ + 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/TaxonomyTermReferenceCckTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckTest.php index 437fd67..24df65d 100644 --- a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckTest.php +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/cckfield/TaxonomyTermReferenceCckTest.php @@ -48,6 +48,22 @@ protected function setUp() { * @covers ::processCckFieldValues */ public function testProcessCckFieldValues() { + $this->plugin->processCckFieldValues($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'iterator', + 'source' => 'somefieldname', + 'process' => [ + 'target_id' => 'tid', + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + + /** + * @covers ::processFieldValues + */ + public function testProcessFieldValues() { $this->plugin->processFieldValues($this->migration, 'somefieldname', []); $expected = [ @@ -60,4 +76,20 @@ public function testProcessCckFieldValues() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'iterator', + 'source' => 'somefieldname', + 'process' => [ + 'target_id' => 'tid', + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } diff --git a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldTest.php b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldTest.php index 8422293..31ff5df 100644 --- a/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldTest.php +++ b/core/modules/taxonomy/tests/src/Unit/Plugin/migrate/field/TaxonomyTermReferenceFieldTest.php @@ -31,7 +31,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(). @@ -59,4 +59,20 @@ public function testProcessFieldValues() { $this->assertSame($expected, $this->migration->getProcess()); } + /** + * @covers ::defineValueProcessPipeline + */ + public function testDefineValueProcessPipeline() { + $this->plugin->defineValueProcessPipeline($this->migration, 'somefieldname', []); + + $expected = [ + 'plugin' => 'iterator', + 'source' => 'somefieldname', + 'process' => [ + 'target_id' => 'tid', + ], + ]; + $this->assertSame($expected, $this->migration->getProcess()); + } + } 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 aa324b6..82396ab 100644 --- a/core/modules/text/src/Plugin/migrate/field/d6/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/d6/TextField.php @@ -42,9 +42,17 @@ public function getFieldFormatterMap() { } /** + * @deprecated in Drupal 8.5.x, to be removed before Drupal 9.0.x. Use + * defineValueProcessPipeline() instead. + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + return $this->defineValueProcessPipeline($migration, $field_name, $data); + } + + /** * {@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 8bf5d2a..c032b56 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(). @@ -69,6 +69,29 @@ 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('iterator', $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']); + } + + /** * @covers ::processFieldValues */ public function testProcessBooleanTextImplicitValues() { @@ -94,6 +117,31 @@ 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']); + } + + /** * @covers ::processFieldValues */ public function testProcessBooleanTextExplicitValues() { @@ -119,6 +167,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/TextFieldTest.php b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php index b79a0b5..44acade 100644 --- a/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.php +++ b/core/modules/text/tests/src/Unit/Plugin/migrate/field/d6/TextFieldTest.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 // 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(). @@ -68,6 +68,29 @@ 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('iterator', $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']); + } + + /** * @covers ::processFieldValues */ public function testProcessBooleanTextImplicitValues() { @@ -93,6 +116,31 @@ 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']); + } + + /** * @covers ::processFieldValues */ public function testProcessBooleanTextExplicitValues() { @@ -118,6 +166,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/user/src/Plugin/migrate/User.php b/core/modules/user/src/Plugin/migrate/User.php index 5316259..d918932 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)) {