@@ -11,7 +11,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Cache\CacheEvent;
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Action;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Thelia\Core\Event\Cache\CacheEvent;
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
<service id="session.listener" class="Thelia\Core\EventListener\SessionListener">
|
||||
<tag name="kernel.event_subscriber"/>
|
||||
</service>
|
||||
|
||||
|
||||
<!-- Archive builders -->
|
||||
|
||||
<service id="thelia.manager.archive_builder_manager" class="Thelia\Core\FileFormat\Archive\ArchiveBuilderManager">
|
||||
|
||||
@@ -26,7 +26,6 @@ use Thelia\Files\FileModelInterface;
|
||||
use Thelia\Form\Exception\FormValidationException;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Model\Lang;
|
||||
use Thelia\Tools\MimeTypeTools;
|
||||
use Thelia\Tools\Rest\ResponseRest;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
@@ -61,7 +60,7 @@ class FileController extends BaseAdminController
|
||||
* @param string $parentType Parent Type owning files being saved (product, category, content, etc.)
|
||||
* @param string $objectType Object type, e.g. image or document
|
||||
* @param array $validMimeTypes an array of valid mime types. If empty, any mime type is allowed.
|
||||
* @param array $extBlackList an array of blacklisted extensions.
|
||||
* @param array $extBlackList an array of blacklisted extensions.
|
||||
* @return Response
|
||||
*/
|
||||
public function saveFileAjaxAction(
|
||||
|
||||
@@ -503,4 +503,9 @@ class TarArchiveBuilder extends AbstractArchiveBuilder
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return parent::isAvailable() && extension_loaded("bz2");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,4 +45,8 @@ class TarGzArchiveBuilder extends TarArchiveBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isAvailable()
|
||||
{
|
||||
return parent::isAvailable() && extension_loaded("zlib");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -610,4 +610,14 @@ class ZipArchiveBuilder extends AbstractArchiveBuilder
|
||||
{
|
||||
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);
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if (null !== $archiveBuilder) {
|
||||
if ($archiveBuilder->isAvailable()) {
|
||||
$archiveBuilder->setEnvironment($this->environment);
|
||||
|
||||
$this->archiveBuilders[$archiveBuilder->getName()] = $archiveBuilder;
|
||||
|
||||
@@ -39,7 +39,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAddArchiveBuilder()
|
||||
{
|
||||
/** @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);
|
||||
|
||||
@@ -53,7 +80,34 @@ class ArchiveBuilderManagerTest extends \PHPUnit_Framework_TestCase
|
||||
public function testDeleteArchiveBuilder()
|
||||
{
|
||||
/** @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);
|
||||
|
||||
|
||||
@@ -74,7 +74,9 @@ class ProductPricesExportTest extends \PHPUnit_Framework_TestCase
|
||||
$attributes = [];
|
||||
|
||||
foreach ($attributeCombinations as $attributeCombination) {
|
||||
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
||||
if (!in_array($attributeCombination->getAttributeAv()->getTitle(), $attributes)) {
|
||||
$attributes[] = $attributeCombination->getAttributeAv()->getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
$rowAttributes = explode(",", $row["attributes"]);
|
||||
|
||||
Reference in New Issue
Block a user