diff --git a/core/modules/migrate_drupal/src/MigrationStorage.php b/core/modules/migrate_drupal/src/MigrationStorage.php index 4163c01..43509fe 100644 --- a/core/modules/migrate_drupal/src/MigrationStorage.php +++ b/core/modules/migrate_drupal/src/MigrationStorage.php @@ -139,24 +139,10 @@ protected function applyCckFieldProcessors(array $entities) { /** @var \Drupal\migrate\Entity\Migration $migration */ foreach ($entities as $entity_id => $migration) { - // Allow cck field plugins to add themselves to the field map. - if ($this->isFieldMigration($entity_id)) { - foreach ($this->getCckFieldPlugins() as $plugin) { - $plugin->processField($migration); - } - } - - // Allow cck field plugins to make changes to the field widget settings. - if ($this->isFieldWidgetMigration($entity_id)) { - foreach ($this->getCckFieldPlugins() as $plugin) { - $plugin->processFieldWidget($migration); - } - } - - // Allow cck field plugins to make changes for the field display settings. - if ($this->isFieldDisplayMigration($entity_id)) { - foreach ($this->getCckFieldPlugins() as $plugin) { - $plugin->processFieldDisplay($migration); + // Allow field plugins to process the required migrations. + foreach ($this->getCckFieldPlugins() as $plugin) { + if ($method = $this->getMigrationPluginMethod($entity_id)) { + $plugin->$method($migration); } } @@ -191,55 +177,38 @@ protected function getCckFieldPlugins() { } /** - * Get the cck field plugin manager. - * - * @return \Drupal\migrate_drupal\Plugin\MigratePluginManager - * The loaded plugin manager. - */ - protected function getCckPluginManager() { - if (!isset($this->cckPluginManager)) { - $this->cckPluginManager = \Drupal::service('plugin.manager.migrate.cckfield'); - } - return $this->cckPluginManager; - } - - /** - * Check if this is a Drupal field migration. + * Provides a map between migration ids and the cck field plugin method. * * @param string $entity_id - * The entity id. + * The migration entity id. * - * @return bool - * TRUE if the migration is a Drupal field migration otherwise FALSE. + * @return bool|string + * The method to call on the processing plugin or FALSE. */ - protected function isFieldMigration($entity_id) { - return in_array($entity_id, ['d6_field'], TRUE); - } + protected function getMigrationPluginMethod($entity_id) { + $map = [ + 'd6_field' => 'processField', + 'd6_field_instance_widget_settings' => 'processFieldWidget', + 'd6_field_formatter_settings' => 'processFieldDisplay', + ]; + if (isset($map[$entity_id])) { + return $map[$entity_id]; + } - /** - * Check if this is a Drupal field widget migration. - * - * @param string $entity_id - * The entity id. - * - * @return bool - * TRUE if the migration is a Drupal field widget migration otherwise FALSE. - */ - protected function isFieldWidgetMigration($entity_id) { - return in_array($entity_id, ['d6_field_instance_widget_settings'], TRUE); + return FALSE; } /** - * Check if this is a Drupal field display migration. - * - * @param string $entity_id - * The entity id. + * Get the cck field plugin manager. * - * @return bool - * TRUE if the migration is a Drupal field display migration otherwise FALSE. + * @return \Drupal\migrate_drupal\Plugin\MigratePluginManager + * The loaded plugin manager. */ - protected function isFieldDisplayMigration($entity_id) { - return in_array($entity_id, ['d6_field_formatter_settings'], TRUE); + protected function getCckPluginManager() { + if (!isset($this->cckPluginManager)) { + $this->cckPluginManager = \Drupal::service('plugin.manager.migrate.cckfield'); + } + return $this->cckPluginManager; } }