@@ -11,7 +11,6 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Cache\CacheEvent;
|
use Thelia\Core\Event\Cache\CacheEvent;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
/*************************************************************************************/
|
/*************************************************************************************/
|
||||||
|
|
||||||
namespace Thelia\Action;
|
namespace Thelia\Action;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||||
use Thelia\Core\Event\Cache\CacheEvent;
|
use Thelia\Core\Event\Cache\CacheEvent;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ use Thelia\Files\FileModelInterface;
|
|||||||
use Thelia\Form\Exception\FormValidationException;
|
use Thelia\Form\Exception\FormValidationException;
|
||||||
use Thelia\Log\Tlog;
|
use Thelia\Log\Tlog;
|
||||||
use Thelia\Model\Lang;
|
use Thelia\Model\Lang;
|
||||||
use Thelia\Tools\MimeTypeTools;
|
|
||||||
use Thelia\Tools\Rest\ResponseRest;
|
use Thelia\Tools\Rest\ResponseRest;
|
||||||
use Thelia\Tools\URL;
|
use Thelia\Tools\URL;
|
||||||
|
|
||||||
|
|||||||
@@ -503,4 +503,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->compression;
|
return $this->compression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return false === (bool) ini_get("phar.readonly") && class_exists("\\PharData");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,9 @@ class TarBz2ArchiveBuilder extends TarArchiveBuilder
|
|||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return parent::isAvailable() && extension_loaded("bz2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,8 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return parent::isAvailable() && extension_loaded("zlib");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,4 +610,14 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
|||||||
{
|
{
|
||||||
return $this->zip;
|
return $this->zip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* Returns conditions for archive builder to be available ( loaded libraries )
|
||||||
|
*/
|
||||||
|
public function isAvailable()
|
||||||
|
{
|
||||||
|
return class_exists('\\ZipArchive');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,4 +112,10 @@ interface ArchiveBuilderInterface
|
|||||||
*/
|
*/
|
||||||
public function hasDirectory($directory);
|
public function hasDirectory($directory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* Returns conditions for archive builder to be available ( loaded libraries )
|
||||||
|
*/
|
||||||
|
public function isAvailable();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class ArchiveBuilderManager
|
|||||||
*/
|
*/
|
||||||
public function add(AbstractArchiveBuilder $archiveBuilder)
|
public function add(AbstractArchiveBuilder $archiveBuilder)
|
||||||
{
|
{
|
||||||
if (null !== $archiveBuilder) {
|
if ($archiveBuilder->isAvailable()) {
|
||||||
$archiveBuilder->setEnvironment($this->environment);
|
$archiveBuilder->setEnvironment($this->environment);
|
||||||
|
|
||||||
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||||
|
|||||||
@@ -39,7 +39,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testAddArchiveBuilder()
|
public function testAddArchiveBuilder()
|
||||||
{
|
{
|
||||||
/** @var AbstractArchiveBuilder $instance */
|
/** @var AbstractArchiveBuilder $instance */
|
||||||
$instance = $this->getMock("Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder");
|
$instance = $this->getMock(
|
||||||
|
"Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder",
|
||||||
|
[
|
||||||
|
"isAvailable",
|
||||||
|
"getName",
|
||||||
|
"getExtension",
|
||||||
|
"getMimeType",
|
||||||
|
"addFile",
|
||||||
|
"addFileFromString",
|
||||||
|
"getFileContent",
|
||||||
|
"deleteFile",
|
||||||
|
"addDirectory",
|
||||||
|
"buildArchiveResponse",
|
||||||
|
"loadArchive",
|
||||||
|
"hasFile",
|
||||||
|
"hasDirectory",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$instance->expects($this->any())
|
||||||
|
->method("isAvailable")
|
||||||
|
->willReturn(true)
|
||||||
|
;
|
||||||
|
|
||||||
|
$instance->expects($this->any())
|
||||||
|
->method("getName")
|
||||||
|
->willReturn("foo")
|
||||||
|
;
|
||||||
|
|
||||||
$this->manager->add($instance);
|
$this->manager->add($instance);
|
||||||
|
|
||||||
@@ -53,7 +80,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
|||||||
public function testDeleteArchiveBuilder()
|
public function testDeleteArchiveBuilder()
|
||||||
{
|
{
|
||||||
/** @var AbstractArchiveBuilder $instance */
|
/** @var AbstractArchiveBuilder $instance */
|
||||||
$instance = $this->getMock("Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder");
|
$instance = $this->getMock(
|
||||||
|
"Thelia\\Core\\FileFormat\\Archive\\AbstractArchiveBuilder",
|
||||||
|
[
|
||||||
|
"isAvailable",
|
||||||
|
"getName",
|
||||||
|
"getExtension",
|
||||||
|
"getMimeType",
|
||||||
|
"addFile",
|
||||||
|
"addFileFromString",
|
||||||
|
"getFileContent",
|
||||||
|
"deleteFile",
|
||||||
|
"addDirectory",
|
||||||
|
"buildArchiveResponse",
|
||||||
|
"loadArchive",
|
||||||
|
"hasFile",
|
||||||
|
"hasDirectory",
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
$instance->expects($this->any())
|
||||||
|
->method("isAvailable")
|
||||||
|
->willReturn(true)
|
||||||
|
;
|
||||||
|
|
||||||
|
$instance->expects($this->any())
|
||||||
|
->method("getName")
|
||||||
|
->willReturn("foo")
|
||||||
|
;
|
||||||
|
|
||||||
$this->manager->add($instance);
|
$this->manager->add($instance);
|
||||||
|
|
||||||
|
|||||||
@@ -74,8 +74,10 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase
|
|||||||
$attributes = [];
|
$attributes = [];
|
||||||
|
|
||||||
foreach ($attributeCombinations as $attributeCombination) {
|
foreach ($attributeCombinations as $attributeCombination) {
|
||||||
|
if (!in_array($attributeCombination->getAttributeAv()->getTitle(), $attributes)) {
|
||||||
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$rowAttributes = explode(",", $row["attributes"]);
|
$rowAttributes = explode(",", $row["attributes"]);
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,7 @@
|
|||||||
</select>
|
</select>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
|
{ifloop rel="export-archive-builder"}
|
||||||
<div class="col-md-1"></div>
|
<div class="col-md-1"></div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{form_field form=$form field="do_compress"}
|
{form_field form=$form field="do_compress"}
|
||||||
@@ -104,6 +105,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/ifloop}
|
||||||
</div>
|
</div>
|
||||||
{/ifloop}
|
{/ifloop}
|
||||||
{elseloop rel="export-formatters"}
|
{elseloop rel="export-formatters"}
|
||||||
|
|||||||
@@ -86,6 +86,7 @@
|
|||||||
</select>
|
</select>
|
||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
|
{ifloop rel="export-archive-builder"}
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
{form_field form=$form field="do_compress"}
|
{form_field form=$form field="do_compress"}
|
||||||
<label for="{$label_attr.for}">
|
<label for="{$label_attr.for}">
|
||||||
@@ -144,6 +145,7 @@
|
|||||||
{/form_field}
|
{/form_field}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
{/ifloop}
|
||||||
</div>
|
</div>
|
||||||
{/ifloop}
|
{/ifloop}
|
||||||
{elseloop rel="export-formatters"}
|
{elseloop rel="export-formatters"}
|
||||||
|
|||||||
Reference in New Issue
Block a user