Пример #1
0
 /**
  * Store each file located in the directory to the
  * catalog filesystem in the table akeneo_file_storage_file_info.
  *
  * At the end of this method, all local files are stored in the new filesystem,
  * and for each "new" media, we know the identifier of the "old" media
  */
 public function storeLocalMedias()
 {
     $this->output->writeln(sprintf('Storing medias located in <comment>%s</comment> to the catalog filesystem...', $this->mediaDirectory));
     $storer = $this->container->get('akeneo_file_storage.file_storage.file.file_storer');
     $finder = new Finder();
     foreach ($finder->files()->followLinks()->in($this->mediaDirectory) as $file) {
         $fileInfo = $storer->store($file, FileStorage::CATALOG_STORAGE_ALIAS);
         $this->ormConnection->update('akeneo_file_storage_file_info', ['old_file_key' => $file->getFilename()], ['id' => $fileInfo->getId()]);
     }
 }
 /**
  * Store each file located in the directory to the
  * catalog filesystem in the table akeneo_file_storage_file_info.
  *
  * At the end of this method, all local files are stored in the new filesystem,
  * and for each "new" media, we know the identifier of the "old" media
  */
 public function storeLocalMedias()
 {
     $this->writeConsole(sprintf('Storing medias located in <comment>%s</comment> to the catalog filesystem...', $this->mediaDirectory));
     $storer = $this->container->get('akeneo_file_storage.file_storage.file.file_storer');
     $em = $this->container->get('doctrine.orm.entity_manager');
     $finder = new Finder();
     $storedFiles = 1;
     foreach ($finder->files()->followLinks()->in($this->mediaDirectory) as $file) {
         $fileInfo = $storer->store($file, FileStorage::CATALOG_STORAGE_ALIAS);
         $em->clear();
         $this->ormConnection->update('akeneo_file_storage_file_info', ['old_file_key' => $file->getFilename()], ['id' => $fileInfo->getId()]);
         $storedFiles++;
         if (0 === $storedFiles % 500) {
             $this->writeConsole(sprintf('Stored files = %d', $storedFiles));
         }
     }
 }