Added sorting and position ùmanagement to modules.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user