create test for UrlRewritingTrait

This commit is contained in:
Manuel Raynaud
2013-09-17 20:15:28 +02:00
parent e1e383707b
commit da7f9e07c4
3 changed files with 96 additions and 13 deletions

View File

@@ -2,25 +2,25 @@
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Connection\ConnectionInterface;
use Thelia\Model\Base\RewritingUrl as BaseRewritingUrl;
use Thelia\Model\RewritingUrlQuery;
class RewritingUrl extends BaseRewritingUrl {
public function preSave(ConnectionInterface $con = null)
public function postInsert(ConnectionInterface $con = null)
{
if($this->getRedirected() == 0) {
//check if rewriting url alredy exists and put redirect to 1
if(null !== $this->getRedirected()) {
//check if rewriting url alredy exists and put redirect to the new one
RewritingUrlQuery::create()
->filterByView($this->getView())
->filterByViewId($this->getViewId())
->filterByViewLocale($this->getViewLocale())
->filterByRedirected($this->getId(), Criteria::NOT_IN)
->update(array(
"redirect" => 1
"Redirected" => $this->getId()
));
}
return true;
}
}