diff --git a/src/Plugin/migrate/process/FoxmlFile.php b/src/Plugin/migrate/process/FoxmlFile.php index b0875edc..4bcc47d7 100644 --- a/src/Plugin/migrate/process/FoxmlFile.php +++ b/src/Plugin/migrate/process/FoxmlFile.php @@ -57,7 +57,11 @@ public static function create(ContainerInterface $container, array $configuratio $plugin_id, $plugin_definition, $migration, - $process_plugin_manager->createInstance('dgi_migrate.naive_file_copy', [], $migration), + $process_plugin_manager->createInstance('dgi_migrate.naive_file_copy', [ + 'force_stub' => TRUE, + 'move' => FALSE, + 'file_exists' => 'rename', + ], $migration), ); } @@ -66,10 +70,15 @@ public static function create(ContainerInterface $container, array $configuratio */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { return match ($this->configuration['method']) { - 'copy' => $this->naiveCopyPlugin->transform([ - $value, - $this->getDestinationPath($row), - ], $migrate_executable, $row, $destination_property), + 'copy' => $this->naiveCopyPlugin->transform( + [ + $value, + $this->getDestinationPath($row), + ], + $migrate_executable, + $row, + $destination_property, + ), 'direct' => static::ensureNonWritable($value), }; } diff --git a/src/Plugin/migrate/process/NaiveFileCopy.php b/src/Plugin/migrate/process/NaiveFileCopy.php index 1e30eb57..1087baee 100644 --- a/src/Plugin/migrate/process/NaiveFileCopy.php +++ b/src/Plugin/migrate/process/NaiveFileCopy.php @@ -20,6 +20,10 @@ * The core "file_copy" is rather opinionated, complicating the use of the * php:// scheme. * + * Extends "file_copy", additionally accepting: + * - force_stub: Boolean to force the copying when the row being processed + * appears to be a stub. + * * @MigrateProcessPlugin( * id = "dgi_migrate.naive_file_copy" * ) @@ -33,6 +37,13 @@ class NaiveFileCopy extends FileCopy implements ContainerFactoryPluginInterface */ protected $migrateConfig; + /** + * Boolean if we should force copying when the row is a stub. + * + * @var bool + */ + protected bool $forceStub; + /** * Constructor. */ @@ -40,6 +51,7 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi parent::__construct($configuration, $plugin_id, $plugin_definition, $stream_wrappers, $file_system, $download_plugin); $this->migrateConfig = $config_factory->get('dgi_migrate.settings'); + $this->forceStub = $this->configuration['force_stub'] ?? FALSE; } /** @@ -63,7 +75,7 @@ public static function create(ContainerInterface $container, array $configuratio public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { // If we're stubbing a file entity, return a URI of NULL so it will get // stubbed by the general process. - if ($row->isStub()) { + if (!$this->forceStub && $row->isStub()) { return NULL; } [$source, $destination] = $value;