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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <bperche@openstudio.fr>
|
||||
*/
|
||||
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";
|
||||
}
|
||||
const TABLE = "export.table";
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -57,4 +57,4 @@ class ImportForm extends BaseForm
|
||||
return "thelia_import";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,11 +14,11 @@ namespace Thelia\ImportExport;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Interface ExportHandler
|
||||
* Class AbstractHandler
|
||||
* @package Thelia\ImportExport
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
30
core/lib/Thelia/ImportExport/Export/ExportHandler.php
Normal file
30
core/lib/Thelia/ImportExport/Export/ExportHandler.php
Normal 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();
|
||||
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 <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
|
||||
* @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();
|
||||
}
|
||||
@@ -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,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -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",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -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 ? '?' : '&';
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
<div class="modal-body">
|
||||
{custom_render_form_field form=$form field="file_upload"}
|
||||
<input type="file" required aria-required="true" name="{$name}" id="{$label_attr.for}" />
|
||||
<div class="small">Accepted formats: </div>
|
||||
{/custom_render_form_field}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
|
||||
Reference in New Issue
Block a user