From 8afbcd322bb4afa1fa7c6cb9a115f3e48d1df7c9 Mon Sep 17 00:00:00 2001 From: Benjamin Perche Date: Mon, 21 Jul 2014 15:04:59 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20cs=20and=20bug=20with=20positions=20=09mo?= =?UTF-8?q?difi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Core/Depe?= =?UTF-8?q?ndencyInjection/Loader/XmlFileLoader.php=20=09modifi=C3=A9:=20?= =?UTF-8?q?=20=20=20=20=20=20=20=20core/lib/Thelia/Model/Export.php=20=09m?= =?UTF-8?q?odifi=C3=A9:=20=20=20=20=20=20=20=20=20core/lib/Thelia/Model/Im?= =?UTF-8?q?port.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Loader/XmlFileLoader.php | 1 - core/lib/Thelia/Model/Export.php | 22 ++++++++++--------- core/lib/Thelia/Model/Import.php | 21 +++++++++--------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php index 5d1613c72..b98cc9204 100644 --- a/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php +++ b/core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php @@ -25,7 +25,6 @@ use Symfony\Component\DependencyInjection\SimpleXMLElement; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Loader\FileLoader; -use Thelia\Core\Translation\Translator; use Thelia\ImportExport\Export\ExportHandler; use Thelia\ImportExport\Import\ImportHandler; use Thelia\Model\Export; diff --git a/core/lib/Thelia/Model/Export.php b/core/lib/Thelia/Model/Export.php index 99bb41133..a5fe33d2b 100644 --- a/core/lib/Thelia/Model/Export.php +++ b/core/lib/Thelia/Model/Export.php @@ -37,11 +37,7 @@ class Export extends BaseExport public function downPosition() { - $max = ExportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ExportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); $count = $this->getExportCategory()->countExports(); @@ -82,11 +78,7 @@ class Export extends BaseExport public function setPositionToLast() { - $max = ExportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ExportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); if (null === $max) { $this->setPosition(1); @@ -180,4 +172,14 @@ class Export extends BaseExport return static::$cache instanceof DocumentsExportInterface; } + + public function getMaxPosition() + { + return ExportQuery::create() + ->filterByExportCategoryId($this->getExportCategoryId()) + ->orderByPosition(Criteria::DESC) + ->select(ExportTableMap::POSITION) + ->findOne() + ; + } } diff --git a/core/lib/Thelia/Model/Import.php b/core/lib/Thelia/Model/Import.php index 61df4a815..250e9cce6 100644 --- a/core/lib/Thelia/Model/Import.php +++ b/core/lib/Thelia/Model/Import.php @@ -36,11 +36,7 @@ class Import extends BaseImport public function downPosition() { - $max = ImportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ImportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); $count = $this->getImportCategory()->countImports(); @@ -81,11 +77,7 @@ class Import extends BaseImport public function setPositionToLast() { - $max = ImportQuery::create() - ->orderByPosition(Criteria::DESC) - ->select(ImportTableMap::POSITION) - ->findOne() - ; + $max = $this->getMaxPosition(); if (null === $max) { $this->setPosition(1); @@ -158,4 +150,13 @@ class Import extends BaseImport parent::delete($con); } + public function getMaxPosition() + { + return ImportQuery::create() + ->filterByImportCategoryId($this->getImportCategoryId()) + ->orderByPosition(Criteria::DESC) + ->select(ImportTableMap::POSITION) + ->findOne() + ; + } }