diff --git a/core/modules/field/src/Plugin/migrate/process/FieldType.php b/core/modules/field/src/Plugin/migrate/process/FieldType.php index 05e58a8..e382304 100644 --- a/core/modules/field/src/Plugin/migrate/process/FieldType.php +++ b/core/modules/field/src/Plugin/migrate/process/FieldType.php @@ -11,6 +11,7 @@ use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\migrate\MigrateExecutableInterface; +use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\Plugin\migrate\process\StaticMap; use Drupal\migrate\Row; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -30,6 +31,13 @@ class FieldType extends StaticMap implements ContainerFactoryPluginInterface { protected $cckPluginManager; /** + * The migration object. + * + * @var Drupal\migrate\Plugin\MigrationInterface + */ + protected $migration; + + /** * Constructs a FieldType plugin. * * @param array $configuration @@ -41,20 +49,26 @@ class FieldType extends StaticMap implements ContainerFactoryPluginInterface { * @param \Drupal\Component\Plugin\PluginManagerInterface $cck_plugin_manager * The cckfield plugin manager. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, PluginManagerInterface $cck_plugin_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, PluginManagerInterface $cck_plugin_manager, $migration = NULL) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->cckPluginManager = $cck_plugin_manager; + $this->migration = $migration; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $migration = func_get_args()[4]; + if (!($migration instanceof MigrationInterface)) { + $migration = NULL; + } return new static( $configuration, $plugin_id, $plugin_definition, - $container->get('plugin.manager.migrate.cckfield') + $container->get('plugin.manager.migrate.cckfield'), + $migration ); } @@ -65,7 +79,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable $field_type = is_array($value) ? $value[0] : $value; try { - return $this->cckPluginManager->createInstance($field_type, ['core' => $this->configuration['core']])->getFieldType($row); + return $this->cckPluginManager->createInstance($field_type, [], $this->migration)->getFieldType($row); } catch (PluginNotFoundException $e) { return parent::transform($value, $migrate_executable, $row, $destination_property); diff --git a/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php index bb5c303..2679fa5 100644 --- a/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php +++ b/core/modules/migrate_drupal/src/Plugin/MigrateCckFieldPluginManager.php @@ -29,8 +29,15 @@ class MigrateCckFieldPluginManager extends MigratePluginManager { * A specific createInstance method is necessary to pass the migration on. */ public function createInstance($field_type, array $configuration = array(), MigrationInterface $migration = NULL) { + $core = 6; + if (!empty($configuration['core'])) { + $core = $configuration['core']; + } + else if (!empty($migration->getPluginDefinition()['core'])) { + $core = $migration->getPluginDefinition()['core']; + } foreach ($this->getDefinitions() as $plugin_id => $definition) { - if (in_array($configuration['core'], $definition['core'])) { + if (in_array($core, $definition['core'])) { if (array_key_exists($field_type, $definition['type_map']) || $field_type === $plugin_id) { return parent::createInstance($plugin_id, $configuration, $migration); } diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php b/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php index 4a8a610..d521e0d 100644 --- a/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/CckMigration.php @@ -99,16 +99,12 @@ public function getProcess() { } foreach ($source_plugin as $row) { $field_type = $row->getSourceProperty('type'); - $core = $this->pluginDefinition['core']; - if (empty($core)) { - $core = '6'; - } if (!isset($this->processedFieldTypes[$field_type]) && $this->cckPluginManager->hasDefinition($field_type)) { $this->processedFieldTypes[$field_type] = TRUE; // Allow the cckfield plugin to alter the migration as necessary so // that it knows how to handle fields of this type. if (!isset($this->cckPluginCache[$field_type])) { - $this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, ['core' => $core], $this); + $this->cckPluginCache[$field_type] = $this->cckPluginManager->createInstance($field_type, [], $this); } call_user_func([$this->cckPluginCache[$field_type], $this->pluginDefinition['cck_plugin_method']], $this); }