Added UrlRewritingTrait to manage URLs from model classes
This commit is contained in:
@@ -7,6 +7,19 @@ use Thelia\Tools\URL;
|
||||
|
||||
class Folder extends BaseFolder
|
||||
{
|
||||
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
|
||||
|
||||
use \Thelia\Model\Tools\PositionManagementTrait;
|
||||
|
||||
use \Thelia\Model\Tools\UrlRewritingTrait;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected function getRewritenUrlViewName() {
|
||||
return 'folder';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int number of contents for the folder
|
||||
*/
|
||||
@@ -15,11 +28,6 @@ class Folder extends BaseFolder
|
||||
return FolderQuery::countChild($this->getId());
|
||||
}
|
||||
|
||||
public function getUrl($locale)
|
||||
{
|
||||
return URL::getInstance()->retrieve('folder', $this->getId(), $locale)->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* count all products for current category and sub categories
|
||||
@@ -43,4 +51,23 @@ class Folder extends BaseFolder
|
||||
return $contentsCount;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate next position relative to our parent
|
||||
*/
|
||||
protected function addCriteriaToPositionQuery($query) {
|
||||
$query->filterByParent($this->getParent());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function preInsert(ConnectionInterface $con = null)
|
||||
{
|
||||
$this->setPosition($this->getNextPosition());
|
||||
|
||||
$this->generateRewritenUrl($this->getLocale());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user