summaryrefslogtreecommitdiffstats
path: root/core/modules/migrate_drupal
diff options
context:
space:
mode:
authorNathaniel Catchpole2018-07-13 11:39:04 (GMT)
committerNathaniel Catchpole2018-07-13 11:39:04 (GMT)
commit14a769b7580317bd3d690449c9222492e9308c72 (patch)
tree3eaf49e6d13ac607496c0749fbbc22163f1c8334 /core/modules/migrate_drupal
parent163144a9237a9ad5d28916573d3b34f5a8ddd625 (diff)
Issue #2631698 by Jo Fitzgerald, robpowell, phenaproxima, heddn, quietone: Fix sub-optimal DX in MigrateFieldInterface
Diffstat (limited to 'core/modules/migrate_drupal')
-rw-r--r--core/modules/migrate_drupal/src/Plugin/MigrateFieldInterface.php12
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/cckfield/CckFieldPluginBase.php11
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/field/FieldPluginBase.php81
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/field/NodeReference.php2
-rw-r--r--core/modules/migrate_drupal/src/Plugin/migrate/field/UserReference.php2
5 files changed, 85 insertions, 23 deletions
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 @@ 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 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
* @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 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
* @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 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
* @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 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
/**
* 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 @@ interface MigrateFieldInterface extends PluginInspectionInterface {
* @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..80ad6fa 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 @@ use Drupal\migrate_drupal\Plugin\MigrateCckFieldInterface;
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 dc115ab..7827470 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,66 @@ use Drupal\migrate_drupal\Plugin\MigrateFieldInterface;
abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterface {
/**
- * {@inheritdoc}
+ * Alters the migration for field definitions.
+ *
+ * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use
+ * alterFieldMigration() instead.
+ *
+ * @see https://www.drupal.org/node/2944598
+ * @see ::alterFieldMigration()
*/
public function processField(MigrationInterface $migration) {
+ @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldMigration() instead. See https://www.drupal.org/node/2944598.', 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.6.0, to be removed before Drupal 9.0.0. Use
+ * alterFieldInstanceMigration() instead.
+ *
+ * @see https://www.drupal.org/node/2944598
+ * @see ::alterFieldInstanceMigration()
*/
public function processFieldInstance(MigrationInterface $migration) {
- // Nothing to do by default with field instances.
+ @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldInstanceMigration() instead. See https://www.drupal.org/node/2944598.', 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.6.0, to be removed before Drupal 9.0.0. Use
+ * alterFieldWidgetMigration() instead.
+ *
+ * @see https://www.drupal.org/node/2944598
+ * @see ::alterFieldWidgetMigration()
+ */
public function processFieldWidget(MigrationInterface $migration) {
+ @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldWidgetMigration() instead. See https://www.drupal.org/node/2944598.', 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 +119,24 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterfa
}
/**
- * {@inheritdoc}
+ * Alter field formatter migration.
+ *
+ * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use
+ * alterFieldFormatterMigration() instead.
+ *
+ * @see https://www.drupal.org/node/2944598
+ * @see ::processFieldFormatter()
*/
public function processFieldFormatter(MigrationInterface $migration) {
- $process = [];
+ @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use alterFieldFormatterMigration() instead. See https://www.drupal.org/node/2944598.', 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 +148,23 @@ abstract class FieldPluginBase extends PluginBase implements MigrateFieldInterfa
}
/**
- * {@inheritdoc}
+ * Defines the process pipeline for field values.
+ *
+ * @deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use
+ * defineValueProcessPipeline() instead.
+ *
+ * @see https://www.drupal.org/node/2944598
+ * @see ::defineValueProcessPipeline()
*/
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
+ @trigger_error('Deprecated in Drupal 8.6.0, to be removed before Drupal 9.0.0. Use defineValueProcessPipeline() instead. See https://www.drupal.org/node/2944598.', 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 d8b756b..de8c4f5 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 b42d94c..4a60f45 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,