Merge branch 'master' of github.com:thelia/thelia

This commit is contained in:
Manuel Raynaud
2013-12-06 16:00:37 +01:00
5 changed files with 21 additions and 6 deletions

View File

@@ -115,6 +115,8 @@ class Category extends BaseCategory
*/
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECATEGORY, new CategoryEvent($this));
}
}

View File

@@ -148,6 +148,8 @@ class Content extends BaseContent
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETECONTENT, new ContentEvent($this));
}
}

View File

@@ -100,6 +100,8 @@ class Folder extends BaseFolder
public function postDelete(ConnectionInterface $con = null)
{
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEFOLDER, new FolderEvent($this));
}
}

View File

@@ -263,12 +263,8 @@ class Product extends BaseProduct
*/
public function postDelete(ConnectionInterface $con = null)
{
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
$this->markRewritenUrlObsolete();
$this->dispatchEvent(TheliaEvents::AFTER_DELETEPRODUCT, new ProductEvent($this));
}
}

View File

@@ -29,6 +29,7 @@ use Thelia\Exception\UrlRewritingException;
use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\RewritingUrl;
use Thelia\Tools\URL;
use Thelia\Model\ConfigQuery;
/**
* A trait for managing Rewritten URLs from model classes
*/
@@ -136,6 +137,18 @@ trait UrlRewritingTrait {
return $url;
}
/**
* Mark the current URL as obseolete
*/
public function markRewritenUrlObsolete() {
RewritingUrlQuery::create()
->filterByView($this->getRewrittenUrlViewName())
->filterByViewId($this->getId())
->update(array(
"View" => ConfigQuery::getObsoleteRewrittenUrlView()
));
}
/**
* Set the rewritten URL for the given locale
*