Added UrlRewritingTrait to manage URLs from model classes

This commit is contained in:
franck
2013-09-16 22:31:55 +02:00
parent e473c64588
commit 7858e809b7
10 changed files with 303 additions and 26 deletions

View File

@@ -4,11 +4,41 @@ namespace Thelia\Model;
use Thelia\Model\Base\Content as BaseContent;
use Thelia\Tools\URL;
use Propel\Runtime\Connection\ConnectionInterface;
class Content extends BaseContent
{
public function getUrl($locale)
use \Thelia\Model\Tools\ModelEventDispatcherTrait;
use \Thelia\Model\Tools\PositionManagementTrait;
use \Thelia\Model\Tools\UrlRewritingTrait;
/**
* {@inheritDoc}
*/
protected function getRewritenUrlViewName() {
return 'content';
}
/**
* Calculate next position relative to our parent
*/
protected function addCriteriaToPositionQuery($query) {
// TODO: Find the default folder for this content,
// and generate the position relative to this folder
}
/**
* {@inheritDoc}
*/
public function preInsert(ConnectionInterface $con = null)
{
return URL::getInstance()->retrieve('content', $this->getId(), $locale)->toString();
$this->setPosition($this->getNextPosition());
$this->generateRewritenUrl($this->getLocale());
return true;
}
}