Refactor ImportExportController into two logical controllers
modifié: core/lib/Thelia/Config/Resources/routing/admin.xml renommé: core/lib/Thelia/Controller/Admin/ImportExportController.php -> core/lib/Thelia/Controller/Admin/ExportController.php nouveau fichier: core/lib/Thelia/Controller/Admin/ImportController.php modifié: core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Archive/ArchiveBuilderManagerTrait.php nouveau fichier: core/lib/Thelia/Core/FileFormat/Formatting/FormatterManagerTrait.php
This commit is contained in:
@@ -311,7 +311,6 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$refs = [];
|
||||
/** @var SimpleXMLElement $exportCategory */
|
||||
foreach ($exportCategories as $exportCategory) {
|
||||
$id = (string) $exportCategory->getAttributeAsPhp("id");
|
||||
@@ -338,16 +337,8 @@ class XmlFileLoader extends FileLoader
|
||||
->save($con);
|
||||
;
|
||||
}
|
||||
|
||||
$refs[] = $id;
|
||||
}
|
||||
|
||||
ExportCategoryQuery::create()
|
||||
->filterByRef($refs, Criteria::NOT_IN)
|
||||
->find()
|
||||
->delete()
|
||||
;
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
@@ -366,7 +357,6 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$refs = [];
|
||||
|
||||
/** @var SimpleXMLElement $export */
|
||||
foreach ($exports as $export) {
|
||||
@@ -453,16 +443,8 @@ class XmlFileLoader extends FileLoader
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
|
||||
$refs[] = $id;
|
||||
}
|
||||
|
||||
ExportQuery::create()
|
||||
->filterByRef($refs, Criteria::NOT_IN)
|
||||
->find()
|
||||
->delete()
|
||||
;
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
@@ -481,7 +463,6 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$refs = [];
|
||||
|
||||
/** @var SimpleXMLElement $importCategory */
|
||||
foreach ($importCategories as $importCategory) {
|
||||
@@ -510,15 +491,8 @@ class XmlFileLoader extends FileLoader
|
||||
;
|
||||
}
|
||||
|
||||
$refs[] = $id;
|
||||
}
|
||||
|
||||
ImportCategoryQuery::create()
|
||||
->filterByRef($refs, Criteria::NOT_IN)
|
||||
->find()
|
||||
->delete()
|
||||
;
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
@@ -537,8 +511,6 @@ class XmlFileLoader extends FileLoader
|
||||
$con->beginTransaction();
|
||||
|
||||
try {
|
||||
$refs = [];
|
||||
|
||||
/** @var SimpleXMLElement $import */
|
||||
foreach ($imports as $import) {
|
||||
$id = (string) $import->getAttributeAsPhp("id");
|
||||
@@ -624,16 +596,8 @@ class XmlFileLoader extends FileLoader
|
||||
->save($con)
|
||||
;
|
||||
}
|
||||
|
||||
$refs[] = $id;
|
||||
}
|
||||
|
||||
ImportQuery::create()
|
||||
->filterByRef($refs, Criteria::NOT_IN)
|
||||
->find()
|
||||
->delete()
|
||||
;
|
||||
|
||||
$con->commit();
|
||||
} catch (\Exception $e) {
|
||||
$con->rollBack();
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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\FileFormat\Archive;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Trait ArchiveBuilderManagerTrait
|
||||
* @package Thelia\Core\FileFormat\Archive
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
trait ArchiveBuilderManagerTrait
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return \Thelia\Core\FileFormat\Archive\ArchiveBuilderManager
|
||||
*/
|
||||
public function getArchiveBuilderManager(ContainerInterface $container)
|
||||
{
|
||||
return $container->get("thelia.manager.archive_builder_manager");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?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\FileFormat\Formatting;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Trait FormatterManagerTrait
|
||||
* @package Thelia\Core\FileFormat\Formatter
|
||||
* @author Benjamin Perche <bperche@openstudio.fr>
|
||||
*/
|
||||
trait FormatterManagerTrait
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
* @return \Thelia\Core\FileFormat\Formatting\FormatterManager
|
||||
*/
|
||||
public function getFormatterManager(ContainerInterface $container)
|
||||
{
|
||||
return $container->get("thelia.manager.formatter_manager");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user