Begin import export management

modifié:         core/lib/Thelia/Config/Resources/config.xml
	modifié:         core/lib/Thelia/Config/Resources/form.xml
	modifié:         core/lib/Thelia/Config/Resources/loop.xml
	modifié:         core/lib/Thelia/Config/Resources/routing/admin.xml
	renommé:         core/lib/Thelia/Form/ImportExport/BaseExportForm.php -> core/lib/Thelia/Controller/Admin/CustomerExportController.php
	modifié:         core/lib/Thelia/Controller/Admin/ExportController.php
	modifié:         core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterArchiveBuilderPass.php
	modifié:         core/lib/Thelia/Core/DependencyInjection/Compiler/RegisterFormatterPass.php
	nouveau fichier: core/lib/Thelia/Core/Template/Loop/ArchiveBuilder.php
	nouveau fichier: core/lib/Thelia/Core/Template/Loop/Formatter.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportCategory.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportCategoryI18n.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportCategoryI18nQuery.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportCategoryQuery.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportType.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportTypeI18n.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportTypeI18nQuery.php
	nouveau fichier: core/lib/Thelia/Model/Base/ImportExportTypeQuery.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportCategory.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportCategoryI18n.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportCategoryI18nQuery.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportCategoryQuery.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportType.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportTypeI18n.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportTypeI18nQuery.php
	nouveau fichier: core/lib/Thelia/Model/ImportExportTypeQuery.php
	nouveau fichier: core/lib/Thelia/Model/Map/ImportExportCategoryI18nTableMap.php
	nouveau fichier: core/lib/Thelia/Model/Map/ImportExportCategoryTableMap.php
	nouveau fichier: core/lib/Thelia/Model/Map/ImportExportTypeI18nTableMap.php
	nouveau fichier: core/lib/Thelia/Model/Map/ImportExportTypeTableMap.php
	modifié:         local/config/schema.xml
	modifié:         setup/thelia.sql
	modifié:         templates/backOffice/default/export.html
	nouveau fichier: templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
Benjamin Perche
2014-07-09 15:57:23 +02:00
parent 168cb31253
commit d1f5087d00
34 changed files with 11313 additions and 75 deletions

View File

@@ -24,7 +24,7 @@ class RegisterArchiveBuilderPass implements CompilerPassInterface
{
const MANAGER_DEFINITION = "thelia.manager.archive_builder_manager";
const SERVICE_TAG = "thelia.manager.archive_builder";
const SERVICE_TAG = "thelia.archive_builder";
/**
* You can modify the container here before it is dumped to PHP code.

View File

@@ -24,7 +24,7 @@ class RegisterFormatterPass implements CompilerPassInterface
{
const MANAGER_DEFINITION = "thelia.manager.formatter_manager";
const SERVICE_TAG = "thelia.manager.formatter";
const SERVICE_TAG = "thelia.formatter";
/**
* You can modify the container here before it is dumped to PHP code.

View File

@@ -0,0 +1,134 @@
<?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\Core\Template\Loop;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Template\Element\BaseLoop;
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\Type\EnumType;
use Thelia\Type\TypeCollection;
/**
* Class ArchiveBuilder
* @package Thelia\Core\Template\Loop
* @author Benjamin Perche <bperche@openstudio.fr>
*/
class ArchiveBuilder extends BaseLoop implements ArraySearchLoopInterface
{
/**
* this method returns an array
*
* @return array
*/
public function buildArray()
{
/** @var \Thelia\Core\FileFormat\Archive\archiveBuilderManager $service */
$service = $this->container->get("thelia.manager.archive_builder_manager");
$rawArchiveBuilders = array_change_key_case($service->getAll());
$allowedArchiveBuilder = $this->getAllowed_archive_builder();
$archiveBuilders = [];
if ($allowedArchiveBuilder !== null) {
$allowedArchiveBuilder = explode(",", $allowedArchiveBuilder);
foreach($allowedArchiveBuilder as $archiveBuilder) {
$archiveBuilder = trim(strtolower($archiveBuilder));
if (isset($rawArchiveBuilders[$archiveBuilder])) {
$archiveBuilders[$archiveBuilder] = $rawArchiveBuilders[$archiveBuilder];
}
}
} else {
$archiveBuilders = $rawArchiveBuilders;
}
switch ($this->getOrder()) {
case "alpha":
ksort($archiveBuilders);
break;
case "alpha_reverse":
krsort($archiveBuilders);
break;
}
return $archiveBuilders;
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \Thelia\Core\FileFormat\Archive\AbstractarchiveBuilder $archiveBuilder */
foreach ($loopResult->getResultDataCollection() as $archiveBuilder) {
$loopResultRow = new LoopResultRow();
$loopResultRow
->set("NAME", $archiveBuilder->getName())
->set("EXTENSION", $archiveBuilder->getExtension())
->set("MIME_TYPE", $archiveBuilder->getMimeType())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
/**
* Definition of loop arguments
*
* example :
*
* public function getArgDefinitions()
* {
* return new ArgumentCollection(
*
* Argument::createIntListTypeArgument('id'),
* new Argument(
* 'ref',
* new TypeCollection(
* new Type\AlphaNumStringListType()
* )
* ),
* Argument::createIntListTypeArgument('category'),
* Argument::createBooleanTypeArgument('new'),
* ...
* );
* }
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyTypeArgument("allowed_archive_builder"),
new Argument(
"order",
new TypeCollection(
new EnumType(["alpha", "alpha_reverse"])
),
"alpha"
)
);
}
}

View File

@@ -0,0 +1,132 @@
<?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\Core\Template\Loop;
use Thelia\Core\Template\Element\ArraySearchLoopInterface;
use Thelia\Core\Template\Element\BaseLoop;
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\Type\EnumType;
use Thelia\Type\TypeCollection;
/**
* Class Formatter
* @package Thelia\Core\Template\Loop
* @author Benjamin Perche <bperche@openstudio.fr>
*/
class Formatter extends BaseLoop implements ArraySearchLoopInterface
{
/**
* this method returns an array
*
* @return array
*/
public function buildArray()
{
/** @var \Thelia\Core\FileFormat\Formatting\FormatterManager $service */
$service = $this->container->get("thelia.manager.formatter_manager");
$rawFormatters = array_change_key_case($service->getAll());
$allowedFormatter = $this->getAllowed_formatter();
$formatters = [];
if ($allowedFormatter !== null) {
$allowedFormatter = explode(",", $allowedFormatter);
foreach($allowedFormatter as $formatter) {
$formatter = trim(strtolower($formatter));
if (isset($rawFormatters[$formatter])) {
$formatters[$formatter] = $rawFormatters[$formatter];
}
}
} else {
$formatters = $rawFormatters;
}
switch ($this->getOrder()) {
case "alpha":
ksort($formatters);
break;
case "alpha_reverse":
krsort($formatters);
break;
}
return $formatters;
}
/**
* @param LoopResult $loopResult
*
* @return LoopResult
*/
public function parseResults(LoopResult $loopResult)
{
/** @var \Thelia\Core\FileFormat\Formatting\AbstractFormatter $formatter */
foreach ($loopResult->getResultDataCollection() as $formatter) {
$loopResultRow = new LoopResultRow();
$loopResultRow
->set("NAME", $formatter->getName())
->set("EXTENSION", $formatter->getExtension())
->set("MIME_TYPE", $formatter->getMimeType())
;
$loopResult->addRow($loopResultRow);
}
return $loopResult;
}
/**
* Definition of loop arguments
*
* example :
*
* public function getArgDefinitions()
* {
* return new ArgumentCollection(
*
* Argument::createIntListTypeArgument('id'),
* new Argument(
* 'ref',
* new TypeCollection(
* new Type\AlphaNumStringListType()
* )
* ),
* Argument::createIntListTypeArgument('category'),
* Argument::createBooleanTypeArgument('new'),
* ...
* );
* }
*
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
*/
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createAnyTypeArgument("allowed_formatter"),
new Argument(
"order",
new TypeCollection(
new EnumType(["alpha", "alpha_reverse"])
),
"alpha"
)
);
}
}