Commit 14a769b7 authored by catch's avatar catch

Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn, quietone: Fix...

Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn, quietone: Fix sub-optimal DX in MigrateFieldInterface
parent 163144a9
......@@ -46,7 +46,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,
......
......@@ -35,7 +35,7 @@ public function getProcess() {
$this->fieldPluginCache[$field_type] = $this->fieldPluginManager->createInstance($field_type, [], $this);
}
$info = $row->getSource();
$this->fieldPluginCache[$field_type]->processFieldValues($this, $field_name, $info);
$this->fieldPluginCache[$field_type]->defineValueProcessPipeline($this, $field_name, $info);
}
else {
$this->setProcessOfProperty($field_name, $field_name);
......
......@@ -44,7 +44,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';
......
......@@ -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';
......
<?php
namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field;
/**
* @group migrate
* @group legacy
*/
class DateFieldLegacyTest extends DateFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testUnknownDateType($method = 'processFieldValues') {
parent::testUnknownDateType($method);
}
}
......@@ -11,25 +11,15 @@
*/
class DateFieldTest extends UnitTestCase {
/**
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
*/
protected $plugin;
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $migration;
/**
* Tests an Exception is thrown when the field type is not a known date type.
*/
public function testUnknownDateType() {
$this->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']);
}
}
<?php
namespace Drupal\Tests\datetime\Unit\Plugin\migrate\field\d6;
/**
* @group migrate
* @group legacy
*/
class DateFieldLegacyTest extends DateFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testUnknownDateType($method = 'processFieldValues') {
parent::testUnknownDateType($method);
}
}
......@@ -4,6 +4,7 @@
use Drupal\datetime\Plugin\migrate\field\d6\DateField;
use Drupal\migrate\MigrateException;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\Tests\UnitTestCase;
/**
......@@ -13,26 +14,28 @@
class DateFieldTest extends UnitTestCase {
/**
* @var \Drupal\migrate_drupal\Plugin\MigrateFieldInterface
* @var \Drupal\migrate\Plugin\MigrationInterface
*/
protected $plugin;
protected $migration;
/**
* @var \Drupal\migrate\Plugin\MigrationInterface
* {@inheritdoc}
*/
protected $migration;
protected function setUp() {
parent::setUp();
$this->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']);
}
}
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 6
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processField
field_plugin_method: alterFieldMigration
source:
plugin: d6_field
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 6
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldFormatter
field_plugin_method: alterFieldFormatterMigration
source:
plugin: d6_field_instance_per_view_mode
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 6
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldInstance
field_plugin_method: alterFieldInstanceMigration
source:
plugin: d6_field_instance
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 6
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldWidget
field_plugin_method: alterFieldWidgetMigration
source:
plugin: d6_field_instance_per_form_display
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 7
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processField
field_plugin_method: alterFieldMigration
source:
plugin: d7_field
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 7
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldFormatter
field_plugin_method: alterFieldFormatterMigration
source:
plugin: d7_field_instance_per_view_mode
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 7
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldInstance
field_plugin_method: alterFieldInstanceMigration
source:
plugin: d7_field_instance
constants:
......
......@@ -4,7 +4,7 @@ migration_tags:
- Drupal 7
- Configuration
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
field_plugin_method: processFieldWidget
field_plugin_method: alterFieldWidgetMigration
source:
plugin: d7_field_instance_per_form_display
constants:
......
......@@ -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,
......
......@@ -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,
......
......@@ -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().
......
......@@ -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().
......
......@@ -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().
......
<?php
namespace Drupal\Tests\file\Unit\Plugin\migrate\field\d6;
/**
* @coversDefaultClass \Drupal\file\Plugin\migrate\field\d6\FileField
* @group legacy
* @group file
*/
class FileFieldLegacyTest extends FileFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testDefineValueProcessPipeline($method = 'processFieldValues') {
parent::testDefineValueProcessPipeline($method);
}
}
......@@ -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().
......@@ -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',
......
<?php
namespace Drupal\Tests\file\Unit\Plugin\migrate\field\d7;
/**
* @coversDefaultClass \Drupal\file\Plugin\migrate\field\d7\FileField
* @group legacy
* @group file
*/
class FileFieldLegacyTest extends FileFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testDefineValueProcessPipeline($method = 'processFieldValues') {
parent::testDefineValueProcessPipeline($method);
}
}
......@@ -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().
......@@ -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',
......
<?php
namespace Drupal\Tests\file\Unit\Plugin\migrate\field\d7;
/**
* @group legacy
* @group file
*/
class ImageFieldLegacyTest extends ImageFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testDefineValueProcessPipeline($method = 'processFieldValues') {
parent::testDefineValueProcessPipeline($method);
}
}
......@@ -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().
......@@ -44,11 +44,11 @@ protected function setUp() {
}
/**
* @covers ::processFieldValues
* @covers ::defineValueProcessPipeline
* @expectedDeprecation ImageField is deprecated in Drupal 8.5.x and will be removed before Drupal 9.0.x. Use \Drupal\image\Plugin\migrate\field\d7\ImageField instead. See https://www.drupal.org/node/2936061.
*/
public function testProcessFieldValues() {
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
public function testDefineValueProcessPipeline($method = 'defineValueProcessPipeline') {
$this->plugin->$method($this->migration, 'somefieldname', []);
$expected = [
'plugin' => 'sub_process',
......
......@@ -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,
......
......@@ -10,6 +10,7 @@
/**
* @coversDefaultClass \Drupal\image\Plugin\migrate\field\d7\ImageField
* @group image
* @group legacy
*/
class ImageFieldTest extends UnitTestCase {
......@@ -44,6 +45,7 @@ protected function setUp() {
/**
* @covers ::processFieldValues
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testProcessFieldValues() {
$this->plugin->processFieldValues($this->migration, 'somefieldname', []);
......
......@@ -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',
......
......@@ -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',
......
......@@ -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,
......
......@@ -42,7 +42,7 @@ public function getFieldWidgetMap() {
/**
* {@inheritdoc}
*/
public function processFieldInstance(MigrationInterface $migration) {
public function alterFieldInstanceMigration(MigrationInterface $migration) {
$process = [
'plugin' => 'static_map',
'source' => 'settings/title',
......
<?php
namespace Drupal\Tests\link\Kernel\Plugin\migrate\cckfield\d7;
/**
* @group link
* @group legacy
*/
class LinkCckDeprecationTest extends LinkCckTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.
*/
public function testAlterFieldInstanceMigration($method = 'processFieldInstance') {
parent::testAlterFieldInstanceMigration($method);
}
}
......@@ -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().
......@@ -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',
......
<?php
namespace Drupal\Tests\link\Kernel\Plugin\migrate\field\d7;
/**
* @group legacy
* @group link
*/
class LinkFieldLegacyTest extends LinkFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.
*/
public function testAlterFieldInstanceMigration($method = 'processFieldInstance') {
parent::testAlterFieldInstanceMigration($method);
}
}
......@@ -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().
......@@ -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',
......
<?php
namespace Drupal\Tests\link\Unit\Plugin\migrate\field\d6;
/**
* @group legacy
* @group link
*/
class LinkFieldLegacyTest extends LinkFieldTest {
/**
* @expectedDeprecation Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.
*/
public function testDefineValueProcessPipeline($method = 'processFieldValues') {
parent::testDefineValueProcessPipeline($method);
}
}
......@@ -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().
......@@ -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',
......
......@@ -17,7 +17,7 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
* @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.
......
......@@ -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.