Refactor position management with trait
nouveau fichier: core/lib/Thelia/Action/Export.php nouveau fichier: core/lib/Thelia/Action/Import.php modifié: core/lib/Thelia/Config/Resources/action.xml modifié: core/lib/Thelia/Config/Resources/routing/admin.xml modifié: core/lib/Thelia/Controller/Admin/ExportController.php modifié: core/lib/Thelia/Controller/Admin/ImportController.php modifié: core/lib/Thelia/Core/Event/TheliaEvents.php modifié: core/lib/Thelia/ImportExport/Export/Type/ProductTaxedPricesExport.php modifié: core/lib/Thelia/Model/Export.php modifié: core/lib/Thelia/Model/ExportCategory.php modifié: core/lib/Thelia/Model/Import.php modifié: core/lib/Thelia/Model/ImportCategory.php modifié: templates/backOffice/default/export.html
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilderManagerTrait;
|
||||
use Thelia\Core\FileFormat\Formatting\FormatterManagerTrait;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
@@ -328,72 +329,57 @@ class ExportController extends BaseAdminController
|
||||
}
|
||||
|
||||
|
||||
public function changePosition($action, $id)
|
||||
public function changePosition()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$export = $this->getExport($id);
|
||||
$mode = $this->getRequest()->get("mode");
|
||||
$id = $this->getRequest()->get("id");
|
||||
$value = $this->getRequest()->get("value");
|
||||
|
||||
if ($action === "up") {
|
||||
$export->upPosition();
|
||||
} elseif ($action === "down") {
|
||||
$export->downPosition();
|
||||
}
|
||||
$this->getExport($id);
|
||||
|
||||
$event = new UpdatePositionEvent($id, $this->getMode($mode), $value);
|
||||
$this->dispatch(TheliaEvents::EXPORT_CHANGE_POSITION, $event);
|
||||
|
||||
$this->setOrders(null, "manual");
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
public function updatePosition($id, $value)
|
||||
public function changeCategoryPosition()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$export = $this->getExport($id);
|
||||
$mode = $this->getRequest()->get("mode");
|
||||
$id = $this->getRequest()->get("id");
|
||||
$value = $this->getRequest()->get("value");
|
||||
|
||||
$export->updatePosition($value);
|
||||
$this->getCategory($id);
|
||||
|
||||
$this->setOrders(null, "manual");
|
||||
$event = new UpdatePositionEvent($id, $this->getMode($mode), $value);
|
||||
$this->dispatch(TheliaEvents::EXPORT_CATEGORY_CHANGE_POSITION, $event);
|
||||
|
||||
$this->setOrders("manual");
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
public function changeCategoryPosition($action, $id)
|
||||
public function getMode($action)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$category = $this->getCategory($id);
|
||||
|
||||
if ($action === "up") {
|
||||
$category->upPosition();
|
||||
$mode = UpdatePositionEvent::POSITION_UP;
|
||||
} elseif ($action === "down") {
|
||||
$category->downPosition();
|
||||
$mode = UpdatePositionEvent::POSITION_DOWN;
|
||||
} else {
|
||||
$mode = UpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
$this->setOrders("manual");
|
||||
|
||||
return $this->render('export');
|
||||
}
|
||||
|
||||
public function updateCategoryPosition($id, $value)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::EXPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$category = $this->getCategory($id);
|
||||
|
||||
$category->updatePosition($value);
|
||||
|
||||
$this->setOrders("manual");
|
||||
|
||||
return $this->render('export');
|
||||
return $mode;
|
||||
}
|
||||
|
||||
protected function setOrders($category = null, $export = null)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\ImportExport as ImportExportEvent;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Event\UpdatePositionEvent;
|
||||
use Thelia\Core\FileFormat\Archive\AbstractArchiveBuilder;
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilderManager;
|
||||
use Thelia\Core\FileFormat\Archive\ArchiveBuilderManagerTrait;
|
||||
@@ -426,72 +427,54 @@ class ImportController extends BaseAdminController
|
||||
;
|
||||
}
|
||||
|
||||
public function changePosition($action, $id)
|
||||
public function changePosition()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$import = $this->getImport($id);
|
||||
$mode = $this->getRequest()->get("mode");
|
||||
$id = $this->getRequest()->get("id");
|
||||
$value = $this->getRequest()->get("value");
|
||||
|
||||
if ($action === "up") {
|
||||
$import->upPosition();
|
||||
} elseif ($action === "down") {
|
||||
$import->downPosition();
|
||||
}
|
||||
$this->getImport($id);
|
||||
|
||||
$this->setOrders(null, "manual");
|
||||
$event = new UpdatePositionEvent($id, $this->getMode($mode), $value);
|
||||
$this->dispatch(TheliaEvents::IMPORT_CHANGE_POSITION, $event);
|
||||
|
||||
return $this->render('import');
|
||||
}
|
||||
|
||||
public function updatePosition($id, $value)
|
||||
public function changeCategoryPosition()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$import = $this->getImport($id);
|
||||
$mode = $this->getRequest()->get("mode");
|
||||
$id = $this->getRequest()->get("id");
|
||||
$value = $this->getRequest()->get("value");
|
||||
|
||||
$import->updatePosition($value);
|
||||
$this->getCategory($id);
|
||||
|
||||
$this->setOrders(null, "manual");
|
||||
|
||||
return $this->render('import');
|
||||
}
|
||||
|
||||
public function changeCategoryPosition($action, $id)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
}
|
||||
|
||||
$category = $this->getCategory($id);
|
||||
|
||||
if ($action === "up") {
|
||||
$category->upPosition();
|
||||
} elseif ($action === "down") {
|
||||
$category->downPosition();
|
||||
}
|
||||
$event = new UpdatePositionEvent($id, $this->getMode($mode), $value);
|
||||
$this->dispatch(TheliaEvents::IMPORT_CATEGORY_CHANGE_POSITION, $event);
|
||||
|
||||
$this->setOrders("manual");
|
||||
|
||||
return $this->render('import');
|
||||
}
|
||||
|
||||
public function updateCategoryPosition($id, $value)
|
||||
public function getMode($action)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth([AdminResources::IMPORT], [], [AccessManager::UPDATE])) {
|
||||
return $response;
|
||||
if ($action === "up") {
|
||||
$mode = UpdatePositionEvent::POSITION_UP;
|
||||
} elseif ($action === "down") {
|
||||
$mode = UpdatePositionEvent::POSITION_DOWN;
|
||||
} else {
|
||||
$mode = UpdatePositionEvent::POSITION_ABSOLUTE;
|
||||
}
|
||||
|
||||
$category = $this->getCategory($id);
|
||||
|
||||
$category->updatePosition($value);
|
||||
|
||||
$this->setOrders("manual");
|
||||
|
||||
return $this->render('import');
|
||||
return $mode;
|
||||
}
|
||||
|
||||
protected function getImport($id)
|
||||
|
||||
Reference in New Issue
Block a user