extractTo example

public function remove($file_path) {
    $this->zip->deleteName($file_path);

    return $this;
  }

  /** * {@inheritdoc} */
  public function extract($path, array $files = []) {
    if ($files) {
      $this->zip->extractTo($path$files);
    }
    else {
      $this->zip->extractTo($path);
    }

    return $this;
  }

  /** * {@inheritdoc} */
  
if (!is_writable($destination)) {
            throw new PluginExtractionException(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $pluginName = $this->getPluginName($archive);
        $this->validatePluginZip($pluginName$archive);

        $oldFile = $this->findOldFile($destination$pluginName);
        $backupFile = $this->createBackupFile($oldFile);

        try {
            $archive->extractTo($destination);

            if ($backupFile !== null) {
                $this->filesystem->remove($backupFile);
            }

            if ($delete) {
                unlink($archive->filename);
            }
        } catch (\Exception $e) {
            $this->filesystem->rename($backupFile$oldFile);

            


    /** * Helper function to decompress zip files. * * @throws Exception */
    private function unzip(UploadedFile $file, string $targetDirectory): void
    {
        $filePath = $file->getPath() . DIRECTORY_SEPARATOR . $file->getFilename();
        $zipUtils = ZipUtils::openZip($filePath);
        $zipUtils->extractTo($targetDirectory);
    }

    /** * Helper function which checks if the passed template * or the inheritance templates has configuration sets. */
    private function hasTemplateConfigSet(Template $template): bool
    {
        $theme = $this->get(Util::class)->getThemeByTemplate($template);

        if ($template->getConfigSets()->count() > 0) {
            

            $file = $path . $file;
        }

        return $files;
    }

    private function extractedFilesFromZip(string $path, string $dir): void
    {
        $zip = new ZipArchive();
        $zip->open($path);
        $success = $zip->extractTo($dir);
        if (!$success) {
            throw new RuntimeException(sprintf('Could not extract %s to %s', $path$dir));
        }
        $zip->close();
    }
}
throw new Exception(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $prefix = $this->getPluginPrefix($archive);
        $this->validatePluginZip($prefix$archive);
        $this->validatePluginRequirements($prefix$archive);

        $oldFile = $this->findOldFile($prefix);
        $backupFile = $this->createBackupFile($oldFile);

        try {
            $archive->extractTo($destination);

            if ($backupFile !== false) {
                $this->filesystem->remove($backupFile);
            }

            unlink($archive->filename);
        } catch (Exception $e) {
            if ($oldFile !== false) {
                $this->filesystem->rename($backupFile$oldFile);
            }
            throw $e;
        }

    public function extract($archive$destination)
    {
        if (!is_writable($destination)) {
            throw new Exception(sprintf('Destination directory "%s" is not writable', $destination));
        }

        $this->validatePluginZip($archive);

        $archive->extractTo($destination);

        $this->clearOpcodeCache();
    }

    /** * Iterates all files of the provided zip archive * path and validates the plugin namespace, directory traversal * and multiple plugin directories. * * @throws Exception */
    

        $zip = new ZipArchive();

        if ($zip->open($filePath) !== true) {
            throw new EmotionImportException(sprintf('Could not open zip file "%s"!', $filePath));
        }

        if ($zip->locateName('emotion.json') === false) {
            throw new EmotionImportException(sprintf('Missing emotion.json in %s!', $filePath));
        }

        if ($zip->extractTo($extractPath) !== true) {
            throw new EmotionImportException(sprintf('Could not extract zip file %s to %s!', $filePath$extractPath));
        }

        $zip->close();
        $this->filesystem->remove($filePath);

        return json_decode(file_get_contents($extractPath . '/emotion.json'), true);
    }

    /** * @throws EmotionImportException */
Home | Imprint | This part of the site doesn't use cookies.