Exemplo n.º 1
0
 /**
  * Add documents to archive
  *
  * @param \Thelia\ImportExport\Export\AbstractExport $export   An export instance
  * @param \Thelia\Core\Archiver\ArchiverInterface    $archiver
  */
 protected function processExportDocuments(AbstractExport $export, ArchiverInterface $archiver)
 {
     foreach ($export->getDocumentsPaths() as $documentPath) {
         $archiver->add($documentPath);
     }
 }
Exemplo n.º 2
0
 /**
  * Extract archive
  *
  * @param \Symfony\Component\HttpFoundation\File\File $file
  * @param \Thelia\Core\Archiver\ArchiverInterface     $archiver
  *
  * @return \Symfony\Component\HttpFoundation\File\File First file in unarchiver
  */
 public function extractArchive(File $file, ArchiverInterface $archiver)
 {
     $archiver->open($file->getPathname());
     $extractpath = dirname($archiver->getArchivePath()) . DS . uniqid();
     $archiver->extract($extractpath);
     /** @var \DirectoryIterator $item */
     foreach (new \DirectoryIterator($extractpath) as $item) {
         if (!$item->isDot() && $item->isFile()) {
             $file = new File($item->getPathname());
             break;
         }
     }
     return $file;
 }
Exemplo n.º 3
0
 /**
  * Add an archiver
  *
  * @param \Thelia\Core\Archiver\ArchiverInterface $archiver An archiver
  *
  * @return $this Return $this, allow chaining
  */
 public function add(ArchiverInterface $archiver)
 {
     $this->archivers[$archiver->getId()] = $archiver;
     return $this;
 }