diff --git a/core/lib/Thelia/Controller/Admin/ImportExportController.php b/core/lib/Thelia/Controller/Admin/ImportExportController.php index 8bed0dbab..fd11c6af2 100644 --- a/core/lib/Thelia/Controller/Admin/ImportExportController.php +++ b/core/lib/Thelia/Controller/Admin/ImportExportController.php @@ -43,9 +43,16 @@ class ImportExportController extends BaseAdminController $this->formatterManager = $this->container->get("thelia.manager.formatter_manager"); } + /** + * @param integer $id + * @return Response + * + * This method is called when the route /admin/import/{id} + * is called with a POST request. + */ public function import($id) { - if (null === $import = $this->getImport($id)) { + if (null === $import = $this->getImport($id)) { return $this->render("404"); } @@ -55,6 +62,13 @@ class ImportExportController extends BaseAdminController $this->hydrate(); } + /** + * @param integer $id + * @return Response + * + * This method is called when the route /admin/export/{id} + * is called with a POST request. + */ public function export($id) { if (null === $export = $this->getExport($id)) { @@ -79,31 +93,15 @@ class ImportExportController extends BaseAdminController */ $handler = $export->getHandleClassInstance($this->container); - $types = $handler->getHandledType(); + $types = $handler->getHandledTypes(); - if (!is_array($types)) { - $types = [$types]; - } - - $formatters = []; - /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */ - foreach ($this->formatterManager->getAll() as $formatter) { - if (in_array($formatter->getExportType(), $types)) { - $formatters[$formatter->getName()] = $formatter->getName(); - } - } + $formatters = $this->formatterManager->getFormattersByTypes($types); /** * Define and validate the form */ - $form = new ExportForm( - $this->getRequest(), - "form", - array(), - array(), - $archiveBuilders, - $formatters - ); + $form = new ExportForm($this->getRequest()); + $errorMessage = null; try { @@ -205,9 +203,19 @@ class ImportExportController extends BaseAdminController return $this->exportView($id); } + /** + * @param integer $id + * @return Response + * + * This method is called when the route /admin/import/{id} + * is called with a GET request. + * + * It returns a modal view if the request is an AJAX one, + * otherwise it generates a "normal" back-office page + */ public function importView($id) { - if (null === $import = $this->getImport($id)) { + if (null === $import = $this->getImport($id)) { return $this->render("404"); } @@ -236,6 +244,11 @@ class ImportExportController extends BaseAdminController } } + /** + * Inject allowed formats + */ + $this->archiveBuilderManager; + /** Then render the form */ if ($this->getRequest()->isXmlHttpRequest()) { return $this->render("ajax/import-modal"); @@ -244,6 +257,16 @@ class ImportExportController extends BaseAdminController } } + /** + * @param integer $id + * @return Response + * + * This method is called when the route /admin/export/{id} + * is called with a GET request. + * + * It returns a modal view if the request is an AJAX one, + * otherwise it generates a "normal" back-office page + */ public function exportView($id) { if (null === $export = $this->getExport($id)) { @@ -305,4 +328,4 @@ class ImportExportController extends BaseAdminController return $export; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index 2b6ed5e96..697da722d 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -26,8 +26,8 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Loader\FileLoader; use Thelia\Core\Translation\Translator; -use Thelia\ImportExport\ExportHandler; -use Thelia\ImportExport\ImportHandler; +use Thelia\ImportExport\Export\ExportHandler; +use Thelia\ImportExport\Import\ImportHandler; use Thelia\Model\Export; use Thelia\Model\ExportCategory; use Thelia\Model\ExportCategoryQuery; @@ -381,7 +381,7 @@ class XmlFileLoader extends FileLoader "The class \"%class\" must extend %baseClass", [ "%class" => $class, - "%baseClass" => "Thelia\\ImportExport\\ExportHandler", + "%baseClass" => "Thelia\\ImportExport\\Export\\ExportHandler", ] ) ); diff --git a/core/lib/Thelia/Core/Event/ImportExport/Export.php b/core/lib/Thelia/Core/Event/ImportExport/Export.php index d6e51b28a..33f9ccc63 100644 --- a/core/lib/Thelia/Core/Event/ImportExport/Export.php +++ b/core/lib/Thelia/Core/Event/ImportExport/Export.php @@ -14,7 +14,7 @@ namespace Thelia\Core\Event\ImportExport; use Thelia\Core\Event\ActionEvent; use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder; use Thelia\Core\FileFormat\Formatting\AbstractFormatter; -use Thelia\ImportExport\ExportHandler; +use Thelia\ImportExport\Export\ExportHandler; /** * Class Export @@ -23,7 +23,7 @@ use Thelia\ImportExport\ExportHandler; */ class Export extends ActionEvent { - /** @var \Thelia\ImportExport\ExportHandler */ + /** @var \Thelia\ImportExport\Export\ExportHandler */ protected $handler; /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter */ @@ -34,7 +34,7 @@ class Export extends ActionEvent public function __construct( AbstractFormatter $formatter, - ExportHandler $handler, + \Thelia\ImportExport\Export\ExportHandler $handler, AbstractArchiveBuilder $archiveBuilder = null ) { $this->archiveBuilder = $archiveBuilder; @@ -81,7 +81,7 @@ class Export extends ActionEvent } /** - * @param ExportHandler $handler + * @param \Thelia\ImportExport\Export\ExportHandler $handler * @return $this */ public function setHandler(ExportHandler $handler) @@ -92,7 +92,7 @@ class Export extends ActionEvent } /** - * @return \Thelia\ImportExport\ExportHandler + * @return \Thelia\ImportExport\Export\ExportHandler */ public function getHandler() { diff --git a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php index 2168ed019..ee396f02f 100644 --- a/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php +++ b/core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php @@ -103,4 +103,39 @@ class ArchiveBuilderManager ) ); } + + /** + * @return array + * + * Return the extensions handled by archive builders + */ + public function getExtensions() + { + $extensions = []; + + /** @var AbstractArchiveBuilder $archiveBuilder */ + foreach ($this->archiveBuilders as $archiveBuilder) { + $extensions += [$archiveBuilder->getName() => $archiveBuilder->getExtension()]; + } + + return $extensions; + } + + /** + * @param $extension + * @return bool|AbstractArchiveBuilder + */ + public function getArchiveBuilderByExtension($extension) + { + $extensions = $this->getExtensions(); + + if (!in_array($extension, $extensions)) { + return false; + } else { + $flip = array_flip($extensions); + $archiveBuilderName = $flip[$extension]; + + return $this->archiveBuilders[$archiveBuilderName]; + } + } } diff --git a/core/lib/Thelia/ImportExport/Export/ExportType.php b/core/lib/Thelia/Core/FileFormat/FormatType.php similarity index 85% rename from core/lib/Thelia/ImportExport/Export/ExportType.php rename to core/lib/Thelia/Core/FileFormat/FormatType.php index 7b98edd4a..37b3988ce 100644 --- a/core/lib/Thelia/ImportExport/Export/ExportType.php +++ b/core/lib/Thelia/Core/FileFormat/FormatType.php @@ -10,24 +10,24 @@ /* file that was distributed with this source code. */ /*************************************************************************************/ -namespace Thelia\ImportExport\Export; +namespace Thelia\Core\FileFormat; /** - * Class ExportType - * @package Thelia\ImportExport\Export + * Class FormatType + * @package Thelia\Core\FileFormat * @author Benjamin Perche */ -class ExportType +class FormatType { /** * This type is for unbounded formats, in general serialization formats * example: XML, json, yaml */ - const EXPORT_UNBOUNDED = "export.unbounded"; + const UNBOUNDED = "export.unbounded"; /** * This type is for tabled format ( matrix ), most used by spreadsheet application. * example: CSV, ODS, XLS */ - const EXPORT_TABLE = "export.table"; -} \ No newline at end of file + const TABLE = "export.table"; +} diff --git a/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php b/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php index a8cd9f3dd..9e5213937 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php +++ b/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php @@ -13,7 +13,7 @@ namespace Thelia\Core\FileFormat\Formatting\Formatter; use Thelia\Core\FileFormat\Formatting\AbstractFormatter; use Thelia\Core\FileFormat\Formatting\FormatterData; -use Thelia\ImportExport\Export\ExportType; +use Thelia\Core\FileFormat\FormatType; /** * Class JsonFormatter @@ -88,8 +88,8 @@ class JsonFormatter extends AbstractFormatter ); } - public function getExportType() + public function getHandledType() { - return ExportType::EXPORT_UNBOUNDED; + return FormatType::UNBOUNDED; } } diff --git a/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php b/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php index 480054158..9351ebe7f 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php +++ b/core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php @@ -14,7 +14,7 @@ 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; -use Thelia\ImportExport\Export\ExportType; +use Thelia\Core\FileFormat\FormatType; /** * Class XMLFormatter @@ -157,8 +157,8 @@ class XMLFormatter extends AbstractFormatter return $data->setData($array); } - public function getExportType() + public function getHandledType() { - return ExportType::EXPORT_UNBOUNDED; + return FormatType::UNBOUNDED; } } diff --git a/core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php b/core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php index a68daac2d..93f018873 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php +++ b/core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php @@ -42,11 +42,11 @@ interface FormatterInterface * * return a string that defines the handled format type. * - * Thelia types are defined in \Thelia\ImportExport\Export\ExportType + * Thelia types are defined in \Thelia\Core\FileFormat\FormatType * * examples: - * return ExportType::EXPORT_TABLE; - * return ExportType::EXPORT_UNBOUNDED; + * return FormatType::TABLE; + * return FormatType::UNBOUNDED; */ - public function getExportType(); + public function getHandledType(); } diff --git a/core/lib/Thelia/Core/FileFormat/Formatting/FormatterManager.php b/core/lib/Thelia/Core/FileFormat/Formatting/FormatterManager.php index c5432ecf1..53c6a4f8e 100644 --- a/core/lib/Thelia/Core/FileFormat/Formatting/FormatterManager.php +++ b/core/lib/Thelia/Core/FileFormat/Formatting/FormatterManager.php @@ -99,4 +99,59 @@ class FormatterManager ) ); } + + /** + * @return array + * + * Return the extensions handled by archive builders + */ + public function getExtensions() + { + $extensions = []; + + /** @var AbstractFormatter $formatter */ + foreach ($this->formatters as $formatter) { + $extensions += [$formatter->getName() => $formatter->getExtension()]; + } + + return $extensions; + } + + /** + * @param $extension + * @return bool|AbstractFormatter + */ + public function getFormatterByExtension($extension) + { + $extensions = $this->getExtensions(); + + if (!in_array($extension, $extensions)) { + return false; + } else { + $flip = array_flip($extensions); + $formatterName = $flip[$extension]; + + return $this->formatters[$formatterName]; + } + } + + public function getFormattersByTypes($types) + { + if (!is_array($types)) { + $types = [$types]; + } + + $selectedFormatters = []; + + /** @var AbstractFormatter $formatter */ + foreach ($this->formatters as $formatter) { + $handledType = $formatter->getHandledType(); + + if (in_array($handledType, $types)) { + $selectedFormatters += [$formatter->getName() => $formatter]; + } + } + + return $selectedFormatters; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Formatter.php b/core/lib/Thelia/Core/Template/Loop/Formatter.php index 849f2ecd9..db76749f0 100644 --- a/core/lib/Thelia/Core/Template/Loop/Formatter.php +++ b/core/lib/Thelia/Core/Template/Loop/Formatter.php @@ -49,7 +49,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface if (null !== $export) { $handlerInstance = $export->getHandleClassInstance($this->container); - $types = $handlerInstance->getHandledType(); + $types = $handlerInstance->getHandledTypes(); if (is_scalar($types)) { $types = [$types]; @@ -57,7 +57,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */ foreach ($rawFormatters as $key=>$formatter) { - if (in_array($formatter->getExportType(), $types)) { + if (in_array($formatter->getHandledType(), $types)) { $formatters[$key] = $formatter; } } diff --git a/core/lib/Thelia/Core/Template/Loop/ImportExportCategory.php b/core/lib/Thelia/Core/Template/Loop/ImportExportCategory.php index 4d2aaf08e..c03fda4d0 100644 --- a/core/lib/Thelia/Core/Template/Loop/ImportExportCategory.php +++ b/core/lib/Thelia/Core/Template/Loop/ImportExportCategory.php @@ -14,7 +14,6 @@ namespace Thelia\Core\Template\Loop; use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\ModelCriteria; use Thelia\Core\Template\Element\BaseI18nLoop; -use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\PropelSearchLoopInterface; diff --git a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php index a55d746b6..30fdeeb23 100644 --- a/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php +++ b/core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php @@ -84,7 +84,7 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface break; case "quantity_reverse": $search->orderByQuantity(Criteria::DESC); - break; + break; case "min_price": $search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC); break; diff --git a/core/lib/Thelia/Form/ImportForm.php b/core/lib/Thelia/Form/ImportForm.php index 040f5feb0..b05e736fb 100644 --- a/core/lib/Thelia/Form/ImportForm.php +++ b/core/lib/Thelia/Form/ImportForm.php @@ -57,4 +57,4 @@ class ImportForm extends BaseForm return "thelia_import"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/ImportExport/ExportHandler.php b/core/lib/Thelia/ImportExport/AbstractHandler.php similarity index 75% rename from core/lib/Thelia/ImportExport/ExportHandler.php rename to core/lib/Thelia/ImportExport/AbstractHandler.php index 03000ae5f..6b7e7a622 100644 --- a/core/lib/Thelia/ImportExport/ExportHandler.php +++ b/core/lib/Thelia/ImportExport/AbstractHandler.php @@ -14,11 +14,11 @@ namespace Thelia\ImportExport; use Symfony\Component\DependencyInjection\ContainerInterface; /** - * Interface ExportHandler + * Class AbstractHandler * @package Thelia\ImportExport * @author Benjamin Perche */ -abstract class ExportHandler +abstract class AbstractHandler { protected $container; @@ -31,28 +31,21 @@ abstract class ExportHandler $this->container = $container; } - /** - * @return \Thelia\Core\FileFormat\Formatting\FormatterData - * - * The method builds the FormatterData for the formatter - */ - abstract public function buildFormatterData(); /** * @return string|array * - * Define all the type of export/formatters that this can handle + * Define all the type of formatters that this can handle * return a string if it handle a single type ( specific exports ), * or an array if multiple. * - * Thelia types are defined in \Thelia\ImportExport\Export\ExportType + * Thelia types are defined in \Thelia\Core\FileFormat\FormatType * * example: * return array( - * ExportType::EXPORT_TABLE, - * ExportType::EXPORT_UNBOUNDED, + * FormatType::TABLE, + * FormatType::UNBOUNDED, * ); */ - abstract public function getHandledType(); - + abstract public function getHandledTypes(); } \ No newline at end of file diff --git a/core/lib/Thelia/ImportExport/Export/ExportHandler.php b/core/lib/Thelia/ImportExport/Export/ExportHandler.php new file mode 100644 index 000000000..8694d86d4 --- /dev/null +++ b/core/lib/Thelia/ImportExport/Export/ExportHandler.php @@ -0,0 +1,30 @@ + + */ +abstract class ExportHandler extends AbstractHandler +{ + /** + * @return \Thelia\Core\FileFormat\Formatting\FormatterData + * + * The method builds the FormatterData for the formatter + */ + abstract public function buildFormatterData(); + +} \ No newline at end of file diff --git a/core/lib/Thelia/ImportExport/Export/MailingExport.php b/core/lib/Thelia/ImportExport/Export/MailingExport.php index 060d431ff..31f49f865 100644 --- a/core/lib/Thelia/ImportExport/Export/MailingExport.php +++ b/core/lib/Thelia/ImportExport/Export/MailingExport.php @@ -12,8 +12,8 @@ namespace Thelia\ImportExport\Export; use Thelia\Core\FileFormat\Formatting\FormatterData; +use Thelia\Core\FileFormat\FormatType; use Thelia\Core\Translation\Translator; -use Thelia\ImportExport\ExportHandler; use Thelia\Model\CustomerQuery; use Thelia\Model\Map\CustomerTableMap; use Thelia\Model\Map\NewsletterTableMap; @@ -85,19 +85,19 @@ class MailingExport extends ExportHandler * return a string if it handle a single type ( specific exports ), * or an array if multiple. * - * Thelia types are defined in \Thelia\ImportExport\Export\ExportType + * Thelia types are defined in \Thelia\Core\FileFormat\FormatType * * example: * return array( - * ExportType::EXPORT_TABLE, - * ExportType::EXPORT_UNBOUNDED, + * FormatType::TABLE, + * FormatType::UNBOUNDED, * ); */ - public function getHandledType() + public function getHandledTypes() { return array( - ExportType::EXPORT_TABLE, - ExportType::EXPORT_UNBOUNDED, + FormatType::TABLE, + FormatType::UNBOUNDED, ); } } \ No newline at end of file diff --git a/core/lib/Thelia/ImportExport/ImportHandler.php b/core/lib/Thelia/ImportExport/Import/ImportHandler.php similarity index 59% rename from core/lib/Thelia/ImportExport/ImportHandler.php rename to core/lib/Thelia/ImportExport/Import/ImportHandler.php index bda7df69e..f9c0638a3 100644 --- a/core/lib/Thelia/ImportExport/ImportHandler.php +++ b/core/lib/Thelia/ImportExport/Import/ImportHandler.php @@ -10,28 +10,17 @@ /* file that was distributed with this source code. */ /*************************************************************************************/ -namespace Thelia\ImportExport; -use Symfony\Component\DependencyInjection\ContainerInterface; +namespace Thelia\ImportExport\Import; use Thelia\Core\FileFormat\Formatting\FormatterData; +use Thelia\ImportExport\AbstractHandler; /** * Class ImportHandler * @package Thelia\ImportExport * @author Benjamin Perche */ -abstract class ImportHandler +abstract class ImportHandler extends AbstractHandler { - protected $container; - - /** - * @param ContainerInterface $container - * - * Dependency injection: load the container to be able to get parameters and services - */ - public function __construct(ContainerInterface $container) { - $this->container = $container; - } - /** * @param \Thelia\Core\FileFormat\Formatting\FormatterData * @return string|array error messages @@ -39,21 +28,4 @@ abstract class ImportHandler * The method does the import routine from a FormatterData */ abstract public function retrieveFromFormatterData(FormatterData $data); - - /** - * @return string|array - * - * Define all the type of import/formatters that this can handle - * return a string if it handle a single type ( specific exports ), - * or an array if multiple. - * - * Thelia types are defined in \Thelia\ImportExport\Export\ExportType - * - * example: - * return array( - * ExportType::EXPORT_TABLE, - * ExportType::EXPORT_UNBOUNDED, - * ); - */ - abstract public function getHandledType(); } \ No newline at end of file diff --git a/core/lib/Thelia/ImportExport/Import/ProductStockImport.php b/core/lib/Thelia/ImportExport/Import/ProductStockImport.php index 80dff2712..98d234973 100644 --- a/core/lib/Thelia/ImportExport/Import/ProductStockImport.php +++ b/core/lib/Thelia/ImportExport/Import/ProductStockImport.php @@ -14,8 +14,7 @@ namespace Thelia\ImportExport\Import; use Propel\Runtime\Collection\ObjectCollection; use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\Translation\Translator; -use Thelia\ImportExport\Export\ExportType; -use Thelia\ImportExport\ImportHandler; +use Thelia\Core\FileFormat\FormatType; use Thelia\Model\ProductSaleElementsQuery; /** @@ -66,19 +65,19 @@ class ProductStockImport extends ImportHandler * return a string if it handle a single type ( specific exports ), * or an array if multiple. * - * Thelia types are defined in \Thelia\ImportExport\Export\ExportType + * Thelia types are defined in \Thelia\Core\FileFormat\FormatType * * example: * return array( - * ExportType::EXPORT_TABLE, - * ExportType::EXPORT_UNBOUNDED, + * FormatType::TABLE, + * FormatType::UNBOUNDED, * ); */ - public function getHandledType() + public function getHandledTypes() { return array( - ExportType::EXPORT_TABLE, - ExportType::EXPORT_UNBOUNDED, + FormatType::TABLE, + FormatType::UNBOUNDED, ); } diff --git a/core/lib/Thelia/Model/Export.php b/core/lib/Thelia/Model/Export.php index f07fbfeaf..bcc25ffe8 100644 --- a/core/lib/Thelia/Model/Export.php +++ b/core/lib/Thelia/Model/Export.php @@ -6,7 +6,7 @@ use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\DependencyInjection\ContainerInterface; use Thelia\Core\Translation\Translator; use Thelia\ImportExport\DocumentsExportInterface; -use Thelia\ImportExport\ExportHandler; +use Thelia\ImportExport\Export\ExportHandler; use Thelia\ImportExport\ImagesExportInterface; use Thelia\Model\Base\Export as BaseExport; use Thelia\Model\Map\ExportTableMap; @@ -97,8 +97,8 @@ class Export extends BaseExport } /** - * @param ContainerInterface $container - * @return ExportHandler + * @param ContainerInterface $container + * @return \Thelia\ImportExport\Export\ExportHandler * @throws \ErrorException */ public function getHandleClassInstance(ContainerInterface $container) @@ -128,7 +128,7 @@ class Export extends BaseExport "The class \"%class\" must implement %interface", [ "%class" => $class, - "%interface" => "\\Thelia\\ImportExport\\ExportHandler", + "%interface" => "\\Thelia\\ImportExport\\Export\\ExportHandler", ] ) ); diff --git a/core/lib/Thelia/Model/Import.php b/core/lib/Thelia/Model/Import.php index 929e15a12..f0e377847 100644 --- a/core/lib/Thelia/Model/Import.php +++ b/core/lib/Thelia/Model/Import.php @@ -4,8 +4,7 @@ namespace Thelia\Model; use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\DependencyInjection\ContainerInterface; -use Thelia\ImportExport\ExportHandler; -use Thelia\ImportExport\ImportHandler; +use Thelia\ImportExport\Import\ImportHandler; use Thelia\Model\Base\Import as BaseImport; use Thelia\Model\Map\ImportTableMap; @@ -92,7 +91,6 @@ class Import extends BaseImport return $this; } - public function getHandleClassInstance(ContainerInterface $container) { $class = $this->getHandleClass(); @@ -113,7 +111,7 @@ class Import extends BaseImport "The class \"%class\" must implement %interface", [ "%class" => $class, - "%interface" => "\\Thelia\\ImportExport\\ImportHandler", + "%interface" => "\\Thelia\\ImportExport\\Import\\ImportHandler", ] ); } diff --git a/core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php b/core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php index fd45426c5..fb5aa57be 100644 --- a/core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php +++ b/core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php @@ -13,7 +13,7 @@ namespace Thelia\Tests\ImportExport\Export; use Symfony\Component\DependencyInjection\Container; use Thelia\Core\Translation\Translator; -use Thelia\ImportExport\Export\ExportType; +use Thelia\Core\FileFormat\FormatType; use Thelia\ImportExport\Export\MailingExport; /** @@ -45,8 +45,8 @@ class MailingExportTest extends \PHPUnit_Framework_TestCase public function testType() { $this->assertEquals( - [ExportType::EXPORT_TABLE, ExportType::EXPORT_UNBOUNDED], - $this->handler->getHandledType() + [\Thelia\Core\FileFormat\FormatType::TABLE, FormatType::UNBOUNDED], + $this->handler->getHandledTypes() ); } } \ No newline at end of file diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index ab52472e6..54ed6a42d 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -171,12 +171,11 @@ class URL // url could contain anchor $pos = strrpos($base, '#'); - if($pos !== false) { + if ($pos !== false) { $anchor = substr($base, $pos); $base = substr($base, 0, $pos); } - $base = rtrim($base, "?&"); $sepChar = strstr($base, '?') === false ? '?' : '&'; diff --git a/templates/backOffice/default/ajax/import-modal.html b/templates/backOffice/default/ajax/import-modal.html index 2cc37c93a..3d80e9ecc 100644 --- a/templates/backOffice/default/ajax/import-modal.html +++ b/templates/backOffice/default/ajax/import-modal.html @@ -10,6 +10,7 @@