Refactor and fix CS

modifié:         core/lib/Thelia/Controller/Admin/ImportExportController.php
	modifié:         core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php
	modifié:         core/lib/Thelia/Core/Event/ImportExport/Export.php
	modifié:         core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManager.php
	renommé:         core/lib/Thelia/ImportExport/Export/ExportType.php -> core/lib/Thelia/Core/FileFormat/FormatType.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/Formatter/JsonFormatter.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/Formatter/XMLFormatter.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/FormatterInterface.php
	modifié:         core/lib/Thelia/Core/FileFormat/Formatting/FormatterManager.php
	modifié:         core/lib/Thelia/Core/Template/Loop/Formatter.php
	modifié:         core/lib/Thelia/Core/Template/Loop/ImportExportCategory.php
	modifié:         core/lib/Thelia/Core/Template/Loop/ProductSaleElements.php
	modifié:         core/lib/Thelia/Form/ImportForm.php
	renommé:         core/lib/Thelia/ImportExport/ExportHandler.php -> core/lib/Thelia/ImportExport/AbstractHandler.php
	nouveau fichier: core/lib/Thelia/ImportExport/Export/ExportHandler.php
	modifié:         core/lib/Thelia/ImportExport/Export/MailingExport.php
	renommé:         core/lib/Thelia/ImportExport/ImportHandler.php -> core/lib/Thelia/ImportExport/Import/ImportHandler.php
	modifié:         core/lib/Thelia/ImportExport/Import/ProductStockImport.php
	modifié:         core/lib/Thelia/Model/Export.php
	modifié:         core/lib/Thelia/Model/Import.php
	modifié:         core/lib/Thelia/Tests/ImportExport/Export/MailingExportTest.php
	modifié:         core/lib/Thelia/Tools/URL.php
	modifié:         templates/backOffice/default/ajax/import-modal.html
This commit is contained in:
Benjamin Perche
2014-07-17 10:52:17 +02:00
parent af5d355e19
commit a6f008fde2
23 changed files with 230 additions and 126 deletions

View File

@@ -43,9 +43,16 @@ class ImportExportController extends BaseAdminController
$this->formatterManager = $this->container->get("thelia.manager.formatter_manager"); $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) public function import($id)
{ {
if (null === $import = $this->getImport($id)) { if (null === $import = $this->getImport($id)) {
return $this->render("404"); return $this->render("404");
} }
@@ -55,6 +62,13 @@ class ImportExportController extends BaseAdminController
$this->hydrate(); $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) public function export($id)
{ {
if (null === $export = $this->getExport($id)) { if (null === $export = $this->getExport($id)) {
@@ -79,31 +93,15 @@ class ImportExportController extends BaseAdminController
*/ */
$handler = $export->getHandleClassInstance($this->container); $handler = $export->getHandleClassInstance($this->container);
$types = $handler->getHandledType(); $types = $handler->getHandledTypes();
if (!is_array($types)) { $formatters = $this->formatterManager->getFormattersByTypes($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();
}
}
/** /**
* Define and validate the form * Define and validate the form
*/ */
$form = new ExportForm( $form = new ExportForm($this->getRequest());
$this->getRequest(),
"form",
array(),
array(),
$archiveBuilders,
$formatters
);
$errorMessage = null; $errorMessage = null;
try { try {
@@ -205,9 +203,19 @@ class ImportExportController extends BaseAdminController
return $this->exportView($id); 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) public function importView($id)
{ {
if (null === $import = $this->getImport($id)) { if (null === $import = $this->getImport($id)) {
return $this->render("404"); return $this->render("404");
} }
@@ -236,6 +244,11 @@ class ImportExportController extends BaseAdminController
} }
} }
/**
* Inject allowed formats
*/
$this->archiveBuilderManager;
/** Then render the form */ /** Then render the form */
if ($this->getRequest()->isXmlHttpRequest()) { if ($this->getRequest()->isXmlHttpRequest()) {
return $this->render("ajax/import-modal"); 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) public function exportView($id)
{ {
if (null === $export = $this->getExport($id)) { if (null === $export = $this->getExport($id)) {
@@ -305,4 +328,4 @@ class ImportExportController extends BaseAdminController
return $export; return $export;
} }
} }

View File

@@ -26,8 +26,8 @@ use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Loader\FileLoader; use Symfony\Component\DependencyInjection\Loader\FileLoader;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\ExportHandler; use Thelia\ImportExport\Export\ExportHandler;
use Thelia\ImportExport\ImportHandler; use Thelia\ImportExport\Import\ImportHandler;
use Thelia\Model\Export; use Thelia\Model\Export;
use Thelia\Model\ExportCategory; use Thelia\Model\ExportCategory;
use Thelia\Model\ExportCategoryQuery; use Thelia\Model\ExportCategoryQuery;
@@ -381,7 +381,7 @@ class XmlFileLoader extends FileLoader
"The class \"%class\" must extend %baseClass", "The class \"%class\" must extend %baseClass",
[ [
"%class" => $class, "%class" => $class,
"%baseClass" => "Thelia\\ImportExport\\ExportHandler", "%baseClass" => "Thelia\\ImportExport\\Export\\ExportHandler",
] ]
) )
); );

View File

@@ -14,7 +14,7 @@ namespace Thelia\Core\Event\ImportExport;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder; use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
use Thelia\Core\FileFormat\Formatting\AbstractFormatter; use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
use Thelia\ImportExport\ExportHandler; use Thelia\ImportExport\Export\ExportHandler;
/** /**
* Class Export * Class Export
@@ -23,7 +23,7 @@ use Thelia\ImportExport\ExportHandler;
*/ */
class Export extends ActionEvent class Export extends ActionEvent
{ {
/** @var \Thelia\ImportExport\ExportHandler */ /** @var \Thelia\ImportExport\Export\ExportHandler */
protected $handler; protected $handler;
/** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter */ /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter */
@@ -34,7 +34,7 @@ class Export extends ActionEvent
public function __construct( public function __construct(
AbstractFormatter $formatter, AbstractFormatter $formatter,
ExportHandler $handler, \Thelia\ImportExport\Export\ExportHandler $handler,
AbstractArchiveBuilder $archiveBuilder = null AbstractArchiveBuilder $archiveBuilder = null
) { ) {
$this->archiveBuilder = $archiveBuilder; $this->archiveBuilder = $archiveBuilder;
@@ -81,7 +81,7 @@ class Export extends ActionEvent
} }
/** /**
* @param ExportHandler $handler * @param \Thelia\ImportExport\Export\ExportHandler $handler
* @return $this * @return $this
*/ */
public function setHandler(ExportHandler $handler) 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() public function getHandler()
{ {

View File

@@ -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];
}
}
} }

View File

@@ -10,24 +10,24 @@
/* file that was distributed with this source code. */ /* file that was distributed with this source code. */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\ImportExport\Export; namespace Thelia\Core\FileFormat;
/** /**
* Class ExportType * Class FormatType
* @package Thelia\ImportExport\Export * @package Thelia\Core\FileFormat
* @author Benjamin Perche <bperche@openstudio.fr> * @author Benjamin Perche <bperche@openstudio.fr>
*/ */
class ExportType class FormatType
{ {
/** /**
* This type is for unbounded formats, in general serialization formats * This type is for unbounded formats, in general serialization formats
* example: XML, json, yaml * 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. * This type is for tabled format ( matrix ), most used by spreadsheet application.
* example: CSV, ODS, XLS * example: CSV, ODS, XLS
*/ */
const EXPORT_TABLE = "export.table"; const TABLE = "export.table";
} }

View File

@@ -13,7 +13,7 @@
namespace Thelia\Core\FileFormat\Formatting\Formatter; namespace Thelia\Core\FileFormat\Formatting\Formatter;
use Thelia\Core\FileFormat\Formatting\AbstractFormatter; use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\ImportExport\Export\ExportType; use Thelia\Core\FileFormat\FormatType;
/** /**
* Class JsonFormatter * Class JsonFormatter
@@ -88,8 +88,8 @@ class JsonFormatter extends AbstractFormatter
); );
} }
public function getExportType() public function getHandledType()
{ {
return ExportType::EXPORT_UNBOUNDED; return FormatType::UNBOUNDED;
} }
} }

View File

@@ -14,7 +14,7 @@ namespace Thelia\Core\FileFormat\Formatting\Formatter;
use Thelia\Core\FileFormat\Formatter\Exception\BadFormattedStringException; use Thelia\Core\FileFormat\Formatter\Exception\BadFormattedStringException;
use Thelia\Core\FileFormat\Formatting\AbstractFormatter; use Thelia\Core\FileFormat\Formatting\AbstractFormatter;
use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\ImportExport\Export\ExportType; use Thelia\Core\FileFormat\FormatType;
/** /**
* Class XMLFormatter * Class XMLFormatter
@@ -157,8 +157,8 @@ class XMLFormatter extends AbstractFormatter
return $data->setData($array); return $data->setData($array);
} }
public function getExportType() public function getHandledType()
{ {
return ExportType::EXPORT_UNBOUNDED; return FormatType::UNBOUNDED;
} }
} }

View File

@@ -42,11 +42,11 @@ interface FormatterInterface
* *
* return a string that defines the handled format type. * 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: * examples:
* return ExportType::EXPORT_TABLE; * return FormatType::TABLE;
* return ExportType::EXPORT_UNBOUNDED; * return FormatType::UNBOUNDED;
*/ */
public function getExportType(); public function getHandledType();
} }

View File

@@ -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;
}
} }

View File

@@ -49,7 +49,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
if (null !== $export) { if (null !== $export) {
$handlerInstance = $export->getHandleClassInstance($this->container); $handlerInstance = $export->getHandleClassInstance($this->container);
$types = $handlerInstance->getHandledType(); $types = $handlerInstance->getHandledTypes();
if (is_scalar($types)) { if (is_scalar($types)) {
$types = [$types]; $types = [$types];
@@ -57,7 +57,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
/** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */ /** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */
foreach ($rawFormatters as $key=>$formatter) { foreach ($rawFormatters as $key=>$formatter) {
if (in_array($formatter->getExportType(), $types)) { if (in_array($formatter->getHandledType(), $types)) {
$formatters[$key] = $formatter; $formatters[$key] = $formatter;
} }
} }

View File

@@ -14,7 +14,6 @@ namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Element\PropelSearchLoopInterface; use Thelia\Core\Template\Element\PropelSearchLoopInterface;

View File

@@ -84,7 +84,7 @@ class ProductSaleElements extends BaseLoop implements PropelSearchLoopInterface
break; break;
case "quantity_reverse": case "quantity_reverse":
$search->orderByQuantity(Criteria::DESC); $search->orderByQuantity(Criteria::DESC);
break; break;
case "min_price": case "min_price":
$search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC); $search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC);
break; break;

View File

@@ -57,4 +57,4 @@ class ImportForm extends BaseForm
return "thelia_import"; return "thelia_import";
} }
} }

View File

@@ -14,11 +14,11 @@ namespace Thelia\ImportExport;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
* Interface ExportHandler * Class AbstractHandler
* @package Thelia\ImportExport * @package Thelia\ImportExport
* @author Benjamin Perche <bperche@openstudio.fr> * @author Benjamin Perche <bperche@openstudio.fr>
*/ */
abstract class ExportHandler abstract class AbstractHandler
{ {
protected $container; protected $container;
@@ -31,28 +31,21 @@ abstract class ExportHandler
$this->container = $container; $this->container = $container;
} }
/**
* @return \Thelia\Core\FileFormat\Formatting\FormatterData
*
* The method builds the FormatterData for the formatter
*/
abstract public function buildFormatterData();
/** /**
* @return string|array * @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 ), * return a string if it handle a single type ( specific exports ),
* or an array if multiple. * or an array if multiple.
* *
* Thelia types are defined in \Thelia\ImportExport\Export\ExportType * Thelia types are defined in \Thelia\Core\FileFormat\FormatType
* *
* example: * example:
* return array( * return array(
* ExportType::EXPORT_TABLE, * FormatType::TABLE,
* ExportType::EXPORT_UNBOUNDED, * FormatType::UNBOUNDED,
* ); * );
*/ */
abstract public function getHandledType(); abstract public function getHandledTypes();
} }

View File

@@ -0,0 +1,30 @@
<?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\ImportExport\Export;
use Thelia\ImportExport\AbstractHandler;
/**
* Interface ExportHandler
* @package Thelia\ImportExport
* @author Benjamin Perche <bperche@openstudio.fr>
*/
abstract class ExportHandler extends AbstractHandler
{
/**
* @return \Thelia\Core\FileFormat\Formatting\FormatterData
*
* The method builds the FormatterData for the formatter
*/
abstract public function buildFormatterData();
}

View File

@@ -12,8 +12,8 @@
namespace Thelia\ImportExport\Export; namespace Thelia\ImportExport\Export;
use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\Core\FileFormat\FormatType;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\ExportHandler;
use Thelia\Model\CustomerQuery; use Thelia\Model\CustomerQuery;
use Thelia\Model\Map\CustomerTableMap; use Thelia\Model\Map\CustomerTableMap;
use Thelia\Model\Map\NewsletterTableMap; use Thelia\Model\Map\NewsletterTableMap;
@@ -85,19 +85,19 @@ class MailingExport extends ExportHandler
* return a string if it handle a single type ( specific exports ), * return a string if it handle a single type ( specific exports ),
* or an array if multiple. * or an array if multiple.
* *
* Thelia types are defined in \Thelia\ImportExport\Export\ExportType * Thelia types are defined in \Thelia\Core\FileFormat\FormatType
* *
* example: * example:
* return array( * return array(
* ExportType::EXPORT_TABLE, * FormatType::TABLE,
* ExportType::EXPORT_UNBOUNDED, * FormatType::UNBOUNDED,
* ); * );
*/ */
public function getHandledType() public function getHandledTypes()
{ {
return array( return array(
ExportType::EXPORT_TABLE, FormatType::TABLE,
ExportType::EXPORT_UNBOUNDED, FormatType::UNBOUNDED,
); );
} }
} }

View File

@@ -10,28 +10,17 @@
/* file that was distributed with this source code. */ /* file that was distributed with this source code. */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\ImportExport; namespace Thelia\ImportExport\Import;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\ImportExport\AbstractHandler;
/** /**
* Class ImportHandler * Class ImportHandler
* @package Thelia\ImportExport * @package Thelia\ImportExport
* @author Benjamin Perche <bperche@openstudio.fr> * @author Benjamin Perche <bperche@openstudio.fr>
*/ */
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 * @param \Thelia\Core\FileFormat\Formatting\FormatterData
* @return string|array error messages * @return string|array error messages
@@ -39,21 +28,4 @@ abstract class ImportHandler
* The method does the import routine from a FormatterData * The method does the import routine from a FormatterData
*/ */
abstract public function retrieveFromFormatterData(FormatterData $data); 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();
} }

View File

@@ -14,8 +14,7 @@ namespace Thelia\ImportExport\Import;
use Propel\Runtime\Collection\ObjectCollection; use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Core\FileFormat\Formatting\FormatterData; use Thelia\Core\FileFormat\Formatting\FormatterData;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\Export\ExportType; use Thelia\Core\FileFormat\FormatType;
use Thelia\ImportExport\ImportHandler;
use Thelia\Model\ProductSaleElementsQuery; use Thelia\Model\ProductSaleElementsQuery;
/** /**
@@ -66,19 +65,19 @@ class ProductStockImport extends ImportHandler
* return a string if it handle a single type ( specific exports ), * return a string if it handle a single type ( specific exports ),
* or an array if multiple. * or an array if multiple.
* *
* Thelia types are defined in \Thelia\ImportExport\Export\ExportType * Thelia types are defined in \Thelia\Core\FileFormat\FormatType
* *
* example: * example:
* return array( * return array(
* ExportType::EXPORT_TABLE, * FormatType::TABLE,
* ExportType::EXPORT_UNBOUNDED, * FormatType::UNBOUNDED,
* ); * );
*/ */
public function getHandledType() public function getHandledTypes()
{ {
return array( return array(
ExportType::EXPORT_TABLE, FormatType::TABLE,
ExportType::EXPORT_UNBOUNDED, FormatType::UNBOUNDED,
); );
} }

View File

@@ -6,7 +6,7 @@ use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\DocumentsExportInterface; use Thelia\ImportExport\DocumentsExportInterface;
use Thelia\ImportExport\ExportHandler; use Thelia\ImportExport\Export\ExportHandler;
use Thelia\ImportExport\ImagesExportInterface; use Thelia\ImportExport\ImagesExportInterface;
use Thelia\Model\Base\Export as BaseExport; use Thelia\Model\Base\Export as BaseExport;
use Thelia\Model\Map\ExportTableMap; use Thelia\Model\Map\ExportTableMap;
@@ -97,8 +97,8 @@ class Export extends BaseExport
} }
/** /**
* @param ContainerInterface $container * @param ContainerInterface $container
* @return ExportHandler * @return \Thelia\ImportExport\Export\ExportHandler
* @throws \ErrorException * @throws \ErrorException
*/ */
public function getHandleClassInstance(ContainerInterface $container) public function getHandleClassInstance(ContainerInterface $container)
@@ -128,7 +128,7 @@ class Export extends BaseExport
"The class \"%class\" must implement %interface", "The class \"%class\" must implement %interface",
[ [
"%class" => $class, "%class" => $class,
"%interface" => "\\Thelia\\ImportExport\\ExportHandler", "%interface" => "\\Thelia\\ImportExport\\Export\\ExportHandler",
] ]
) )
); );

View File

@@ -4,8 +4,7 @@ namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\ImportExport\ExportHandler; use Thelia\ImportExport\Import\ImportHandler;
use Thelia\ImportExport\ImportHandler;
use Thelia\Model\Base\Import as BaseImport; use Thelia\Model\Base\Import as BaseImport;
use Thelia\Model\Map\ImportTableMap; use Thelia\Model\Map\ImportTableMap;
@@ -92,7 +91,6 @@ class Import extends BaseImport
return $this; return $this;
} }
public function getHandleClassInstance(ContainerInterface $container) public function getHandleClassInstance(ContainerInterface $container)
{ {
$class = $this->getHandleClass(); $class = $this->getHandleClass();
@@ -113,7 +111,7 @@ class Import extends BaseImport
"The class \"%class\" must implement %interface", "The class \"%class\" must implement %interface",
[ [
"%class" => $class, "%class" => $class,
"%interface" => "\\Thelia\\ImportExport\\ImportHandler", "%interface" => "\\Thelia\\ImportExport\\Import\\ImportHandler",
] ]
); );
} }

View File

@@ -13,7 +13,7 @@
namespace Thelia\Tests\ImportExport\Export; namespace Thelia\Tests\ImportExport\Export;
use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\Container;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\Export\ExportType; use Thelia\Core\FileFormat\FormatType;
use Thelia\ImportExport\Export\MailingExport; use Thelia\ImportExport\Export\MailingExport;
/** /**
@@ -45,8 +45,8 @@ class MailingExportTest extends \PHPUnit_Framework_TestCase
public function testType() public function testType()
{ {
$this->assertEquals( $this->assertEquals(
[ExportType::EXPORT_TABLE, ExportType::EXPORT_UNBOUNDED], [\Thelia\Core\FileFormat\FormatType::TABLE, FormatType::UNBOUNDED],
$this->handler->getHandledType() $this->handler->getHandledTypes()
); );
} }
} }

View File

@@ -171,12 +171,11 @@ class URL
// url could contain anchor // url could contain anchor
$pos = strrpos($base, '#'); $pos = strrpos($base, '#');
if($pos !== false) { if ($pos !== false) {
$anchor = substr($base, $pos); $anchor = substr($base, $pos);
$base = substr($base, 0, $pos); $base = substr($base, 0, $pos);
} }
$base = rtrim($base, "?&"); $base = rtrim($base, "?&");
$sepChar = strstr($base, '?') === false ? '?' : '&'; $sepChar = strstr($base, '?') === false ? '?' : '&';

View File

@@ -10,6 +10,7 @@
<div class="modal-body"> <div class="modal-body">
{custom_render_form_field form=$form field="file_upload"} {custom_render_form_field form=$form field="file_upload"}
<input type="file" required aria-required="true" name="{$name}" id="{$label_attr.for}" /> <input type="file" required aria-required="true" name="{$name}" id="{$label_attr.for}" />
<div class="small">Accepted formats: </div>
{/custom_render_form_field} {/custom_render_form_field}
</div> </div>
<div class="modal-footer"> <div class="modal-footer">