This commit is contained in:
Manuel Raynaud
2014-01-10 11:41:55 +01:00
parent ab0fbb6e27
commit 9d0121f321
54 changed files with 220 additions and 290 deletions

View File

@@ -22,12 +22,8 @@
/*************************************************************************************/
namespace Thelia\Rewriting;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Exception\RewritingUrlException;
use Thelia\Exception\UrlRewritingException;
use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\Map\RewritingUrlTableMap;
/**
* Class RewritingResolver
@@ -51,7 +47,7 @@ class RewritingResolver
{
$this->rewritingUrlQuery = new RewritingUrlQuery();
if($url !== null) {
if ($url !== null) {
$this->load($url);
}
}
@@ -62,7 +58,7 @@ class RewritingResolver
$rewrittenUrl = urldecode($rewrittenUrl);
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
if($this->search->count() == 0) {
if ($this->search->count() == 0) {
throw new UrlRewritingException('URL NOT FOUND', UrlRewritingException::URL_NOT_FOUND);
}
@@ -76,16 +72,16 @@ class RewritingResolver
protected function getOtherParameters()
{
if($this->search === null) {
if ($this->search === null) {
throw new UrlRewritingException('RESOLVER NULL SEARCH', UrlRewritingException::RESOLVER_NULL_SEARCH);
}
$otherParameters = array();
foreach($this->search as $result) {
foreach ($this->search as $result) {
$parameter = $result->getParameter();
$value = $result->getValue();
if(null !== $parameter) {
if (null !== $parameter) {
$otherParameters[$parameter] = $value;
}
}
@@ -93,5 +89,4 @@ class RewritingResolver
return $otherParameters;
}
}

View File

@@ -22,9 +22,7 @@
/*************************************************************************************/
namespace Thelia\Rewriting;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\RewritingUrlQuery;
use Thelia\Model\Map\RewritingUrlTableMap;
use Thelia\Tools\URL;
/**
@@ -46,7 +44,7 @@ class RewritingRetriever
{
$this->rewritingUrlQuery = new RewritingUrlQuery();
if($view !== null && $viewLocale !== null) {
if ($view !== null && $viewLocale !== null) {
$this->load($view, $viewLocale, $viewId);
}
}
@@ -61,16 +59,16 @@ class RewritingRetriever
$this->search = $this->rewritingUrlQuery->getViewUrlQuery($view, $viewLocale, $viewId);
$allParametersWithoutView = array();
if(null !== $viewId) {
if (null !== $viewId) {
$allParametersWithoutView['locale'] = $viewLocale;
}
if(null !== $viewId) {
if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
}
$this->rewrittenUrl = null;
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
if($this->search !== null) {
if ($this->search !== null) {
$this->rewrittenUrl = URL::getInstance()->absoluteUrl(
$this->search->getUrl()
);
@@ -85,8 +83,9 @@ class RewritingRetriever
*/
public function loadSpecificUrl($view, $viewLocale, $viewId = null, $viewOtherParameters = array())
{
if(empty($viewOtherParameters)) {
if (empty($viewOtherParameters)) {
$this->loadViewUrl($view, $viewLocale, $viewId);
return;
}
@@ -94,13 +93,13 @@ class RewritingRetriever
$allParametersWithoutView = $viewOtherParameters;
$allParametersWithoutView['locale'] = $viewLocale;
if(null !== $viewId) {
if (null !== $viewId) {
$allParametersWithoutView[$view . '_id'] = $viewId;
}
$this->rewrittenUrl = null;
$this->url = URL::getInstance()->viewUrl($view, $allParametersWithoutView);
if($this->search !== null) {
if ($this->search !== null) {
$this->rewrittenUrl = $this->search->getUrl();
}
}