Finish Import / Export categories management
modifié: core/lib/Thelia/Config/Resources/routing/admin.xml modifié: core/lib/Thelia/Controller/Admin/ExportController.php modifié: core/lib/Thelia/Controller/Admin/ImportExportController.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/Template/Loop/Export.php modifié: core/lib/Thelia/Core/Template/Loop/Formatter.php nouveau fichier: core/lib/Thelia/ImportExport/Both/NewsletterImportExport.php nouveau fichier: core/lib/Thelia/ImportExport/Export/ExportType.php nouveau fichier: core/lib/Thelia/ImportExport/Export/MailingExport.php modifié: core/lib/Thelia/ImportExport/ExportHandlerInterface.php modifié: core/lib/Thelia/Model/Export.php modifié: core/lib/Thelia/Model/ExportCategory.php modifié: core/lib/Thelia/Model/ImportCategory.php modifié: templates/backOffice/default/export-page.html modifié: templates/backOffice/default/export.html modifié: templates/backOffice/default/import.html modifié: templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
@@ -13,6 +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;
|
||||
|
||||
/**
|
||||
* Class JsonFormatter
|
||||
@@ -87,4 +88,11 @@ class JsonFormatter extends AbstractFormatter
|
||||
);
|
||||
}
|
||||
|
||||
public function getExportType()
|
||||
{
|
||||
return array(
|
||||
ExportType::EXPORT_TABLE,
|
||||
ExportType::EXPORT_UNBOUNDED,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +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;
|
||||
|
||||
/**
|
||||
* Class XMLFormatter
|
||||
@@ -141,4 +142,12 @@ class XMLFormatter extends AbstractFormatter
|
||||
$data = new FormatterData($this->getAliases());
|
||||
return $data->setData($array);
|
||||
}
|
||||
|
||||
public function getExportType()
|
||||
{
|
||||
return array(
|
||||
ExportType::EXPORT_TABLE,
|
||||
ExportType::EXPORT_UNBOUNDED,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -36,4 +36,17 @@ interface FormatterInterface
|
||||
* a FormatterData object.
|
||||
*/
|
||||
public function decode($rawData);
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*
|
||||
* return a string that defines the handled format type.
|
||||
*
|
||||
* Thelia types are defined in \Thelia\ImportExport\Export\ExportType
|
||||
*
|
||||
* examples:
|
||||
* return ExportType::EXPORT_TABLE;
|
||||
* return ExportType::EXPORT_UNBOUNDED;
|
||||
*/
|
||||
public function getExportType();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Model\ExportQuery;
|
||||
use Thelia\Model\Map\ExportTableMap;
|
||||
|
||||
/**
|
||||
* Class Export
|
||||
|
||||
@@ -17,6 +17,7 @@ use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ExportQuery;
|
||||
use Thelia\Type\EnumType;
|
||||
use Thelia\Type\TypeCollection;
|
||||
|
||||
@@ -39,19 +40,27 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
|
||||
|
||||
$rawFormatters = array_change_key_case($service->getAll());
|
||||
|
||||
$allowedFormatter = $this->getAllowed_formatter();
|
||||
$exportId = $this->getExport();
|
||||
$formatters = [];
|
||||
if ($allowedFormatter !== null) {
|
||||
$allowedFormatter = explode(",", $allowedFormatter);
|
||||
if ($exportId !== null) {
|
||||
$export = ExportQuery::create()->findPk($exportId);
|
||||
|
||||
if (null !== $export) {
|
||||
$types = $export->getHandleClassInstance($this->container)
|
||||
->getHandledType();
|
||||
|
||||
foreach($allowedFormatter as $formatter) {
|
||||
$formatter = trim(strtolower($formatter));
|
||||
if (is_scalar($types)) {
|
||||
$types = [$types];
|
||||
}
|
||||
|
||||
if (isset($rawFormatters[$formatter])) {
|
||||
$formatters[$formatter] = $rawFormatters[$formatter];
|
||||
/** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */
|
||||
foreach ($rawFormatters as $key=>$formatter) {
|
||||
if (in_array($formatter->getExportType(), $types)) {
|
||||
$formatters[$key] = $formatter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$formatters = $rawFormatters;
|
||||
}
|
||||
@@ -118,7 +127,7 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createAnyTypeArgument("allowed_formatter"),
|
||||
Argument::createIntTypeArgument("export"),
|
||||
new Argument(
|
||||
"order",
|
||||
new TypeCollection(
|
||||
|
||||
Reference in New Issue
Block a user