Revert files
modifié: core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php supprimé: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php~HEAD modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderInterface.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php modifié: core/lib/Thelia/Core/FileFormat/FormatInterface.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/AbstractFormatter.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatting/FormatterData.php modifié: core/lib/Thelia/Tests/Action/FolderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarBz2ArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TarGzArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/TestResources/bad_formatted.tar modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilder/ZipArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php nouveau fichier: core/lib/Thelia/Tests/FileFormat/Formatting/Formatter/XMLFormatterTest.php modifié: core/lib/Thelia/Tests/FileFormat/Formatting/FormatterDataTest.php modifié: core/lib/Thelia/Tests/Tools/FakeFileDownloader.php modifié: core/lib/Thelia/Tests/Tools/FileDownloaderTest.php modifié: core/lib/Thelia/Tools/FileDownload/FileDownloader.php modifié: core/lib/Thelia/Tools/FileDownload/FileDownloaderAwareTrait.php modifié: core/lib/Thelia/Tools/FileDownload/FileDownloaderInterface.php
This commit is contained in:
@@ -12,18 +12,10 @@
|
||||
|
||||
namespace Thelia\Core\FileFormat\Archive;
|
||||
use Thelia\Core\FileFormat\FormatInterface;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\FileNotFoundException;
|
||||
use Thelia\Exception\FileNotReadableException;
|
||||
use Thelia\Log\Tlog;
|
||||
=======
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
use Thelia\Tools\FileDownload\FileDownloaderAwareTrait;
|
||||
|
||||
/**
|
||||
@@ -34,25 +26,12 @@ use Thelia\Tools\FileDownload\FileDownloaderAwareTrait;
|
||||
abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilderInterface
|
||||
{
|
||||
use FileDownloaderAwareTrait;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
const TEMP_DIRECTORY_NAME = "archive_builder";
|
||||
|
||||
/** @var string */
|
||||
protected $cacheFile;
|
||||
|
||||
=======
|
||||
|
||||
const TEMP_DIRECTORY_NAME = "archive_builder";
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
/** @var string */
|
||||
protected $cacheFile;
|
||||
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
/** @var \Thelia\Core\Translation\Translator */
|
||||
protected $translator;
|
||||
|
||||
@@ -62,18 +41,9 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
/** @var string */
|
||||
protected $cacheDir;
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
/** @var string */
|
||||
protected $environment;
|
||||
|
||||
=======
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
/** @var string */
|
||||
protected $environment;
|
||||
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
public function __construct()
|
||||
{
|
||||
$this->translator = Translator::getInstance();
|
||||
@@ -96,15 +66,7 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$archiveBuilderCacheDir = $this->cacheDir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME;
|
||||
=======
|
||||
$archiveBuilderCacheDir = $this->cache_dir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME;
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
$archiveBuilderCacheDir = $this->cacheDir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
if (!is_dir($archiveBuilderCacheDir) && !mkdir($archiveBuilderCacheDir, 0755)) {
|
||||
throw new \ErrorException(
|
||||
@@ -120,10 +82,6 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
return $archiveBuilderCacheDir;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
/**
|
||||
* @param $pathToFile
|
||||
* @param $destination
|
||||
@@ -215,11 +173,6 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
|
||||
return $this;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
public function getCacheDir()
|
||||
{
|
||||
@@ -241,29 +194,14 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
{
|
||||
return $this->translator;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
public function getCacheFile()
|
||||
{
|
||||
return $this->cacheFile;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
/**
|
||||
* @param string $environment
|
||||
=======
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* @param string $environment
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
* @param string $environment
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
*
|
||||
* Sets the execution environment of the Kernel,
|
||||
@@ -273,21 +211,4 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
||||
{
|
||||
$this->environment = $environment;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -20,12 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception;
|
||||
class TarArchiveException extends \Exception
|
||||
{
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception;
|
||||
|
||||
/**
|
||||
* Class ZipArchiveException
|
||||
* @package Thelia\Core\FileFormat\Archive\ArchiveBuilder
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class ZipArchiveException extends \ErrorException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -13,23 +13,10 @@
|
||||
namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder;
|
||||
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\FileNotReadableException;
|
||||
=======
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilderInterface;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Exception\FileNotReadableException;
|
||||
>>>>>>> Finish Tar archive builder
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
||||
|
||||
@@ -60,39 +47,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
/** @var \Thelia\Log\Tlog */
|
||||
protected $logger;
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
function __construct($compressionType = null)
|
||||
{
|
||||
$this->translator = Translator::getInstance();
|
||||
$this->logger = Tlog::getNewInstance();
|
||||
|
||||
$supportedCompression = [
|
||||
"gz",
|
||||
"bz2",
|
||||
null
|
||||
];
|
||||
|
||||
if (!in_array($compressionType, $supportedCompression)) {
|
||||
throw new TarArchiveException(
|
||||
$this->translator->trans(
|
||||
"The compression %type is not supported"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->compression = $compressionType;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
/**
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
|
||||
>>>>>>> Finish Tar archive builder
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
public function __destruct()
|
||||
{
|
||||
if ($this->tar instanceof \PharData) {
|
||||
@@ -100,8 +54,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
unlink($this->cacheFile);
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,21 +61,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
}*/
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish Tar archive builder
|
||||
|
||||
/**
|
||||
* @param string $filePath It is the path to access the file.
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
@@ -143,15 +80,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
* Download the file if it is online
|
||||
* If it's local check if the file exists and if it is redable
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$fileDownloadCache = $this->cacheDir . DS . md5(uniqid()) . ".tmp";
|
||||
=======
|
||||
$fileDownloadCache = $this->cacheDir . DS . "download.tmp";
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
$fileDownloadCache = $this->cacheDir . DS . md5(uniqid()) . ".tmp";
|
||||
>>>>>>> Complete zip tests
|
||||
$this->copyFile($filePath, $fileDownloadCache, $isOnline);
|
||||
|
||||
/**
|
||||
@@ -167,35 +96,18 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
|
||||
$this->tar->addFile($filePath, $name);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish Tar archive builder
|
||||
/**
|
||||
* And clear the download temp file
|
||||
*/
|
||||
unlink($fileDownloadCache);
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Finish Tar archive builder
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @param $name
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $directoryInArchive
|
||||
=======
|
||||
* @param string $directoryInArchive
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $directoryInArchive
|
||||
>>>>>>> Fix cs
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*
|
||||
@@ -220,15 +132,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
try {
|
||||
$this->tar->addFromString($name, $content);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
} catch (\Exception $e) {
|
||||
=======
|
||||
} catch(\Exception $e) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
} catch (\Exception $e) {
|
||||
>>>>>>> Fix cs
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"Error while writing the file into the archive, error message: %errmes",
|
||||
@@ -240,13 +144,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
/**
|
||||
* @param $directoryPath
|
||||
* @return $this
|
||||
@@ -262,15 +159,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
|
||||
try {
|
||||
$this->tar->addEmptyDir($directoryInArchive);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
} catch (\Exception $e) {
|
||||
=======
|
||||
} catch(\Exception $e) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
} catch (\Exception $e) {
|
||||
>>>>>>> Fix cs
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"The directory %dir has not been created in the archive",
|
||||
@@ -286,15 +175,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $pathToFile
|
||||
=======
|
||||
* @param string $pathToFile
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $pathToFile
|
||||
>>>>>>> Fix cs
|
||||
* @return null|string
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
@@ -304,11 +185,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function getFileContent($pathToFile)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Fix FileDownloader test
|
||||
$pathToFile = $this->formatFilePath($pathToFile);
|
||||
|
||||
if (!$this->hasFile($pathToFile)) {
|
||||
@@ -317,19 +193,11 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
|
||||
/** @var \PharFileInfo $fileInfo*/
|
||||
$fileInfo = $this->tar[$pathToFile];
|
||||
<<<<<<< HEAD
|
||||
|
||||
/** @var \SplFileObject $file */
|
||||
$file = $fileInfo->openFile();
|
||||
$content = "";
|
||||
|
||||
=======
|
||||
|
||||
/** @var \SplFileObject $file */
|
||||
$file = $fileInfo->openFile();
|
||||
$content = "";
|
||||
|
||||
>>>>>>> Fix FileDownloader test
|
||||
while (false !== ($char = $file->fgetc())) {
|
||||
$content .= $char;
|
||||
}
|
||||
@@ -337,18 +205,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
return $content;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
=======
|
||||
|
||||
>>>>>>> Complete zip tests
|
||||
}
|
||||
|
||||
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
/**
|
||||
* @param $pathInArchive
|
||||
* @return $this
|
||||
@@ -380,8 +236,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*
|
||||
* This method return an instance of a Response with the archive as content.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function buildArchiveResponse($filename)
|
||||
{
|
||||
$this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION);
|
||||
@@ -418,54 +272,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
* @param string $environment
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
=======
|
||||
public function buildArchiveResponse()
|
||||
=======
|
||||
public function buildArchiveResponse($filename)
|
||||
>>>>>>> Add filename in build archive response
|
||||
{
|
||||
$this->tar->setMetadata("Generated by Thelia v" . Thelia::THELIA_VERSION);
|
||||
|
||||
if (!is_file($this->cacheFile)) {
|
||||
$this->throwFileNotFound($this->cacheFile);
|
||||
}
|
||||
|
||||
if (!is_readable($this->cacheFile)) {
|
||||
throw new FileNotReadableException(
|
||||
$this->translator->trans(
|
||||
"The file %file is not readable",
|
||||
[
|
||||
"%file" => $this->cacheFile
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$content = file_get_contents($this->cacheFile);
|
||||
|
||||
return new Response(
|
||||
$content,
|
||||
200,
|
||||
[
|
||||
"Content-Type" => $this->getMimeType(),
|
||||
"Content-Disposition" => $filename . "." . $this->getExtension(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* @param string $pathToArchive
|
||||
* @param string $environment
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $pathToArchive
|
||||
* @param string $environment
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\HttpUrlException
|
||||
@@ -473,8 +279,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*
|
||||
* Loads an archive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function loadArchive($pathToArchive, $isOnline = false)
|
||||
{
|
||||
$tar = clone $this;
|
||||
@@ -482,57 +286,13 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
$tar
|
||||
->setCacheFile($tar->generateCacheFile($this->environment))
|
||||
->copyFile($pathToArchive, $tar->getCacheFile(), $isOnline);
|
||||
=======
|
||||
public static function loadArchive(
|
||||
$pathToArchive,
|
||||
$environment,
|
||||
$isOnline = false,
|
||||
FileDownloaderInterface $fileDownloader = null
|
||||
) {
|
||||
/** @var TarArchiveBuilder $instance */
|
||||
$instance = new static();
|
||||
|
||||
if ($fileDownloader !== null) {
|
||||
$instance->setFileDownloader($fileDownloader);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
$instance->setCacheFile($instance->getCacheFile())
|
||||
->copyFile($pathToArchive, $isOnline);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
$instance->setCacheFile($instance->generateCacheFile($environment))
|
||||
->copyFile($pathToArchive, $instance->getCacheFile(), $isOnline);
|
||||
>>>>>>> Fix FileDownloader test
|
||||
=======
|
||||
public function loadArchive($pathToArchive, $isOnline = false)
|
||||
{
|
||||
$tar = clone $this;
|
||||
|
||||
$tar
|
||||
->setCacheFile($tar->generateCacheFile($this->environment))
|
||||
->copyFile($pathToArchive, $tar->getCacheFile(), $isOnline);
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
/**
|
||||
* This throws TarArchiveBuilderException if
|
||||
* the archive is not valid.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
|
||||
return $tar->setEnvironment($tar->environment);
|
||||
=======
|
||||
$instance->setEnvironment($environment);
|
||||
|
||||
return $instance;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
return $tar->setEnvironment($tar->environment);
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -552,43 +312,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
/** @var \PharFileInfo $fileInfo */
|
||||
$fileInfo = $this->tar[$pathToFile];
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if ($fileInfo->isFile()) {
|
||||
=======
|
||||
if($fileInfo->isFile()) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
if ($fileInfo->isFile()) {
|
||||
>>>>>>> Fix cs
|
||||
$isFile = true;
|
||||
}
|
||||
/**
|
||||
* Catch the exception to avoid its displaying.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
} catch (\BadMethodCallException $e) {}
|
||||
=======
|
||||
} catch(\BadMethodCallException $e) {}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
} catch (\BadMethodCallException $e) {}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
return $isFile;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $directory
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Fix cs
|
||||
* @return bool
|
||||
*
|
||||
* Check if the archive has a directory
|
||||
@@ -602,43 +338,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
/** @var \PharFileInfo $fileInfo */
|
||||
$fileInfo = $this->tar[$pathToDir];
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if ($fileInfo->isDir()) {
|
||||
=======
|
||||
if($fileInfo->isDir()) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
if ($fileInfo->isDir()) {
|
||||
>>>>>>> Fix cs
|
||||
$isDir = true;
|
||||
}
|
||||
/**
|
||||
* Catch the exception to avoid its displaying.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
} catch (\BadMethodCallException $e) {}
|
||||
=======
|
||||
} catch(\BadMethodCallException $e) {}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
} catch (\BadMethodCallException $e) {}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
return $isDir;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $environment
|
||||
=======
|
||||
* @param string $environment
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $environment
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
*
|
||||
* Sets the execution environment of the Kernel,
|
||||
@@ -646,10 +358,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
if (empty($environment)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
@@ -658,11 +366,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
if ($this->cacheFile === null) {
|
||||
$cacheFile = $this->generateCacheFile($environment);
|
||||
|
||||
@@ -678,45 +381,14 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
try {
|
||||
$this->tar = new \PharData($cacheFile, null, null, static::PHAR_FORMAT);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->compressionEntryPoint();
|
||||
|
||||
} catch (\BadMethodCallException $e) {
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
switch ($this->compression) {
|
||||
case "gz":
|
||||
$this->tar = $this->tar->compress(\Phar::GZ);
|
||||
$cacheFile .= ".gz";
|
||||
break;
|
||||
case "bz2":
|
||||
$this->tar = $this->tar->compress(\Phar::BZ2);
|
||||
$cacheFile .= ".bz2";
|
||||
break;
|
||||
}
|
||||
=======
|
||||
$this->compressionEntryPoint();
|
||||
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
} catch(\BadMethodCallException $e) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
/**
|
||||
* This should not happen
|
||||
*/
|
||||
$errorMessage = "You have badly called the method setEnvironment twice for %file";
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
=======
|
||||
} catch(\UnexpectedValueException $e) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
} catch (\UnexpectedValueException $e) {
|
||||
>>>>>>> Fix cs
|
||||
$errorMessage = "The file %file is corrupted";
|
||||
}
|
||||
|
||||
@@ -732,28 +404,13 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
$this->cacheFile = $cacheFile;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->environment = $environment;
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
$this->environment = $environment;
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $initialString
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Fix cs
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid file path for \ZipArchive
|
||||
@@ -774,15 +431,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $initialString
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Fix cs
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid directory path for \ZipArchive
|
||||
@@ -804,21 +453,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
return "tar";
|
||||
=======
|
||||
$name = "tar";
|
||||
|
||||
if ($this->compression !== null) {
|
||||
$name .= "." . $this->compression;
|
||||
}
|
||||
|
||||
return $name;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
return "tar";
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -832,15 +467,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
return "tar";
|
||||
=======
|
||||
return $this->getName();
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
return "tar";
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -853,10 +480,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
return "application/x-tar";
|
||||
}
|
||||
|
||||
@@ -866,7 +489,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
* This method must be overwritten if you want to do some
|
||||
* stuff to compress you archive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
|
||||
public function getCompression()
|
||||
@@ -874,25 +496,3 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
return $this->compression;
|
||||
}
|
||||
}
|
||||
=======
|
||||
return $this->compression === null ?
|
||||
"application/x-tar" :
|
||||
"application/x-gtar"
|
||||
;
|
||||
}
|
||||
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
}
|
||||
|
||||
public function getCompression()
|
||||
{
|
||||
return $this->compression;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -44,12 +44,4 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder
|
||||
|
||||
return $this;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -49,12 +49,4 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -12,24 +12,10 @@
|
||||
|
||||
namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder;
|
||||
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException;
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Exception\FileNotReadableException;
|
||||
=======
|
||||
=======
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
use Thelia\Core\Thelia;
|
||||
use Thelia\Exception\FileNotReadableException;
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Log\Tlog;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
||||
|
||||
/**
|
||||
@@ -45,118 +31,42 @@ use Thelia\Tools\FileDownload\FileDownloaderInterface;
|
||||
*/
|
||||
class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
const TEMP_DIRECTORY_NAME = "archive_builder";
|
||||
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
/**
|
||||
* @var \ZipArchive
|
||||
*/
|
||||
protected $zip;
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->zip = new \ZipArchive();
|
||||
=======
|
||||
/**
|
||||
* @var string This is the absolute path to the zip file in cache
|
||||
*/
|
||||
protected $zipCacheFile;
|
||||
|
||||
/**
|
||||
* @var string This is the path of the cache
|
||||
*/
|
||||
protected $cacheDir;
|
||||
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
<<<<<<< HEAD
|
||||
$this->translator = Translator::getInstance();
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip = new \ZipArchive();
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
}
|
||||
|
||||
/**
|
||||
* On the destruction of the class,
|
||||
* remove the temporary file.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function __destruct()
|
||||
=======
|
||||
function __destruct()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
public function __destruct()
|
||||
>>>>>>> Fix cs
|
||||
{
|
||||
if ($this->zip instanceof \ZipArchive) {
|
||||
@$this->zip->close();
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if (file_exists($this->cacheFile)) {
|
||||
unlink($this->cacheFile);
|
||||
=======
|
||||
if (file_exists($this->zip_cache_file)) {
|
||||
unlink($this->zip_cache_file);
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
if (file_exists($this->zipCacheFile)) {
|
||||
unlink($this->zipCacheFile);
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
if (file_exists($this->cacheFile)) {
|
||||
unlink($this->cacheFile);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
* @param string $filePath It is the path to access the file.
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
<<<<<<< HEAD
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
* @throws \ErrorException
|
||||
=======
|
||||
* @param string $filePath It is the path to access the file.
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @throws \ErrorException
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
*
|
||||
* This methods adds a file in the archive.
|
||||
* If the file is local, $isOnline must be false,
|
||||
@@ -164,8 +74,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function addFile($filePath, $directoryInArchive = null, $name = null, $isOnline = false)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryInArchive);
|
||||
|
||||
/**
|
||||
@@ -173,7 +81,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
|
||||
if (!empty($directoryInArchive)) {
|
||||
<<<<<<< HEAD
|
||||
$this->addDirectory($directoryInArchive);
|
||||
}
|
||||
|
||||
@@ -259,242 +166,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $directoryPath
|
||||
* @return $this
|
||||
* @throws \ErrorException
|
||||
*
|
||||
* This method creates an empty directory
|
||||
*/
|
||||
public function addDirectory($directoryPath)
|
||||
{
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryPath);
|
||||
|
||||
if (!empty($directoryInArchive)) {
|
||||
=======
|
||||
=======
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryInArchive);
|
||||
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
/**
|
||||
* Add empty directory if it doesn't exist
|
||||
*/
|
||||
|
||||
if(!empty($directoryInArchive)) {
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
$this->addDirectory($directoryInArchive);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Define archive builders and formatters
|
||||
if (!$this->zip->addEmptyDir($directoryInArchive)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"The directory %dir has not been created in the archive",
|
||||
[
|
||||
"%dir" => $directoryInArchive
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
=======
|
||||
if (empty($name) || !is_scalar($name)) {
|
||||
$name = basename($filePath);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $pathToFile
|
||||
* @return null|string
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
* @throws \ErrorException
|
||||
*
|
||||
* This method returns a file content
|
||||
*/
|
||||
public function getFileContent($pathToFile)
|
||||
{
|
||||
$pathToFile = $this->formatFilePath($pathToFile);
|
||||
|
||||
if (!$this->hasFile($pathToFile)) {
|
||||
$this->throwFileNotFound($pathToFile);
|
||||
}
|
||||
|
||||
$stream = $this->zip->getStream($pathToFile);
|
||||
$content = "";
|
||||
|
||||
while (!feof($stream)) {
|
||||
$content .= fread($stream, 2);
|
||||
}
|
||||
|
||||
fclose($stream);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $initialString
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid file path for \ZipArchive
|
||||
*/
|
||||
public function getFilePath($initialString)
|
||||
{
|
||||
/**
|
||||
* Remove the / at the beginning and the end.
|
||||
*/
|
||||
$initialString = trim($initialString, "/");
|
||||
|
||||
/**
|
||||
* Remove the double, triple, ... slashes
|
||||
*/
|
||||
$initialString = preg_replace("#\/{2,}#", "/", $initialString);
|
||||
|
||||
if (preg_match("#\/?[^\/]+\/[^\/]+\/?#", $initialString)) {
|
||||
$initialString = "/" . $initialString;
|
||||
}
|
||||
|
||||
return $initialString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $initialString
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid directory path for \ZipArchive
|
||||
*/
|
||||
public function getDirectoryPath($initialString)
|
||||
{
|
||||
$initialString = $this->getFilePath($initialString);
|
||||
|
||||
if ($initialString[0] !== "/") {
|
||||
$initialString = "/" . $initialString;
|
||||
}
|
||||
|
||||
return $initialString . "/";
|
||||
=======
|
||||
=======
|
||||
/**
|
||||
* Download the file if it is online
|
||||
* If it's local check if the file exists and if it is redable
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
if ($isOnline) {
|
||||
$fileDownloadCache = $this->cacheDir . DS . "download";
|
||||
|
||||
$this->getFileDownloader()
|
||||
->download($filePath, $fileDownloadCache)
|
||||
;
|
||||
|
||||
$filePath = $fileDownloadCache;
|
||||
} else {
|
||||
if (!file_exists($filePath)) {
|
||||
$this->throwFileNotFound($filePath);
|
||||
} else if (!is_readable($filePath)) {
|
||||
throw new FileNotReadableException(
|
||||
$this->translator
|
||||
->trans(
|
||||
"The file %file is not readable",
|
||||
[
|
||||
"%file" => $filePath,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($name)) {
|
||||
$name = basename($filePath);
|
||||
}
|
||||
=======
|
||||
$fileDownloadCache = $this->cacheDir . DS . "download.tmp";
|
||||
=======
|
||||
$fileDownloadCache = $this->cacheDir . DS . md5(uniqid()) . ".tmp";
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
$this->copyFile($filePath, $fileDownloadCache, $isOnline);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
/**
|
||||
* Then write the file in the archive and commit the changes
|
||||
*/
|
||||
$destination = $directoryInArchive . $name;
|
||||
|
||||
if (!$this->zip->addFile($fileDownloadCache, $destination)) {
|
||||
$translatedErrorMessage = $this->translator->trans(
|
||||
"An error occurred while adding this file to the archive: %file",
|
||||
[
|
||||
"%file" => $fileDownloadCache
|
||||
]
|
||||
);
|
||||
|
||||
$this->logger->error($translatedErrorMessage);
|
||||
|
||||
// if error delete the cache file
|
||||
unlink($fileDownloadCache);
|
||||
|
||||
throw new \ErrorException($translatedErrorMessage);
|
||||
}
|
||||
|
||||
$this->commit();
|
||||
|
||||
// Delete the temp file
|
||||
unlink($fileDownloadCache);
|
||||
|
||||
return $this;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @param $name
|
||||
* @param string $directoryInArchive
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*
|
||||
* This method creates a file in the archive with its content
|
||||
*/
|
||||
public function addFileFromString($content, $name, $directoryInArchive = "/")
|
||||
{
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryInArchive);
|
||||
|
||||
if (!empty($directoryInArchive) && $directoryInArchive !== "/") {
|
||||
$this->addDirectory($directoryInArchive);
|
||||
}
|
||||
|
||||
if (empty($name) || !is_scalar($name)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"The filename is not correct"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$filePath = $this->getFilePath($directoryInArchive . DS . $name);
|
||||
|
||||
if (!$this->zip->addFromString($filePath, $content)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"Unable to write the file %file into the archive",
|
||||
[
|
||||
"%file" => $filePath,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->commit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $directoryPath
|
||||
* @return $this
|
||||
@@ -604,15 +275,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function deleteFile($pathInArchive)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$pathInArchive = $this->formatFilePath($pathInArchive);
|
||||
=======
|
||||
$pathInArchive = $this->getFilePath($pathInArchive);
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$pathInArchive = $this->formatFilePath($pathInArchive);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
if (!$this->hasFile($pathInArchive)) {
|
||||
$this->throwFileNotFound($pathInArchive);
|
||||
@@ -639,84 +302,28 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*
|
||||
* This method return an instance of a Response with the archive as content.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function buildArchiveResponse($filename)
|
||||
=======
|
||||
public function buildArchiveResponse()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
public function buildArchiveResponse($filename)
|
||||
>>>>>>> Add filename in build archive response
|
||||
{
|
||||
$this->zip->comment = "Generated by Thelia v" . Thelia::THELIA_VERSION;
|
||||
|
||||
$this->commit();
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if (!file_exists($this->cacheFile)) {
|
||||
$this->throwFileNotFound($this->cacheFile);
|
||||
}
|
||||
|
||||
if (!is_readable($this->cacheFile)) {
|
||||
=======
|
||||
if (!file_exists($this->zip_cache_file)) {
|
||||
$this->throwFileNotFound($this->zip_cache_file);
|
||||
}
|
||||
|
||||
if (!is_readable($this->zip_cache_file)) {
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
if (!file_exists($this->zipCacheFile)) {
|
||||
$this->throwFileNotFound($this->zipCacheFile);
|
||||
}
|
||||
|
||||
if (!is_readable($this->zipCacheFile)) {
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
if (!file_exists($this->cacheFile)) {
|
||||
$this->throwFileNotFound($this->cacheFile);
|
||||
}
|
||||
|
||||
if (!is_readable($this->cacheFile)) {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
throw new FileNotReadableException(
|
||||
$this->translator->trans(
|
||||
"The cache file %file is not readable",
|
||||
[
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
"%file" => $this->cacheFile
|
||||
=======
|
||||
"%file" => $this->zip_cache_file
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
"%file" => $this->zipCacheFile
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
"%file" => $this->cacheFile
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$content = file_get_contents($this->cacheFile);
|
||||
=======
|
||||
$content = file_get_contents($this->zip_cache_file);
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$content = file_get_contents($this->zipCacheFile);
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
$content = file_get_contents($this->cacheFile);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
$this->zip->close();
|
||||
|
||||
@@ -724,59 +331,28 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
$content,
|
||||
200,
|
||||
[
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
"Content-Type" => $this->getMimeType(),
|
||||
"Content-Disposition" => $filename . "." . $this->getExtension(),
|
||||
=======
|
||||
"Content-Type" => $this->getMimeType()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
"Content-Type" => $this->getMimeType(),
|
||||
"Content-Disposition" => $filename . "." . $this->getExtension(),
|
||||
>>>>>>> Add filename in build archive response
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
* @return ZipArchiveBuilder
|
||||
=======
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
<<<<<<< HEAD
|
||||
* @return $this
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
=======
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Fix cs
|
||||
* @return ZipArchiveBuilder
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\HttpUrlException
|
||||
*
|
||||
* Loads an archive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
public function loadArchive($pathToArchive, $isOnline = false)
|
||||
{
|
||||
$back = $this->zip;
|
||||
$this->zip = new \ZipArchive();
|
||||
$zip = clone $this;
|
||||
$this->zip = $back;
|
||||
<<<<<<< HEAD
|
||||
|
||||
$zip->setEnvironment($this->environment);
|
||||
|
||||
@@ -793,46 +369,6 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
return $zip;
|
||||
=======
|
||||
public static function loadArchive(
|
||||
$pathToArchive,
|
||||
$environment,
|
||||
$isOnline = false,
|
||||
FileDownloaderInterface $fileDownloader = null
|
||||
) {
|
||||
/** @var ZipArchiveBuilder $instance */
|
||||
$instance = new static();
|
||||
|
||||
$instance->setEnvironment($environment);
|
||||
$zip = $instance->getRawZipArchive();
|
||||
$zip->close();
|
||||
|
||||
if ($fileDownloader !== null) {
|
||||
$instance->setFileDownloader($fileDownloader);
|
||||
}
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
$zip->setEnvironment($this->environment);
|
||||
|
||||
$zip->copyFile(
|
||||
$pathToArchive,
|
||||
$zip->getCacheFile(),
|
||||
$isOnline
|
||||
);
|
||||
|
||||
if (true !== $return = $zip->getRawZipArchive()->open($zip->getCacheFile())) {
|
||||
throw new ZipArchiveException(
|
||||
$zip->getZipErrorMessage($return)
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
return $instance;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
return $zip;
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -844,57 +380,25 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
public function hasFile($pathToFile)
|
||||
{
|
||||
return $this->zip
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
->locateName($this->formatFilePath($pathToFile)) !== false
|
||||
=======
|
||||
->locateName($this->getFilePath($pathToFile)) !== false
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
->locateName($this->formatFilePath($pathToFile)) !== false
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $directory
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Fix cs
|
||||
* @return bool
|
||||
*
|
||||
* Checks if the link $directory exists and if it's not a file.
|
||||
*/
|
||||
public function hasDirectory($directory)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$link = $this->zip->locateName($this->formatDirectoryPath($directory));
|
||||
=======
|
||||
$link = $this->zip->locateName($this->getDirectoryPath($directory));
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$link = $this->zip->locateName($this->formatDirectoryPath($directory));
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
return $link !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $environment
|
||||
=======
|
||||
* @param string $environment
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $environment
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
*
|
||||
* Sets the execution environment of the Kernel,
|
||||
@@ -902,58 +406,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function setEnvironment($environment)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
parent::setEnvironment($environment);
|
||||
|
||||
$cacheFile = $this->generateCacheFile($environment);
|
||||
=======
|
||||
$theliaCacheDir = THELIA_CACHE_DIR . $environment . DS;
|
||||
|
||||
if (!is_writable($theliaCacheDir)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"The cache directory \"%env\" is not writable",
|
||||
[
|
||||
"%env" => $environment
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$archiveBuilderCacheDir = $this->cache_dir = $theliaCacheDir . static::TEMP_DIRECTORY_NAME;
|
||||
|
||||
if (!is_dir($archiveBuilderCacheDir) && !mkdir($archiveBuilderCacheDir, 0755)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"Error while creating the directory \"%directory\"",
|
||||
[
|
||||
"%directory" => static::TEMP_DIRECTORY_NAME
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$cacheFileName = md5 (uniqid());
|
||||
|
||||
$cacheFile = $archiveBuilderCacheDir . DS . $cacheFileName;
|
||||
$cacheFile .= "." . $this->getExtension();
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
=======
|
||||
parent::setEnvironment($environment);
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
<<<<<<< HEAD
|
||||
$cacheFileName = md5 (uniqid());
|
||||
|
||||
$cacheFile = $this->getArchiveBuilderCacheDirectory($environment) . DS;
|
||||
$cacheFile .= $cacheFileName . "." . $this->getExtension();
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
$cacheFile = $this->generateCacheFile($environment);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
if (file_exists($cacheFile)) {
|
||||
unlink($cacheFile);
|
||||
@@ -964,42 +419,15 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
\ZipArchive::CREATE
|
||||
);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if ($opening !== true) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"An unknown error append"
|
||||
=======
|
||||
if($opening !== true) {
|
||||
=======
|
||||
if ($opening !== true) {
|
||||
>>>>>>> Fix cs
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
<<<<<<< HEAD
|
||||
"Unknown"
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
"An unknown error append"
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->cacheFile = $cacheFile;
|
||||
=======
|
||||
$this->zip_cache_file = $cacheFile;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zipCacheFile = $cacheFile;
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
$this->cacheFile = $cacheFile;
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -1071,15 +499,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
public function commit()
|
||||
{
|
||||
$this->zip->close();
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$result = $this->zip->open($this->getCacheFile());
|
||||
=======
|
||||
$result = $this->zip->open($this->getZipCacheFile());
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$result = $this->zip->open($this->getCacheFile());
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
if ($result !== true) {
|
||||
throw new \ErrorException(
|
||||
@@ -1093,28 +513,12 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $initialString
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Fix cs
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid file path for \ZipArchive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function formatFilePath($initialString)
|
||||
=======
|
||||
public function getFilePath($initialString)
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
public function formatFilePath($initialString)
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
{
|
||||
/**
|
||||
* Remove the / at the beginning and the end.
|
||||
@@ -1129,78 +533,27 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
if (preg_match("#\/?[^\/]+\/[^/]+\/?#", $initialString)) {
|
||||
$initialString = "/" . $initialString;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
|
||||
>>>>>>> Fix cs
|
||||
return $initialString;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $initialString
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $initialString
|
||||
>>>>>>> Fix cs
|
||||
* @return string
|
||||
*
|
||||
* Gives a valid directory path for \ZipArchive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function formatDirectoryPath($initialString)
|
||||
{
|
||||
$initialString = $this->formatFilePath($initialString);
|
||||
|
||||
if ($initialString !== "" && $initialString[0] !== "/") {
|
||||
=======
|
||||
public function getDirectoryPath($initialString)
|
||||
=======
|
||||
public function formatDirectoryPath($initialString)
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
{
|
||||
$initialString = $this->formatFilePath($initialString);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if ($initialString[0] !== "/") {
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
if ($initialString !== "" && $initialString[0] !== "/") {
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
$initialString = "/" . $initialString;
|
||||
}
|
||||
|
||||
return $initialString . "/";
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
public function throwFileNotFound($file)
|
||||
{
|
||||
|
||||
throw new FileNotFoundException(
|
||||
$this->getTranslator()
|
||||
->trans(
|
||||
"The file %file is missing or is not readable",
|
||||
[
|
||||
"%file" => $file,
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
@@ -1242,58 +595,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* @return Tlog
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Translator
|
||||
*/
|
||||
public function getTranslator()
|
||||
{
|
||||
return $this->translator;
|
||||
}
|
||||
|
||||
/**
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
* @return \ZipArchive
|
||||
*/
|
||||
public function getRawZipArchive()
|
||||
{
|
||||
return $this->zip;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
|
||||
public function getZipCacheFile()
|
||||
{
|
||||
return $this->zipCacheFile;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
public function getCacheDir()
|
||||
{
|
||||
return $this->cache_dir;
|
||||
}
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -17,47 +17,19 @@ namespace Thelia\Core\FileFormat\Archive;
|
||||
* @package Thelia\Core\FileFormat\Archive
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* This interface defines the methods that an archive builder must have.
|
||||
=======
|
||||
* This interface defines the methods that an archive creator must have.
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* This interface defines the methods that an archive builder must have.
|
||||
>>>>>>> Complete zip tests
|
||||
*/
|
||||
interface ArchiveBuilderInterface
|
||||
{
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
* @param string $filePath It is the path to access the file.
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
<<<<<<< HEAD
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
* @throws \ErrorException
|
||||
=======
|
||||
* @param string $filePath It is the path to access the file.
|
||||
* @param string $directoryInArchive This is the directory where it will be stored in the archive
|
||||
* @param null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||
* @param bool $isOnline
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @throws \ErrorException
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
*
|
||||
* This methods adds a file in the archive.
|
||||
* If the file is local, $isOnline must be false,
|
||||
@@ -66,20 +38,9 @@ interface ArchiveBuilderInterface
|
||||
public function addFile($filePath, $directoryInArchive = "/", $name = null, $isOnline = false);
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param $content
|
||||
* @param $name
|
||||
* @param string $directoryInArchive
|
||||
=======
|
||||
* @param $content
|
||||
* @param $name
|
||||
<<<<<<< HEAD
|
||||
* @param string $directoryInArchive
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $directoryInArchive
|
||||
>>>>>>> Fix cs
|
||||
* @return mixed
|
||||
* @throws \ErrorException
|
||||
*
|
||||
@@ -88,15 +49,7 @@ interface ArchiveBuilderInterface
|
||||
public function addFileFromString($content, $name, $directoryInArchive = "/");
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $pathToFile
|
||||
=======
|
||||
* @param string $pathToFile
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
* @param string $pathToFile
|
||||
>>>>>>> Fix cs
|
||||
* @return null|string
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\FileNotReadableException
|
||||
@@ -106,32 +59,16 @@ interface ArchiveBuilderInterface
|
||||
*/
|
||||
public function getFileContent($pathToFile);
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* @param $pathInArchive
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
=======
|
||||
* @param $pathInArchive
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param $pathInArchive
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
*
|
||||
* This method deletes a file in the archive
|
||||
*/
|
||||
public function deleteFile($pathInArchive);
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
* @param $directoryPath
|
||||
* @return $this
|
||||
* @throws \ErrorException
|
||||
@@ -139,73 +76,25 @@ interface ArchiveBuilderInterface
|
||||
* This method creates an empty directory
|
||||
*/
|
||||
public function addDirectory($directoryPath);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
/**
|
||||
* @params string $filename
|
||||
=======
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
/**
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
|
||||
/**
|
||||
* @params string $filename
|
||||
>>>>>>> Add filename in build archive response
|
||||
* @return \Thelia\Core\HttpFoundation\Response
|
||||
*
|
||||
* This method return an instance of a Response with the archive as content.
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function buildArchiveResponse($filename);
|
||||
|
||||
/**
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
=======
|
||||
public function buildArchiveResponse();
|
||||
=======
|
||||
public function buildArchiveResponse($filename);
|
||||
>>>>>>> Add filename in build archive response
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
* @param string $pathToArchive
|
||||
* @param bool $isOnline
|
||||
>>>>>>> Fix cs
|
||||
* @return $this
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \Thelia\Exception\HttpUrlException
|
||||
*
|
||||
* Loads an archive
|
||||
*/
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
public function loadArchive($pathToArchive, $isOnline = false);
|
||||
=======
|
||||
public static function loadArchive($pathToArchive, $environment, $isOnline = false);
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
public static function loadArchive($pathToArchive, $environment, $isOnline = false, FileDownloaderInterface $fileDownloader = null);
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
public function loadArchive($pathToArchive, $isOnline = false);
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
|
||||
/**
|
||||
* @param $pathToFile
|
||||
@@ -216,39 +105,11 @@ interface ArchiveBuilderInterface
|
||||
public function hasFile($pathToFile);
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $directory
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $directory
|
||||
>>>>>>> Fix cs
|
||||
* @return bool
|
||||
*
|
||||
* Check if the archive has a directory
|
||||
*/
|
||||
public function hasDirectory($directory);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
/**
|
||||
* @param string $environment
|
||||
* @return $this
|
||||
*
|
||||
* Sets the execution environment of the Kernel,
|
||||
* used to know which cache is used.
|
||||
*/
|
||||
public function setEnvironment($environment);
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -20,19 +20,8 @@ use Thelia\Core\Translation\Translator;
|
||||
*/
|
||||
class ArchiveBuilderManager
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Add getNames methods to managers
|
||||
/** @var array */
|
||||
protected $archiveBuilders = array();
|
||||
=======
|
||||
protected $archiveCreators = array();
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
protected $archiveBuilders = array();
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
|
||||
protected $environment;
|
||||
|
||||
@@ -41,9 +30,6 @@ class ArchiveBuilderManager
|
||||
$this->environment = $environment;
|
||||
}
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param AbstractArchiveBuilder $archiveBuilder
|
||||
* @return $this
|
||||
*/
|
||||
@@ -53,31 +39,6 @@ class ArchiveBuilderManager
|
||||
$archiveBuilder->setEnvironment($this->environment);
|
||||
|
||||
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||
=======
|
||||
* @param AbstractArchiveBuilder $archiveCreator
|
||||
=======
|
||||
* @param AbstractArchiveBuilder $archiveCreator
|
||||
>>>>>>> Fix cs
|
||||
=======
|
||||
* @param AbstractArchiveBuilder $archiveBuilder
|
||||
>>>>>>> Add getNames methods to managers
|
||||
* @return $this
|
||||
*/
|
||||
public function add(AbstractArchiveBuilder $archiveBuilder)
|
||||
{
|
||||
if (null !== $archiveBuilder) {
|
||||
$archiveBuilder->setEnvironment($this->environment);
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->archiveCreators[$archiveCreator->getName()] = $archiveCreator;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->archiveBuilders[$archiveCreator->getName()] = $archiveCreator;
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
=======
|
||||
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||
>>>>>>> Add getNames methods to managers
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -90,41 +51,16 @@ class ArchiveBuilderManager
|
||||
*/
|
||||
public function delete($name)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if (!array_key_exists($name, $this->archiveBuilders)) {
|
||||
$this->throwOutOfBounds($name);
|
||||
}
|
||||
|
||||
unset($this->archiveBuilders[$name]);
|
||||
=======
|
||||
if (!array_key_exists($name, $this->archiveCreators)) {
|
||||
throw new \OutOfBoundsException(
|
||||
Translator::getInstance()->trans(
|
||||
"The archive creator %name doesn't exist",
|
||||
[
|
||||
"%name" => $name
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
unset($this->archiveCreators[$name]);
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
if (!array_key_exists($name, $this->archiveBuilders)) {
|
||||
$this->throwOutOfBounds($name);
|
||||
}
|
||||
|
||||
unset($this->archiveBuilders[$name]);
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @return array
|
||||
*/
|
||||
public function getAll()
|
||||
@@ -168,55 +104,3 @@ class ArchiveBuilderManager
|
||||
);
|
||||
}
|
||||
}
|
||||
=======
|
||||
* @return array[AbstractArchiveBuilder]
|
||||
=======
|
||||
* @return array
|
||||
>>>>>>> Add getNames methods to managers
|
||||
*/
|
||||
public function getAll()
|
||||
{
|
||||
return $this->archiveBuilders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getNames()
|
||||
{
|
||||
$names = [];
|
||||
|
||||
/** @var AbstractArchiveBuilder $builder */
|
||||
foreach($this->archiveBuilders as $builder) {
|
||||
$names[] = $builder->getName();
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
public function get($name)
|
||||
{
|
||||
if (!array_key_exists($name, $this->archiveBuilders)) {
|
||||
$this->throwOutOfBounds($name);
|
||||
}
|
||||
|
||||
return $this->archiveBuilders[$name];
|
||||
}
|
||||
|
||||
protected function throwOutOfBounds($name)
|
||||
{
|
||||
throw new \OutOfBoundsException(
|
||||
Translator::getInstance()->trans(
|
||||
"The archive creator %name doesn't exist",
|
||||
[
|
||||
"%name" => $name
|
||||
]
|
||||
)
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -55,12 +55,4 @@ interface FormatInterface
|
||||
* return "application/json";
|
||||
*/
|
||||
public function getMimeType();
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
|
||||
namespace Thelia\Core\FileFormat\Formatting;
|
||||
use Thelia\Core\FileFormat\FormatInterface;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
>>>>>>> Remove conflicts
|
||||
|
||||
/**
|
||||
* Class AbstractFormatter
|
||||
@@ -25,9 +22,6 @@ use Thelia\Log\Tlog;
|
||||
*/
|
||||
abstract class AbstractFormatter implements FormatInterface, FormatterInterface
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
/** @var \Thelia\Core\Translation\Translator */
|
||||
protected $translator;
|
||||
|
||||
@@ -55,5 +49,4 @@ abstract class AbstractFormatter implements FormatInterface, FormatterInterface
|
||||
{
|
||||
return $this->aliases;
|
||||
}
|
||||
>>>>>>> Remove conflicts
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\FileFormat\Formatting\Formatter;
|
||||
use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterData;
|
||||
|
||||
/**
|
||||
* Class JsonFormatter
|
||||
* @package Thelia\Core\FileFormat\Formatting\Formatter
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class JsonFormatter extends AbstractFormatter
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the name of the format.
|
||||
*
|
||||
* example:
|
||||
* return "XML";
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "Json";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the extension of the file format, without the ".".
|
||||
* The string should be lowercase.
|
||||
*
|
||||
* example:
|
||||
* return "xml";
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return "json";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the mime type of the file format.
|
||||
*
|
||||
* example:
|
||||
* return "application/json";
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormatterData $data
|
||||
* @return mixed
|
||||
*
|
||||
* This method must use a FormatterData object and output
|
||||
* a formatted value.
|
||||
*/
|
||||
public function encode(FormatterData $data)
|
||||
{
|
||||
return json_encode($data->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $rawData
|
||||
* @return FormatterData
|
||||
*
|
||||
* This must takes raw data as argument and outputs
|
||||
* a FormatterData object.
|
||||
*/
|
||||
public function decode($rawData)
|
||||
{
|
||||
return (new FormatterData($this->getAliases()))->setData(
|
||||
json_decode($rawData, true)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\FileFormat\Formatting\Formatter;
|
||||
use Thelia\Core\FileFormat\Formatter\Exception\BadFormattedStringException;
|
||||
use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterData;
|
||||
|
||||
/**
|
||||
* Class XMLFormatter
|
||||
* @package Thelia\Core\FileFormat\Formatting\Formatter
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class XMLFormatter extends AbstractFormatter
|
||||
{
|
||||
public $root = "data";
|
||||
public $nodeName = "node";
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the name of the format.
|
||||
*
|
||||
* example:
|
||||
* return "XML";
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return "XML";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the extension of the file format, without the ".".
|
||||
* The string should be lowercase.
|
||||
*
|
||||
* example:
|
||||
* return "xml";
|
||||
*/
|
||||
public function getExtension()
|
||||
{
|
||||
return "xml";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* This method must return a string, the mime type of the file format.
|
||||
*
|
||||
* example:
|
||||
* return "application/json";
|
||||
*/
|
||||
public function getMimeType()
|
||||
{
|
||||
return "application/xml";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormatterData $data
|
||||
* @return mixed
|
||||
*
|
||||
* This method must use a FormatterData object and output
|
||||
* a formatted value.
|
||||
*/
|
||||
public function encode(FormatterData $data)
|
||||
{
|
||||
$arrayData = $data->getData();
|
||||
|
||||
$domDocument = new \DOMDocument("1.0");
|
||||
$container = $domDocument->appendChild(new \DOMElement($this->root));
|
||||
|
||||
foreach ($arrayData as $key=>$entry) {
|
||||
if (is_array($entry)) {
|
||||
$node = $container->appendChild(new \DOMElement($this->nodeName));
|
||||
$this->recursiveBuild($entry, $node);
|
||||
} else {
|
||||
$container->appendChild(new \DOMElement($key, $entry));
|
||||
}
|
||||
}
|
||||
|
||||
$domDocument->preserveWhiteSpace = false;
|
||||
$domDocument->formatOutput = true;
|
||||
|
||||
return $domDocument->saveXML();
|
||||
}
|
||||
|
||||
protected function recursiveBuild(array $data, \DOMNode $node)
|
||||
{
|
||||
foreach ($data as $key=>$entry) {
|
||||
if (is_array($entry)) {
|
||||
$newNode = $node->appendChild(new \DOMElement($key));
|
||||
$this->recursiveBuild($entry, $newNode);
|
||||
} else {
|
||||
$node->appendChild(new \DOMElement($key, $entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $rawData
|
||||
* @return FormatterData
|
||||
*
|
||||
* This must takes raw data as argument and outputs
|
||||
* a FormatterData object.
|
||||
*/
|
||||
public function decode($rawData)
|
||||
{
|
||||
try {
|
||||
$xml = new \SimpleXMLElement($rawData);
|
||||
} catch (\Exception $e) {
|
||||
$errorMessage = $this->translator->trans(
|
||||
"You tried to load a bad formatted XML"
|
||||
);
|
||||
|
||||
$this->logger->error(
|
||||
$errorMessage .": ". $e->getMessage()
|
||||
);
|
||||
|
||||
throw new BadFormattedStringException(
|
||||
$errorMessage
|
||||
);
|
||||
}
|
||||
|
||||
$array = json_decode(json_encode($xml),true);
|
||||
|
||||
if (isset($array[$this->nodeName])) {
|
||||
$array += $array[$this->nodeName];
|
||||
unset($array[$this->nodeName]);
|
||||
}
|
||||
|
||||
$data = new FormatterData($this->getAliases());
|
||||
return $data->setData($array);
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,6 @@ namespace Thelia\Core\FileFormat\Formatting;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Propel\Runtime\Map\TableMap;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
>>>>>>> Remove conflicts
|
||||
=======
|
||||
>>>>>>> Restore
|
||||
/**
|
||||
* Class FormatterData
|
||||
* @package Thelia\Core\FileFormat\Formatting
|
||||
@@ -30,11 +22,7 @@ use Thelia\Model\Map\ProductTableMap;
|
||||
class FormatterData
|
||||
{
|
||||
/** @var array */
|
||||
<<<<<<< HEAD
|
||||
protected $data;
|
||||
=======
|
||||
protected $data = array();
|
||||
>>>>>>> Remove conflicts
|
||||
|
||||
/** @var null|array */
|
||||
protected $aliases;
|
||||
@@ -81,10 +69,7 @@ class FormatterData
|
||||
* @return $this
|
||||
*
|
||||
* Sets raw data with aliases
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
* may bug with some formatter
|
||||
>>>>>>> Remove conflicts
|
||||
*/
|
||||
public function setData(array $data)
|
||||
{
|
||||
@@ -171,8 +156,6 @@ class FormatterData
|
||||
return $formattedData;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
/**
|
||||
* @param array $row
|
||||
* @return $this
|
||||
@@ -234,17 +217,13 @@ class FormatterData
|
||||
return $this->applyAliases($data, array_flip($aliases));
|
||||
}
|
||||
|
||||
>>>>>>> Remove conflicts
|
||||
public function getData()
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
public function getDataReverseAliases()
|
||||
{
|
||||
return $this->reverseAliases($this->data, $this->aliases);
|
||||
}
|
||||
>>>>>>> Remove conflicts
|
||||
}
|
||||
|
||||
@@ -33,26 +33,11 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
Tlog::getNewInstance();
|
||||
|
||||
$this->tar = new TarArchiveBuilder();
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->tar->setEnvironment("dev");
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
$this->tar->setEnvironment("dev");
|
||||
>>>>>>> Fix FileDownloader test
|
||||
}
|
||||
|
||||
public function testAddFileAndDirectory()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
$this->tar->setEnvironment("dev");
|
||||
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Fix FileDownloader test
|
||||
/**
|
||||
* File
|
||||
*/
|
||||
@@ -97,20 +82,10 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($this->tar->hasDirectory("bar"));
|
||||
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Complete zip tests
|
||||
|
||||
public function testAddValidFileFromString()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->tar->addFileFromString(
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
$this->tar->addFileFromString(
|
||||
>>>>>>> Fix FileDownloader test
|
||||
"foo", "bar"
|
||||
);
|
||||
|
||||
@@ -122,7 +97,6 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
"foo",
|
||||
$this->tar->getFileContent("bar")
|
||||
);
|
||||
<<<<<<< HEAD
|
||||
|
||||
$this->tar->addFileFromString(
|
||||
"foo", "bar", "baz"
|
||||
@@ -315,216 +289,3 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
=======
|
||||
>>>>>>> Fix FileDownloader test
|
||||
=======
|
||||
>>>>>>> Fix FileDownloader test
|
||||
|
||||
$this->tar->addFileFromString(
|
||||
"foo", "bar", "baz"
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->tar->hasFile("baz/bar")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->tar->getFileContent("baz/bar")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \ErrorException
|
||||
*/
|
||||
public function testAddNotValidFileFromString()
|
||||
{
|
||||
$this->tar->addFileFromString(
|
||||
"foo", $this
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \ErrorException
|
||||
*/
|
||||
public function testAddNotValidFileValueFromString()
|
||||
{
|
||||
$this->tar->addFileFromString(
|
||||
$this, "foo"
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeleteFile()
|
||||
{
|
||||
$this->tar->addFileFromString(
|
||||
"foo", "bar"
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$this->tar->hasFile("bar")
|
||||
);
|
||||
|
||||
$this->tar->deleteFile("bar");
|
||||
|
||||
$this->assertFalse(
|
||||
$this->tar->hasFile("bar")
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
>>>>>>> Complete zip tests
|
||||
=======
|
||||
|
||||
public function testLoadValidArchive()
|
||||
{
|
||||
$tar = $this->tar->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.tar"
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
get_class($this->tar),
|
||||
$tar
|
||||
);
|
||||
|
||||
$this->assertTrue(
|
||||
$tar->hasFile("LICENSE.txt")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\TarArchiveException
|
||||
*/
|
||||
public function testLoadInvalidArchive()
|
||||
{
|
||||
$tar = $this->tar->loadArchive(
|
||||
__DIR__ . DS . "TestResources/bad_formatted.tar"
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatDirectoryPath()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"foo/",
|
||||
$this->tar->formatDirectoryPath("foo")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/",
|
||||
$this->tar->formatDirectoryPath("/foo")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/",
|
||||
$this->tar->formatDirectoryPath("foo/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/",
|
||||
$this->tar->formatDirectoryPath("/foo/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/",
|
||||
$this->tar->formatDirectoryPath("foo/bar")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/",
|
||||
$this->tar->formatDirectoryPath("/foo/bar")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/",
|
||||
$this->tar->formatDirectoryPath("/foo//bar/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/",
|
||||
$this->tar->formatDirectoryPath("/foo/bar/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/baz/",
|
||||
$this->tar->formatDirectoryPath("foo/bar/baz")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/baz/",
|
||||
$this->tar->formatDirectoryPath("//foo/bar///baz/")
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatFilePath()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->tar->formatFilePath("foo")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->tar->formatFilePath("/foo")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->tar->formatFilePath("foo/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->tar->formatFilePath("/foo/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar",
|
||||
$this->tar->formatFilePath("foo/bar")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar",
|
||||
$this->tar->formatFilePath("/foo/bar")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar",
|
||||
$this->tar->formatFilePath("/foo//bar/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar",
|
||||
$this->tar->formatFilePath("/foo/bar/")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/baz",
|
||||
$this->tar->formatFilePath("foo/bar/baz")
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo/bar/baz",
|
||||
$this->tar->formatFilePath("//foo/bar///baz/")
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
>>>>>>> Finish Tar archive builder
|
||||
=======
|
||||
|
||||
public function testCompression()
|
||||
{
|
||||
$this->assertEquals(
|
||||
null,
|
||||
$this->tar->getCompression()
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -35,12 +35,4 @@ class TarBz2ArchiveBuilderTest extends TarArchiveBuilderTest
|
||||
$this->tar->getCompression()
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -12,13 +12,6 @@
|
||||
|
||||
namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder;
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
use Thelia\Core\HttpFoundation\Response;
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
>>>>>>> Fix cs
|
||||
|
||||
/**
|
||||
* Class TarGzArchiveBuilderTest
|
||||
@@ -42,12 +35,4 @@ class TarGzArchiveBuilderTest extends TarArchiveBuilderTest
|
||||
$this->tar->getCompression()
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
foo
|
||||
bar
|
||||
|
||||
@@ -40,325 +40,126 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$this->zip = new ZipArchiveBuilder();
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->setEnvironment("dev");
|
||||
|
||||
$this->loadedZip = $this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||
=======
|
||||
$this->loadedZip = $this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||
"dev"
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->setEnvironment("dev");
|
||||
|
||||
$this->loadedZip = $this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method formats a path to be compatible with \ZipArchive
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
*/
|
||||
public function testFormatFilePath()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
$this->zip->formatFilePath("foo")
|
||||
=======
|
||||
*
|
||||
*
|
||||
=======
|
||||
>>>>>>> Begin tar, tar.bz2 and tar.gz formatter, fix zip test resources
|
||||
*/
|
||||
public function testFormatFilePath()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
<<<<<<< HEAD
|
||||
$this->zip->getFilePath("foo")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("foo")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("/foo")
|
||||
=======
|
||||
$this->zip->getFilePath("/foo")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("/foo")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("foo/")
|
||||
=======
|
||||
$this->zip->getFilePath("foo/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("foo/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"foo",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("/foo/")
|
||||
=======
|
||||
$this->zip->getFilePath("/foo/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("/foo/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("foo/bar")
|
||||
=======
|
||||
$this->zip->getFilePath("foo/bar")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("foo/bar")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("/foo/bar")
|
||||
=======
|
||||
$this->zip->getFilePath("/foo/bar")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("/foo/bar")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("/foo//bar/")
|
||||
=======
|
||||
$this->zip->getFilePath("/foo//bar/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("/foo//bar/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("/foo/bar/")
|
||||
=======
|
||||
$this->zip->getFilePath("/foo/bar/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("/foo/bar/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/baz",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("foo/bar/baz")
|
||||
=======
|
||||
$this->zip->getFilePath("foo/bar/baz")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatFilePath("foo/bar/baz")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/baz",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatFilePath("//foo/bar///baz/")
|
||||
);
|
||||
}
|
||||
|
||||
public function testFormatDirectoryPath()
|
||||
<<<<<<< HEAD
|
||||
{
|
||||
$this->assertEquals(
|
||||
"/foo/",
|
||||
$this->zip->formatDirectoryPath("foo")
|
||||
=======
|
||||
$this->zip->getFilePath("//foo/bar///baz/")
|
||||
=======
|
||||
$this->zip->formatFilePath("//foo/bar///baz/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetDirectoryPath()
|
||||
=======
|
||||
>>>>>>> Finish Tar archive builder
|
||||
{
|
||||
$this->assertEquals(
|
||||
"/foo/",
|
||||
<<<<<<< HEAD
|
||||
$this->zip->getDirectoryPath("foo")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("foo")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("/foo")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("/foo")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("/foo")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("foo/")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("foo/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("foo/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("/foo/")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("/foo/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("/foo/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("foo/bar")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("foo/bar")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("foo/bar")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("/foo/bar")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("/foo/bar")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("/foo/bar")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("/foo//bar/")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("/foo//bar/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("/foo//bar/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("/foo/bar/")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("/foo/bar/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("/foo/bar/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/baz/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("foo/bar/baz")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("foo/bar/baz")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("foo/bar/baz")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"/foo/bar/baz/",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->formatDirectoryPath("//foo/bar///baz/")
|
||||
=======
|
||||
$this->zip->getDirectoryPath("//foo/bar///baz/")
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->formatDirectoryPath("//foo/bar///baz/")
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadValidZip()
|
||||
{
|
||||
$loadedZip = $this->zip->loadArchive(
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||
"dev"
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip"
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
|
||||
$this->assertInstanceOf(
|
||||
@@ -368,30 +169,13 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException
|
||||
=======
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveException
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
* @expectedExceptionMessage [Zip Error] The file is not a zip archive
|
||||
*/
|
||||
public function testLoadNotValidZip()
|
||||
{
|
||||
$this->zip->loadArchive(
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip"
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||
"dev"
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip"
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
@@ -401,80 +185,31 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
public function testLoadNotExistingFile()
|
||||
{
|
||||
$this->zip->loadArchive(
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip"
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||
"dev"
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip"
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
public function testLoadOnlineAvailableAndValidFile()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||
true
|
||||
=======
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||
"dev",
|
||||
true,
|
||||
FakeFileDownloader::getInstance()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/well_formatted.zip",
|
||||
true
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException
|
||||
=======
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\ZipArchiveException
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @expectedException \Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception\ZipArchiveException
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
* @expectedExceptionMessage [Zip Error] The file is not a zip archive
|
||||
*/
|
||||
public function testLoadOnlineAvailableAndNotValidFile()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||
true
|
||||
=======
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||
"dev",
|
||||
true,
|
||||
FakeFileDownloader::getInstance()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/bad_formatted.zip",
|
||||
true
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
@@ -483,27 +218,11 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testLoadOnlineNotExistingFile()
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||
true
|
||||
=======
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||
"dev",
|
||||
true,
|
||||
FakeFileDownloader::getInstance()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
$this->zip->setFileDownloader(FakeFileDownloader::getInstance());
|
||||
|
||||
$this->zip->loadArchive(
|
||||
__DIR__ . DS . "TestResources/this_file_doesn_t_exist.zip",
|
||||
true
|
||||
>>>>>>> Finish tar, tar.gz, tar.bz2 and tests
|
||||
);
|
||||
}
|
||||
|
||||
@@ -606,15 +325,7 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
public function testBuildArchiveResponse()
|
||||
{
|
||||
$loadedArchiveResponse = $this->loadedZip
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
->buildArchiveResponse("test")
|
||||
=======
|
||||
->buildArchiveResponse()
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
->buildArchiveResponse("test")
|
||||
>>>>>>> Fix Test
|
||||
;
|
||||
|
||||
$loadedArchiveResponseContent = $loadedArchiveResponse->getContent();
|
||||
@@ -626,10 +337,6 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
$loadedArchiveResponseContent
|
||||
);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
|
||||
public function testAddValidFileFromString()
|
||||
{
|
||||
@@ -645,10 +352,6 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
"foo",
|
||||
$this->loadedZip->getFileContent("bar")
|
||||
);
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Complete zip tests
|
||||
|
||||
$this->loadedZip->addFileFromString(
|
||||
"foo", "bar", "baz"
|
||||
@@ -662,11 +365,6 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
"foo",
|
||||
$this->loadedZip->getFileContent("baz/bar")
|
||||
);
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
>>>>>>> Complete zip tests
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -697,15 +395,4 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Finish implementing and testing zip
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -72,12 +72,4 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
||||
$this->manager->delete("foo");
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* This file is part of the Thelia package. */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : dev@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* For the full copyright and license information, please view the LICENSE.txt */
|
||||
/* file that was distributed with this source code. */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Tests\FileFormat\Formatting\Formatter;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Thelia\Core\FileFormat\Formatting\Formatter\XMLFormatter;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterData;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
/**
|
||||
* Class XMLFormatterTest
|
||||
* @package Thelia\Tests\FileFormat\Formatting\Formatter
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
class XMLFormatterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/** @var XMLFormatter */
|
||||
protected $formatter;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
new Translator(new Container());
|
||||
|
||||
$this->formatter = new XMLFormatter();
|
||||
}
|
||||
|
||||
public function testMetaData()
|
||||
{
|
||||
$this->assertEquals(
|
||||
"XML",
|
||||
$this->formatter->getName()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"xml",
|
||||
$this->formatter->getExtension()
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
"application/xml",
|
||||
$this->formatter->getMimeType()
|
||||
);
|
||||
}
|
||||
|
||||
public function testSimpleEncode()
|
||||
{
|
||||
$data = new FormatterData();
|
||||
|
||||
$data->setData(
|
||||
[
|
||||
"foo" => "bar"
|
||||
]
|
||||
);
|
||||
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$dom->appendChild(new \DOMElement("data"))
|
||||
->appendChild(new \DOMElement("foo", "bar"));
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$this->assertEquals(
|
||||
$dom->saveXML(),
|
||||
$this->formatter->encode($data)
|
||||
);
|
||||
}
|
||||
|
||||
public function testComplexEncode()
|
||||
{
|
||||
$data = new FormatterData();
|
||||
$this->formatter->nodeName = "baz";
|
||||
|
||||
$data->setData(
|
||||
[
|
||||
"foo" => "bar",
|
||||
[
|
||||
"name" => "banana",
|
||||
"type" => "fruit",
|
||||
],
|
||||
[
|
||||
"orange"=>[
|
||||
"type" => "fruit"
|
||||
],
|
||||
"banana"=>[
|
||||
"like" => "Yes"
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$base = $dom->appendChild(new \DOMElement("data"));
|
||||
$base->appendChild(new \DOMElement("foo", "bar"));
|
||||
|
||||
$baz = $base->appendChild(new \DOMElement("baz"));
|
||||
$baz->appendChild(new \DOMElement("name", "banana"));
|
||||
$baz->appendChild(new \DOMElement("type", "fruit"));
|
||||
|
||||
$baz = $base->appendChild(new \DOMElement("baz"));
|
||||
$orange = $baz->appendChild(new \DOMElement("orange"));
|
||||
$orange->appendChild(new \DOMElement("type","fruit"));
|
||||
$banana = $baz->appendChild(new \DOMElement("banana"));
|
||||
$banana->appendChild(new \DOMElement("like", "Yes"));
|
||||
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$this->assertEquals(
|
||||
$dom->saveXML(),
|
||||
$this->formatter->encode($data)
|
||||
);
|
||||
}
|
||||
|
||||
public function testSimpleDecode()
|
||||
{
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$dom->appendChild(new \DOMElement("data"))
|
||||
->appendChild(new \DOMElement("foo", "bar"));
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$raw = $dom->saveXML();
|
||||
|
||||
$data = $this->formatter->decode($raw);
|
||||
|
||||
$this->assertEquals(["foo" => "bar"], $data->getData());
|
||||
}
|
||||
|
||||
public function testComplexDecode()
|
||||
{
|
||||
$expectedData =
|
||||
[
|
||||
"foo" => "bar",
|
||||
[
|
||||
"name" => "banana",
|
||||
"type" => "fruit",
|
||||
],
|
||||
[
|
||||
"orange"=>[
|
||||
"type" => "fruit"
|
||||
],
|
||||
"banana"=>[
|
||||
"like" => "Yes"
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$base = $dom->appendChild(new \DOMElement("data"));
|
||||
$base->appendChild(new \DOMElement("foo", "bar"));
|
||||
|
||||
$baz = $base->appendChild(new \DOMElement("baz"));
|
||||
$baz->appendChild(new \DOMElement("name", "banana"));
|
||||
$baz->appendChild(new \DOMElement("type", "fruit"));
|
||||
|
||||
$baz = $base->appendChild(new \DOMElement("baz"));
|
||||
$orange = $baz->appendChild(new \DOMElement("orange"));
|
||||
$orange->appendChild(new \DOMElement("type","fruit"));
|
||||
$banana = $baz->appendChild(new \DOMElement("banana"));
|
||||
$banana->appendChild(new \DOMElement("like", "Yes"));
|
||||
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
|
||||
$this->formatter->nodeName = "baz";
|
||||
$data = $this->formatter->decode($dom->saveXML());
|
||||
|
||||
$this->assertEquals($expectedData, $data->getData());
|
||||
}
|
||||
}
|
||||
@@ -359,8 +359,6 @@ class FormatterDataTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expectedData,$formattedData);
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
public function testSetRawDataMultipleDepthWithReverseAliases() {
|
||||
$aliases = [
|
||||
"orange" => "foo",
|
||||
@@ -463,5 +461,4 @@ class FormatterDataTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($row, $data->popRow());
|
||||
$this->assertFalse($data->getRow());
|
||||
}
|
||||
>>>>>>> Remove conflicts
|
||||
}
|
||||
|
||||
@@ -22,18 +22,6 @@ use Thelia\Tools\FileDownload\FileDownloader;
|
||||
class FakeFileDownloader extends FileDownloader
|
||||
{
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Fix cs
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
* @throws \HttpUrlException
|
||||
@@ -50,13 +38,4 @@ class FakeFileDownloader extends FileDownloader
|
||||
throw new \ErrorException();
|
||||
}
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -14,15 +14,7 @@ namespace Thelia\Tests\Type;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Log\Tlog;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Tools\FileDownload\FileDownloader;
|
||||
=======
|
||||
use Thelia\Tools\FileDownloader;
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
use Thelia\Tools\FileDownload\FileDownloader;
|
||||
>>>>>>> Fix FileDownloader test
|
||||
|
||||
/**
|
||||
* Class FileDownloaderTest
|
||||
@@ -68,12 +60,4 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$this->downloader->download("https://github.com/thelia/thelia", "php://temp");
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs
|
||||
|
||||
@@ -17,14 +17,7 @@ use Thelia\Core\Translation\Translator as TheliaTranslator;
|
||||
use Thelia\Exception\FileNotFoundException;
|
||||
use Thelia\Exception\HttpUrlException;
|
||||
use Thelia\Log\Tlog;
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
use Thelia\Tools\URL;
|
||||
=======
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
use Thelia\Tools\URL;
|
||||
>>>>>>> Fix FileDownloader test
|
||||
|
||||
/**
|
||||
* Class FileDownloader
|
||||
@@ -52,18 +45,8 @@ class FileDownloader implements FileDownloaderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
* @throws \HttpUrlException
|
||||
@@ -142,15 +125,7 @@ class FileDownloader implements FileDownloaderInterface
|
||||
*/
|
||||
$file = @fopen($pathToStore, "w");
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
if ($file === false) {
|
||||
=======
|
||||
if($file === false) {
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
if ($file === false) {
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
$translatedErrorMessage = $this->translator->trans(
|
||||
"Failed to open a writing stream on the file: %file",
|
||||
[
|
||||
@@ -165,12 +140,4 @@ class FileDownloader implements FileDownloaderInterface
|
||||
fputs($file, $response);
|
||||
fclose($file);
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
|
||||
@@ -35,15 +35,7 @@ trait FileDownloaderAwareTrait
|
||||
}
|
||||
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
=======
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param FileDownloaderInterface $fileDownloader
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
* @return $this
|
||||
*/
|
||||
public function setFileDownloader(FileDownloaderInterface $fileDownloader)
|
||||
@@ -52,12 +44,4 @@ trait FileDownloaderAwareTrait
|
||||
|
||||
return $this;
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
|
||||
@@ -14,13 +14,6 @@ namespace Thelia\Tools\FileDownload;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
/**
|
||||
* Class FileDownloader
|
||||
* @package Thelia\Tools\FileDownload
|
||||
@@ -29,18 +22,8 @@ use Symfony\Component\Translation\Translator;
|
||||
interface FileDownloaderInterface
|
||||
{
|
||||
/**
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
* @param string $url
|
||||
* @param string $pathToStore
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
* @throws \Thelia\Exception\FileNotFoundException
|
||||
* @throws \ErrorException
|
||||
* @throws \HttpUrlException
|
||||
@@ -57,12 +40,4 @@ interface FileDownloaderInterface
|
||||
* Returns an hydrated instance
|
||||
*/
|
||||
public static function getInstance();
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
}
|
||||
=======
|
||||
}
|
||||
>>>>>>> Define archive builders and formatters
|
||||
=======
|
||||
}
|
||||
>>>>>>> Fix cs and add get method in managers
|
||||
|
||||
Reference in New Issue
Block a user