Fix cs and bug with positions

modifié:         core/lib/Thelia/Core/DependencyInjection/Loader/XmlFileLoader.php
	modifié:         core/lib/Thelia/Model/Export.php
	modifié:         core/lib/Thelia/Model/Import.php
This commit is contained in:
Benjamin Perche
2014-07-21 15:04:59 +02:00
parent a54ce50eb1
commit 8afbcd322b
3 changed files with 23 additions and 21 deletions

View File

@@ -25,7 +25,6 @@ use Symfony\Component\DependencyInjection\SimpleXMLElement;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException; use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
use Symfony\Component\DependencyInjection\Exception\RuntimeException; use Symfony\Component\DependencyInjection\Exception\RuntimeException;
use Symfony\Component\DependencyInjection\Loader\FileLoader; use Symfony\Component\DependencyInjection\Loader\FileLoader;
use Thelia\Core\Translation\Translator;
use Thelia\ImportExport\Export\ExportHandler; use Thelia\ImportExport\Export\ExportHandler;
use Thelia\ImportExport\Import\ImportHandler; use Thelia\ImportExport\Import\ImportHandler;
use Thelia\Model\Export; use Thelia\Model\Export;

View File

@@ -37,11 +37,7 @@ class Export extends BaseExport
public function downPosition() public function downPosition()
{ {
$max = ExportQuery::create() $max = $this->getMaxPosition();
->orderByPosition(Criteria::DESC)
->select(ExportTableMap::POSITION)
->findOne()
;
$count = $this->getExportCategory()->countExports(); $count = $this->getExportCategory()->countExports();
@@ -82,11 +78,7 @@ class Export extends BaseExport
public function setPositionToLast() public function setPositionToLast()
{ {
$max = ExportQuery::create() $max = $this->getMaxPosition();
->orderByPosition(Criteria::DESC)
->select(ExportTableMap::POSITION)
->findOne()
;
if (null === $max) { if (null === $max) {
$this->setPosition(1); $this->setPosition(1);
@@ -180,4 +172,14 @@ class Export extends BaseExport
return static::$cache instanceof DocumentsExportInterface; return static::$cache instanceof DocumentsExportInterface;
} }
public function getMaxPosition()
{
return ExportQuery::create()
->filterByExportCategoryId($this->getExportCategoryId())
->orderByPosition(Criteria::DESC)
->select(ExportTableMap::POSITION)
->findOne()
;
}
} }

View File

@@ -36,11 +36,7 @@ class Import extends BaseImport
public function downPosition() public function downPosition()
{ {
$max = ImportQuery::create() $max = $this->getMaxPosition();
->orderByPosition(Criteria::DESC)
->select(ImportTableMap::POSITION)
->findOne()
;
$count = $this->getImportCategory()->countImports(); $count = $this->getImportCategory()->countImports();
@@ -81,11 +77,7 @@ class Import extends BaseImport
public function setPositionToLast() public function setPositionToLast()
{ {
$max = ImportQuery::create() $max = $this->getMaxPosition();
->orderByPosition(Criteria::DESC)
->select(ImportTableMap::POSITION)
->findOne()
;
if (null === $max) { if (null === $max) {
$this->setPosition(1); $this->setPosition(1);
@@ -158,4 +150,13 @@ class Import extends BaseImport
parent::delete($con); parent::delete($con);
} }
public function getMaxPosition()
{
return ImportQuery::create()
->filterByImportCategoryId($this->getImportCategoryId())
->orderByPosition(Criteria::DESC)
->select(ImportTableMap::POSITION)
->findOne()
;
}
} }