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");
}
/**
* @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;
}
}
}