Added sorting and position ùmanagement to modules.

This commit is contained in:
Franck Allimant
2013-12-06 18:59:46 +01:00
parent e96088080d
commit 8c864021f5
9 changed files with 215 additions and 13 deletions

View File

@@ -5,11 +5,14 @@ namespace Thelia\Model;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\Module as BaseModule;
use Thelia\Model\Tools\ModelEventDispatcherTrait;
use Thelia\Core\Event\TheliaEvents;
class Module extends BaseModule
{
use ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
public function postSave(ConnectionInterface $con = null)
{
ModuleQuery::resetActivated();
@@ -56,4 +59,21 @@ class Module extends BaseModule
public function getAbsoluteI18nPath() {
return THELIA_MODULE_DIR . $this->getI18nPath();
}
/**
* Calculate next position relative to module type
*/
protected function addCriteriaToPositionQuery($query) {
$query->filterByType($this->getType());
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
$this->setPosition($this->getNextPosition());
return true;
}
}