Fix cs
modifié: core/lib/Thelia/Core/FileFormat/Archive/AbstractArchiveBuilder.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/TarArchiveException.php modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/Exception/ZipArchiveException.php 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/Formatter/AbstractFormatter.php modifié: core/lib/Thelia/Core/FileFormat/Formatter/Exception/BadFormattedStringException.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatter/FormatterInterface.php modifié: core/lib/Thelia/Core/FileFormat/Formatter/FormatterManager.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/ZipArchiveBuilderTest.php modifié: core/lib/Thelia/Tests/FileFormat/Archive/ArchiveBuilderManagerTest.php modifié: core/lib/Thelia/Tests/FileFormat/Formatter/FormatterManagerTest.php modifié: core/lib/Thelia/Tests/Tools/FakeFileDownloader.php modifié: core/lib/Thelia/Tests/Tools/FileDownloaderTest.php
This commit is contained in:
@@ -201,7 +201,7 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $environment
|
* @param string $environment
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* Sets the execution environment of the Kernel,
|
* Sets the execution environment of the Kernel,
|
||||||
@@ -211,4 +211,4 @@ abstract class AbstractArchiveBuilder implements FormatInterface, ArchiveBuilder
|
|||||||
{
|
{
|
||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception;
|
|||||||
class TarArchiveException extends \Exception
|
class TarArchiveException extends \Exception
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Archive\ArchiveBuilder\Exception;
|
|||||||
class ZipArchiveException extends \ErrorException
|
class ZipArchiveException extends \ErrorException
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,10 +57,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filePath It is the path to access the file.
|
* @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 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 null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -107,7 +107,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
/**
|
/**
|
||||||
* @param $content
|
* @param $content
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param string $directoryInArchive
|
* @param string $directoryInArchive
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
*
|
*
|
||||||
@@ -132,7 +132,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
$this->tar->addFromString($name, $content);
|
$this->tar->addFromString($name, $content);
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
$this->translator->trans(
|
$this->translator->trans(
|
||||||
"Error while writing the file into the archive, error message: %errmes",
|
"Error while writing the file into the archive, error message: %errmes",
|
||||||
@@ -144,7 +144,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $directoryPath
|
* @param $directoryPath
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -160,7 +159,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
$this->tar->addEmptyDir($directoryInArchive);
|
$this->tar->addEmptyDir($directoryInArchive);
|
||||||
} catch(\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
$this->translator->trans(
|
$this->translator->trans(
|
||||||
"The directory %dir has not been created in the archive",
|
"The directory %dir has not been created in the archive",
|
||||||
@@ -176,7 +175,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToFile
|
* @param string $pathToFile
|
||||||
* @return null|string
|
* @return null|string
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -206,7 +205,6 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $pathInArchive
|
* @param $pathInArchive
|
||||||
* @return $this
|
* @return $this
|
||||||
@@ -269,10 +267,10 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToArchive
|
* @param string $pathToArchive
|
||||||
* @param string $environment
|
* @param string $environment
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @param FileDownloaderInterface $fileDownloader
|
* @param FileDownloaderInterface $fileDownloader
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\HttpUrlException
|
* @throws \Thelia\Exception\HttpUrlException
|
||||||
@@ -292,6 +290,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* This throws TarArchiveBuilderException if
|
* This throws TarArchiveBuilderException if
|
||||||
* the archive is not valid.
|
* the archive is not valid.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return $tar->setEnvironment($tar->environment);
|
return $tar->setEnvironment($tar->environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -312,19 +311,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
/** @var \PharFileInfo $fileInfo */
|
/** @var \PharFileInfo $fileInfo */
|
||||||
$fileInfo = $this->tar[$pathToFile];
|
$fileInfo = $this->tar[$pathToFile];
|
||||||
|
|
||||||
if($fileInfo->isFile()) {
|
if ($fileInfo->isFile()) {
|
||||||
$isFile = true;
|
$isFile = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Catch the exception to avoid its displaying.
|
* Catch the exception to avoid its displaying.
|
||||||
*/
|
*/
|
||||||
} catch(\BadMethodCallException $e) {}
|
} catch (\BadMethodCallException $e) {}
|
||||||
|
|
||||||
return $isFile;
|
return $isFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* Check if the archive has a directory
|
* Check if the archive has a directory
|
||||||
@@ -338,19 +337,19 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
/** @var \PharFileInfo $fileInfo */
|
/** @var \PharFileInfo $fileInfo */
|
||||||
$fileInfo = $this->tar[$pathToDir];
|
$fileInfo = $this->tar[$pathToDir];
|
||||||
|
|
||||||
if($fileInfo->isDir()) {
|
if ($fileInfo->isDir()) {
|
||||||
$isDir = true;
|
$isDir = true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Catch the exception to avoid its displaying.
|
* Catch the exception to avoid its displaying.
|
||||||
*/
|
*/
|
||||||
} catch(\BadMethodCallException $e) {}
|
} catch (\BadMethodCallException $e) {}
|
||||||
|
|
||||||
return $isDir;
|
return $isDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $environment
|
* @param string $environment
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* Sets the execution environment of the Kernel,
|
* Sets the execution environment of the Kernel,
|
||||||
@@ -383,13 +382,12 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
$this->compressionEntryPoint();
|
$this->compressionEntryPoint();
|
||||||
|
|
||||||
|
} catch (\BadMethodCallException $e) {
|
||||||
} catch(\BadMethodCallException $e) {
|
|
||||||
/**
|
/**
|
||||||
* This should not happen
|
* This should not happen
|
||||||
*/
|
*/
|
||||||
$errorMessage = "You have badly called the method setEnvironment twice for %file";
|
$errorMessage = "You have badly called the method setEnvironment twice for %file";
|
||||||
} catch(\UnexpectedValueException $e) {
|
} catch (\UnexpectedValueException $e) {
|
||||||
$errorMessage = "The file %file is corrupted";
|
$errorMessage = "The file %file is corrupted";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +409,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid file path for \ZipArchive
|
* Gives a valid file path for \ZipArchive
|
||||||
@@ -432,7 +430,7 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid directory path for \ZipArchive
|
* Gives a valid directory path for \ZipArchive
|
||||||
@@ -496,4 +494,4 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->compression;
|
return $this->compression;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,4 +49,4 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* On the destruction of the class,
|
* On the destruction of the class,
|
||||||
* remove the temporary file.
|
* remove the temporary file.
|
||||||
*/
|
*/
|
||||||
function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
if ($this->zip instanceof \ZipArchive) {
|
if ($this->zip instanceof \ZipArchive) {
|
||||||
@$this->zip->close();
|
@$this->zip->close();
|
||||||
@@ -59,10 +59,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filePath It is the path to access the file.
|
* @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 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 null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -80,7 +80,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
* Add empty directory if it doesn't exist
|
* Add empty directory if it doesn't exist
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(!empty($directoryInArchive)) {
|
if (!empty($directoryInArchive)) {
|
||||||
$this->addDirectory($directoryInArchive);
|
$this->addDirectory($directoryInArchive);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +127,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
/**
|
/**
|
||||||
* @param $content
|
* @param $content
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param string $directoryInArchive
|
* @param string $directoryInArchive
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
*
|
*
|
||||||
@@ -194,7 +194,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToFile
|
* @param string $pathToFile
|
||||||
* @return null|string
|
* @return null|string
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -224,7 +224,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid file path for \ZipArchive
|
* Gives a valid file path for \ZipArchive
|
||||||
@@ -244,11 +244,12 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
if (preg_match("#\/?[^\/]+\/[^\/]+\/?#", $initialString)) {
|
if (preg_match("#\/?[^\/]+\/[^\/]+\/?#", $initialString)) {
|
||||||
$initialString = "/" . $initialString;
|
$initialString = "/" . $initialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $initialString;
|
return $initialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid directory path for \ZipArchive
|
* Gives a valid directory path for \ZipArchive
|
||||||
@@ -336,9 +337,9 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToArchive
|
* @param string $pathToArchive
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @param FileDownloaderInterface $fileDownloader
|
* @param FileDownloaderInterface $fileDownloader
|
||||||
* @return ZipArchiveBuilder
|
* @return ZipArchiveBuilder
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\HttpUrlException
|
* @throws \Thelia\Exception\HttpUrlException
|
||||||
@@ -383,7 +384,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* Checks if the link $directory exists and if it's not a file.
|
* Checks if the link $directory exists and if it's not a file.
|
||||||
@@ -396,7 +397,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $environment
|
* @param string $environment
|
||||||
* @return $this
|
* @return $this
|
||||||
*
|
*
|
||||||
* Sets the execution environment of the Kernel,
|
* Sets the execution environment of the Kernel,
|
||||||
@@ -417,7 +418,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
\ZipArchive::CREATE
|
\ZipArchive::CREATE
|
||||||
);
|
);
|
||||||
|
|
||||||
if($opening !== true) {
|
if ($opening !== true) {
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
$this->translator->trans(
|
$this->translator->trans(
|
||||||
"An unknown error append"
|
"An unknown error append"
|
||||||
@@ -511,7 +512,7 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid file path for \ZipArchive
|
* Gives a valid file path for \ZipArchive
|
||||||
@@ -531,11 +532,12 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
if (preg_match("#\/?[^\/]+\/[^/]+\/?#", $initialString)) {
|
if (preg_match("#\/?[^\/]+\/[^/]+\/?#", $initialString)) {
|
||||||
$initialString = "/" . $initialString;
|
$initialString = "/" . $initialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $initialString;
|
return $initialString;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $initialString
|
* @param string $initialString
|
||||||
* @return string
|
* @return string
|
||||||
*
|
*
|
||||||
* Gives a valid directory path for \ZipArchive
|
* Gives a valid directory path for \ZipArchive
|
||||||
@@ -598,4 +600,4 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->zip;
|
return $this->zip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
namespace Thelia\Core\FileFormat\Archive;
|
namespace Thelia\Core\FileFormat\Archive;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface ArchiveBuilderInterface
|
* Interface ArchiveBuilderInterface
|
||||||
* @package Thelia\Core\FileFormat\Archive
|
* @package Thelia\Core\FileFormat\Archive
|
||||||
@@ -23,10 +22,10 @@ namespace Thelia\Core\FileFormat\Archive;
|
|||||||
interface ArchiveBuilderInterface
|
interface ArchiveBuilderInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $filePath It is the path to access the file.
|
* @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 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 null|string $name The name of the file in the archive. if it null or empty, it keeps the same name
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -41,7 +40,7 @@ interface ArchiveBuilderInterface
|
|||||||
/**
|
/**
|
||||||
* @param $content
|
* @param $content
|
||||||
* @param $name
|
* @param $name
|
||||||
* @param string $directoryInArchive
|
* @param string $directoryInArchive
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
*
|
*
|
||||||
@@ -50,7 +49,7 @@ interface ArchiveBuilderInterface
|
|||||||
public function addFileFromString($content, $name, $directoryInArchive = "/");
|
public function addFileFromString($content, $name, $directoryInArchive = "/");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToFile
|
* @param string $pathToFile
|
||||||
* @return null|string
|
* @return null|string
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\FileNotReadableException
|
* @throws \Thelia\Exception\FileNotReadableException
|
||||||
@@ -85,8 +84,8 @@ interface ArchiveBuilderInterface
|
|||||||
public function buildArchiveResponse();
|
public function buildArchiveResponse();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $pathToArchive
|
* @param string $pathToArchive
|
||||||
* @param bool $isOnline
|
* @param bool $isOnline
|
||||||
* @return $this
|
* @return $this
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \Thelia\Exception\HttpUrlException
|
* @throws \Thelia\Exception\HttpUrlException
|
||||||
@@ -104,11 +103,11 @@ interface ArchiveBuilderInterface
|
|||||||
public function hasFile($pathToFile);
|
public function hasFile($pathToFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $directory
|
* @param string $directory
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* Check if the archive has a directory
|
* Check if the archive has a directory
|
||||||
*/
|
*/
|
||||||
public function hasDirectory($directory);
|
public function hasDirectory($directory);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ArchiveBuilderManager
|
|||||||
$this->environment = $environment;
|
$this->environment = $environment;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param AbstractArchiveBuilder $archiveCreator
|
* @param AbstractArchiveBuilder $archiveCreator
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function add(AbstractArchiveBuilder $archiveCreator)
|
public function add(AbstractArchiveBuilder $archiveCreator)
|
||||||
@@ -73,4 +73,4 @@ class ArchiveBuilderManager
|
|||||||
{
|
{
|
||||||
return $this->archiveCreators;
|
return $this->archiveCreators;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,4 +55,4 @@ interface FormatInterface
|
|||||||
* return "application/json";
|
* return "application/json";
|
||||||
*/
|
*/
|
||||||
public function getMimeType();
|
public function getMimeType();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,24 +18,7 @@ use Thelia\Core\FileFormat\FormatInterface;
|
|||||||
* @package Thelia\Core\FileFormat\Formatter
|
* @package Thelia\Core\FileFormat\Formatter
|
||||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||||
*/
|
*/
|
||||||
abstract class AbstractFormatter implements FormatInterface
|
abstract class AbstractFormatter implements FormatInterface, FormatterInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
* @return mixed
|
|
||||||
*
|
|
||||||
* Encodes an array to the desired format.
|
|
||||||
* $data array only contains array and scalar data.
|
|
||||||
*/
|
|
||||||
abstract public function encode(array $data);
|
|
||||||
|
|
||||||
/**
|
}
|
||||||
* @param $data
|
|
||||||
* @return array
|
|
||||||
* @throws \Thelia\Core\FileFormat\Formatter\Exception\BadFormattedStringException
|
|
||||||
*
|
|
||||||
* this method must do exactly the opposite of encode and return
|
|
||||||
* an array composed of array and scalar data.
|
|
||||||
*/
|
|
||||||
abstract public function decode($data);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -20,4 +20,4 @@ namespace Thelia\Core\FileFormat\Formatter\Exception;
|
|||||||
class BadFormattedStringException extends \ErrorException
|
class BadFormattedStringException extends \ErrorException
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
23
core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php
Normal file
23
core/lib/Thelia/Core/FileFormat/Formatter/FormatterData.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?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\Formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class FormatterData
|
||||||
|
* @package Thelia\Core\FileFormat\Formatter
|
||||||
|
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||||
|
*/
|
||||||
|
class FormatterData
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<?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\Formatter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interface FormatterInterface
|
||||||
|
* @package Thelia\Core\FileFormat\Formatter
|
||||||
|
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||||
|
*/
|
||||||
|
interface FormatterInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param FormatterData $data
|
||||||
|
* @return mixed
|
||||||
|
*
|
||||||
|
* This method must use a FormatterData object and output
|
||||||
|
* a formatted value.
|
||||||
|
*/
|
||||||
|
public function encode(FormatterData $data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $rawData
|
||||||
|
* @return FormatterData
|
||||||
|
*
|
||||||
|
* This must takes raw data as argument and outputs
|
||||||
|
* a FormatterData object.
|
||||||
|
*/
|
||||||
|
public function decode($rawData);
|
||||||
|
}
|
||||||
@@ -18,7 +18,7 @@ use Thelia\Core\Translation\Translator;
|
|||||||
* @package Thelia\Core\FileFormat\Formatter
|
* @package Thelia\Core\FileFormat\Formatter
|
||||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||||
*/
|
*/
|
||||||
class FormatterManager
|
class FormatterManager
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $formatters = array();
|
protected $formatters = array();
|
||||||
@@ -66,4 +66,4 @@ class FormatterManager
|
|||||||
{
|
{
|
||||||
return $this->formatters;
|
return $this->formatters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->tar->formatDirectoryPath("//foo/bar///baz/")
|
$this->tar->formatDirectoryPath("//foo/bar///baz/")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFormatFilePath()
|
public function testFormatFilePath()
|
||||||
{
|
{
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@@ -288,4 +288,4 @@ class TarArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->tar->getCompression()
|
$this->tar->getCompression()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,4 +35,4 @@ class TarBz2ArchiveBuilderTest extends TarArchiveBuilderTest
|
|||||||
$this->tar->getCompression()
|
$this->tar->getCompression()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder;
|
namespace Thelia\Tests\FileFormat\Archive\ArchiveBuilder;
|
||||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
|
use Thelia\Core\FileFormat\Archive\ArchiveBuilder\TarGzArchiveBuilder;
|
||||||
use Thelia\Core\HttpFoundation\Response;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class TarGzArchiveBuilderTest
|
* Class TarGzArchiveBuilderTest
|
||||||
@@ -36,4 +35,4 @@ class TarGzArchiveBuilderTest extends TarArchiveBuilderTest
|
|||||||
$this->tar->getCompression()
|
$this->tar->getCompression()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,4 +395,4 @@ class ZipArchiveBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,4 +72,4 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->manager->delete("foo");
|
$this->manager->delete("foo");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,4 +71,4 @@ class FormatterManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->manager->delete("foo");
|
$this->manager->delete("foo");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ use Thelia\Tools\FileDownload\FileDownloader;
|
|||||||
class FakeFileDownloader extends FileDownloader
|
class FakeFileDownloader extends FileDownloader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @param string $pathToStore
|
* @param string $pathToStore
|
||||||
* @throws \Thelia\Exception\FileNotFoundException
|
* @throws \Thelia\Exception\FileNotFoundException
|
||||||
* @throws \ErrorException
|
* @throws \ErrorException
|
||||||
* @throws \HttpUrlException
|
* @throws \HttpUrlException
|
||||||
@@ -41,4 +41,4 @@ class FakeFileDownloader extends FileDownloader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,4 +60,4 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$this->downloader->download("https://github.com/thelia/thelia", "php://temp");
|
$this->downloader->download("https://github.com/thelia/thelia", "php://temp");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user