diff -u b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php --- b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityFile.php @@ -9,10 +9,11 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\File\FileSystemInterface; use Drupal\migrate\Entity\MigrationInterface; -use Drupal\migrate\Plugin\MigratePluginManager; use Drupal\migrate\Row; use Drupal\migrate\MigrateException; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Every migration that uses this destination must have an optional @@ -25,9 +26,14 @@ class EntityFile extends EntityContentBase { /** + * @var \Drupal\Core\File\FileSystemInterface + */ + protected $fileSystem; + + /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EntityStorageInterface $storage, array $bundles, EntityManagerInterface $entity_manager, FileSystemInterface $file_system) { $configuration += array( 'source_base_path' => '', 'source_path_property' => 'filepath', @@ -36,6 +42,25 @@ 'urlencode' => FALSE, ); parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $storage, $bundles, $entity_manager); + + $this->fileSystem = $file_system; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + $entity_type = static::getEntityTypeId($plugin_id); + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $migration, + $container->get('entity.manager')->getStorage($entity_type), + array_keys($container->get('entity.manager')->getBundleInfo($entity_type)), + $container->get('entity.manager'), + $container->get('file_system') + ); } /** @@ -46,13 +71,13 @@ $destination = $row->getDestinationProperty($this->configuration['destination_path_property']); $source = $this->configuration['source_base_path'] . $file; - $dirname = drupal_dirname($destination); + $dirname = $this->fileSystem->dirname($destination); if (!file_prepare_directory($dirname, FILE_CREATE_DIRECTORY)) { throw new MigrateException(t('Could not create directory %dirname', array('%dirname' => $dirname))); } // If the start and end file is exactly the same, there is nothing to do. - if (drupal_realpath($source) === drupal_realpath($destination)) { + if ($this->fileSystem->realpath($source) === $this->fileSystem->realpath($destination)) { return parent::import($row, $old_destination_id_values); } only in patch2: unchanged: --- a/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/FileUri.php +++ b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/FileUri.php @@ -24,7 +24,6 @@ class FileUri extends ProcessPluginBase { * {@inheritdoc} */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - list($filepath, $file_directory_path, $temp_directory_path, $is_public) = $value; // Specific handling using $temp_directory_path for temporary files.