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 c4e7b49..732fd3f 100644 --- a/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php +++ b/core/modules/datetime/src/Plugin/migrate/field/d6/DateField.php @@ -16,7 +16,9 @@ * "datestamp" = "timestamp", * "datetime" = "datetime", * }, - * core = {6} + * core = {6}, + * source_module = "date", + * destination_module = "datetime" * ) * * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php index fbb765f..62e6cee 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php @@ -2,6 +2,10 @@ namespace Drupal\migrate_drupal\Plugin; +use Drupal\Component\Plugin\Exception\PluginNotFoundException; +use Drupal\migrate\Plugin\MigratePluginManager; +use Drupal\migrate\Plugin\MigrationInterface; + @trigger_error('MigrateCckFieldPluginManager is deprecated in Drupal 8.3.x and will be removed before Drupal 9.0.x. Use \Drupal\migrate_drupal\Annotation\MigrateFieldPluginManager instead.', E_USER_DEPRECATED); /** @@ -14,4 +18,42 @@ * * @ingroup migration */ -class MigrateCckFieldPluginManager extends MigrateFieldPluginManager implements MigrateCckFieldPluginManagerInterface { } +class MigrateCckFieldPluginManager extends MigratePluginManager implements MigrateCckFieldPluginManagerInterface { + + /** + * The default version of core to use for cck field plugins. + * + * These plugins were initially only built and used for Drupal 6 cck fields. + * Having been extended for Drupal 7 with a "core" annotation, we fall back to + * Drupal 6 where none exists. + */ + const DEFAULT_CORE_VERSION = 6; + + /** + * {@inheritdoc} + */ + public function getPluginIdFromFieldType($field_type, array $configuration = [], MigrationInterface $migration = NULL) { + $core = static::DEFAULT_CORE_VERSION; + if (!empty($configuration['core'])) { + $core = $configuration['core']; + } + elseif (!empty($migration->getPluginDefinition()['migration_tags'])) { + foreach ($migration->getPluginDefinition()['migration_tags'] as $tag) { + if ($tag == 'Drupal 7') { + $core = 7; + } + } + } + + $definitions = $this->getDefinitions(); + foreach ($definitions as $plugin_id => $definition) { + if (in_array($core, $definition['core'])) { + if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) { + return $plugin_id; + } + } + } + throw new PluginNotFoundException($field_type); + } + +} diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php index d132933..5741258 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateFieldPluginManager.php @@ -62,7 +62,7 @@ public function processDefinition(&$definition, $plugin_id) { foreach (['core', 'source_module', 'destination_module'] as $required_property) { if (empty($definition[$required_property])) { - throw new InvalidPluginDefinitionException(sprintf('The field plugin should define the %s property.', $plugin_id, $required_property)); + throw new InvalidPluginDefinitionException($plugin_id, sprintf('The %s plugin should define the %s property.', $definition['class'], $required_property)); } } }