Add content export
modifié: core/lib/Thelia/Config/Resources/export.xml modifié: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilder/TarArchiveBuilder.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/Formatting/Formatter/CSVFormatter.php nouveau fichier: core/lib/Thelia/ImportExport/Export/Type/ContentExport.php nouveau fichier: core/lib/Thelia/Tests/ImportExport/Export/ContentExportTest.php
This commit is contained in:
@@ -72,8 +72,14 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function addFile($filePath, $directoryInArchive = "/", $name = null, $isOnline = false)
|
||||
{
|
||||
if (!empty($name)) {
|
||||
$directoryInArchive .= DS . dirname($name);
|
||||
}
|
||||
|
||||
if (empty($name) || !is_scalar($name)) {
|
||||
$name = basename($filePath);
|
||||
} else {
|
||||
$name = basename($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,14 +34,10 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
||||
return "tar.gz";
|
||||
}
|
||||
|
||||
public function setEnvironment($environment)
|
||||
protected function compressionEntryPoint()
|
||||
{
|
||||
parent::setEnvironment($environment);
|
||||
|
||||
$this->previousFile = $this->cacheFile;
|
||||
|
||||
if ($this->compression != \Phar::GZ) {
|
||||
$this->tar = $this->tar->compress(\Phar::BZ2, $this->getExtension());
|
||||
$this->tar = $this->tar->compress(\Phar::GZ, $this->getExtension());
|
||||
}
|
||||
|
||||
$this->compression = \Phar::GZ;
|
||||
|
||||
@@ -74,6 +74,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
*/
|
||||
public function addFile($filePath, $directoryInArchive = null, $name = null, $isOnline = false)
|
||||
{
|
||||
if (!empty($name)) {
|
||||
$directoryInArchive .= DS . dirname($name) ;
|
||||
}
|
||||
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryInArchive);
|
||||
|
||||
/**
|
||||
@@ -86,6 +90,8 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
|
||||
if (empty($name) || !is_scalar($name)) {
|
||||
$name = basename($filePath);
|
||||
} else {
|
||||
$name = basename($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,7 +184,10 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
$directoryInArchive = $this->formatDirectoryPath($directoryPath);
|
||||
|
||||
if (!empty($directoryInArchive)) {
|
||||
if (!$this->zip->addEmptyDir($directoryInArchive)) {
|
||||
$this->zip->addEmptyDir($directoryInArchive);
|
||||
$this->commit();
|
||||
|
||||
if (!$this->hasDirectory($directoryInArchive)) {
|
||||
throw new \ErrorException(
|
||||
$this->translator->trans(
|
||||
"The directory %dir has not been created in the archive",
|
||||
|
||||
@@ -116,7 +116,9 @@ class CSVFormatter extends AbstractFormatter
|
||||
ksort($row);
|
||||
|
||||
foreach ($keys as $key) {
|
||||
$string .= $this->formatField($row[$key]);
|
||||
if (array_key_exists($key, $row)) {
|
||||
$string .= $this->formatField($row[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$string = substr($string,0, -$delimiterLength) . $this->lineReturn;
|
||||
|
||||
Reference in New Issue
Block a user