diff -u b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php --- b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d6/FileField.php @@ -18,0 +19,58 @@ + */ + public function getFieldWidgetMap() { + return [ + 'filefield_widget' => 'file_generic', + ]; + } + + /** + * {@inheritdoc} + */ + public function getFieldFormatterMap() { + return [ + 'default' => 'file_default', + 'url_plain' => 'file_url_plain', + 'path_plain' => 'file_url_plain', + 'image_plain' => 'image', + 'image_nodelink' => 'image', + 'image_imagelink' => 'image', + ]; + } + + /** + * {@inheritdoc} + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + $process = [ + 'plugin' => 'd6_field_file', + 'source' => $field_name, + ]; + $migration->mergeProcessOfProperty($field_name, $process); + } + + /** + * {@inheritdoc} + */ + public function getFieldType(Row $row) { + return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file'; + } + +} + 'd6_field_file', + 'plugin' => 'd6_cck_file', 'source' => $field_name, ]; $migration->mergeProcessOfProperty($field_name, $process); diff -u b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php --- b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/FileField.php @@ -18,0 +19,63 @@ + */ + public function getFieldWidgetMap() { + return [ + 'filefield_widget' => 'file_generic', + ]; + } + + /** + * {@inheritdoc} + */ + public function getFieldFormatterMap() { + return [ + 'default' => 'file_default', + 'url_plain' => 'file_url_plain', + 'path_plain' => 'file_url_plain', + 'image_plain' => 'image', + 'image_nodelink' => 'image', + 'image_imagelink' => 'image', + ]; + } + + /** + * {@inheritdoc} + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + $process = [ + 'plugin' => 'iterator', + 'source' => $field_name, + 'process' => [ + 'target_id' => 'fid', + 'display' => 'display', + 'description' => 'description', + ], + ]; + $migration->mergeProcessOfProperty($field_name, $process); + } + + /** + * {@inheritdoc} + */ + public function getFieldType(Row $row) { + return $row->getSourceProperty('widget_type') == 'imagefield_widget' ? 'image' : 'file'; + } + +} + 'iterator', 'source' => $field_name, diff -u b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php --- b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php +++ b/core/modules/file/src/Plugin/migrate/field/d7/ImageField.php @@ -17,0 +18,41 @@ + */ + public function getFieldFormatterMap() { + return []; + } + + /** + * {@inheritdoc} + */ + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { + $process = [ + 'plugin' => 'iterator', + 'source' => $field_name, + 'process' => [ + 'target_id' => 'fid', + 'alt' => 'alt', + 'title' => 'title', + 'width' => 'width', + 'height' => 'height', + ], + ]; + $migration->mergeProcessOfProperty($field_name, $process); + } + +} + 'iterator', 'source' => $field_name, reverted: --- b/core/modules/file/src/Plugin/migrate/process/d6/FieldFile.php +++ /dev/null @@ -1,92 +0,0 @@ -migration = $migration; - $this->migrationPlugin = $migration_plugin; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - // Configure the migration process plugin to look up migrated IDs from - // a d6 file migration. - $migration_plugin_configuration = $configuration + [ - 'migration' => 'd6_file', - 'source' => ['fid'], - ]; - - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $migration, - $container->get('plugin.manager.migrate.process')->createInstance('migration', $migration_plugin_configuration, $migration) - ); - } - - /** - * {@inheritdoc} - */ - public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - $options = unserialize($value['data']); - - // Try to look up the ID of the migrated file. If one cannot be found, it - // means the file referenced by the current field item did not migrate for - // some reason -- file migration is notoriously brittle -- and we do NOT - // want to send invalid file references into the field system (it causes - // fatals), so return an empty item instead. - if ($fid = $this->migrationPlugin->transform($value['fid'], $migrate_executable, $row, $destination_property)) { - return [ - 'target_id' => $fid, - 'display' => $value['list'], - 'description' => isset($options['description']) ? $options['description'] : '', - 'alt' => isset($options['alt']) ? $options['alt'] : '', - 'title' => isset($options['title']) ? $options['title'] : '', - ]; - } - else { - return []; - } - } - -} reverted: --- b/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/FieldFileTest.php +++ a/core/modules/file/tests/src/Unit/Plugin/migrate/process/d6/CckFileTest.php @@ -2,7 +2,7 @@ namespace Drupal\Tests\file\Unit\Plugin\migrate\process\d6; +use Drupal\file\Plugin\migrate\process\d6\CckFile; -use Drupal\file\Plugin\migrate\process\d6\FieldFile; use Drupal\migrate\Plugin\MigrationInterface; use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\Plugin\MigrateProcessInterface; @@ -12,7 +12,7 @@ /** * @group file */ +class CckFileTest extends UnitTestCase { -class FieldFileTest extends UnitTestCase { /** * Tests that alt and title attributes are included in transformed values. @@ -25,7 +25,7 @@ $migration_plugin = $this->prophesize(MigrateProcessInterface::class); $migration_plugin->transform(1, $executable, $row, 'foo')->willReturn(1); + $plugin = new CckFile([], 'd6_cck_file', [], $migration, $migration_plugin->reveal()); - $plugin = new FieldFile([], 'd6_file', [], $migration, $migration_plugin->reveal()); $options = [ 'alt' => 'Foobaz', interdiff impossible; taking evasive action reverted: --- b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php +++ a/core/modules/taxonomy/src/Plugin/migrate/cckfield/TaxonomyTermReference.php @@ -1,12 +1,12 @@ 'iterator', 'source' => $field_name, unchanged: --- /dev/null +++ b/core/modules/taxonomy/src/Plugin/migrate/field/TaxonomyTermReference.php @@ -0,0 +1,40 @@ + 'iterator', + 'source' => $field_name, + 'process' => [ + 'target_id' => 'tid', + ], + ]; + $migration->setProcessOfProperty($field_name, $process); + } + +} diff -u b/core/modules/text/src/Plugin/migrate/field/TextField.php b/core/modules/text/src/Plugin/migrate/field/TextField.php --- b/core/modules/text/src/Plugin/migrate/field/TextField.php +++ b/core/modules/text/src/Plugin/migrate/field/TextField.php