Implement export types

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/Template/Loop/Formatter.php
	modifié:         core/lib/Thelia/ImportExport/Export/MailingExport.php
	modifié:         core/lib/Thelia/Model/Export.php
	modifié:         templates/backOffice/default/export-page.html
	modifié:         templates/backOffice/default/includes/export-form-definition.html
This commit is contained in:
Benjamin Perche
2014-07-11 10:46:16 +02:00
parent 6bc3ed214b
commit 33695a7886
8 changed files with 157 additions and 117 deletions

View File

@@ -46,6 +46,11 @@ class ImportExportController extends BaseAdminController
return $this->render("404");
}
$this->getParserContext()
->set("ID", $export->getId())
->set("TITLE", $export->getTitle())
;
return $this->render("export-page");
}

View File

@@ -90,9 +90,6 @@ class JsonFormatter extends AbstractFormatter
public function getExportType()
{
return array(
ExportType::EXPORT_TABLE,
ExportType::EXPORT_UNBOUNDED,
);
return ExportType::EXPORT_UNBOUNDED;
}
}

View File

@@ -145,9 +145,6 @@ class XMLFormatter extends AbstractFormatter
public function getExportType()
{
return array(
ExportType::EXPORT_TABLE,
ExportType::EXPORT_UNBOUNDED,
);
return ExportType::EXPORT_UNBOUNDED;
}
}

View File

@@ -46,8 +46,9 @@ class Formatter extends BaseLoop implements ArraySearchLoopInterface
$export = ExportQuery::create()->findPk($exportId);
if (null !== $export) {
$types = $export->getHandleClassInstance($this->container)
->getHandledType();
$handlerInstance = $export->getHandleClassInstance($this->container);
$types = $handlerInstance->getHandledType();
if (is_scalar($types)) {
$types = [$types];

View File

@@ -44,4 +44,26 @@ class MailingExport implements ExportHandlerInterface
$data = new FormatterData();
}
/**
* @return string|array
*
* Define all the type of export/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,
* );
*/
public function getHandledType()
{
return array(
ExportType::EXPORT_TABLE,
ExportType::EXPORT_UNBOUNDED,
);
}
}

View File

@@ -4,6 +4,7 @@ namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\ExportHandlerInterface;
use Thelia\Model\Base\Export as BaseExport;
use Thelia\Model\Map\ExportTableMap;
@@ -83,24 +84,32 @@ class Export extends BaseExport
{
$class = $this->getHandleClass();
if ($class[0] !== "\\") {
$class = "\\" . $class;
}
if (!class_exists($class)) {
throw new \ErrorException(
"The class \"%class\" doesn't exist",
[
"%class" => $class
]
Translator::getInstance()->trans(
"The class \"%class\" doesn't exist",
[
"%class" => $class
]
)
);
}
$instance = new $class($container);
if (!$class instanceof ExportHandlerInterface) {
if (!$instance instanceof ExportHandlerInterface) {
throw new \ErrorException(
"The class \"%class\" must implement %interface",
[
"%class" => $class,
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
]
Translator::getInstance()->trans(
"The class \"%class\" must implement %interface",
[
"%class" => $class,
"%interface" => "\\Thelia\\ImportExport\\ExportHandlerInterface",
]
)
);
}