rewriting
This commit is contained in:
@@ -23,9 +23,11 @@
|
||||
namespace Thelia\Rewriting;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Exception\RewritingUrlException;
|
||||
use Thelia\Exception\UrlRewritingException;
|
||||
use Thelia\Model\RewritingArgumentQuery;
|
||||
use Thelia\Model\RewritingUrlQuery;
|
||||
use Thelia\Model\Map\RewritingUrlTableMap;
|
||||
|
||||
/**
|
||||
* Class RewritingResolver
|
||||
@@ -36,13 +38,19 @@ use Thelia\Model\RewritingArgumentQuery;
|
||||
*/
|
||||
class RewritingResolver
|
||||
{
|
||||
protected $search = null;
|
||||
protected $rewritingUrlQuery = null;
|
||||
|
||||
public $view;
|
||||
public $viewId;
|
||||
public $locale;
|
||||
public $otherParameters;
|
||||
public $redirectedToUrl;
|
||||
|
||||
public function __construct($url = null)
|
||||
{
|
||||
$this->rewritingUrlQuery = new RewritingUrlQuery();
|
||||
|
||||
if($url !== null) {
|
||||
$this->load($url);
|
||||
}
|
||||
@@ -50,22 +58,28 @@ class RewritingResolver
|
||||
|
||||
public function load($rewrittenUrl)
|
||||
{
|
||||
$search = RewritingArgumentQuery::create()
|
||||
//->filterByUrl($rewrittenUrl)
|
||||
->joinRewritingUrl('ru', Criteria::RIGHT_JOIN)
|
||||
->where('`ru`.URL = ?', $rewrittenUrl, \PDO::PARAM_STR)
|
||||
->withColumn('`ru`.URL', 'ru_url')
|
||||
->withColumn('`ru`.VIEW', 'ru_view')
|
||||
->withColumn('`ru`.VIEW_LOCALE', 'ru_locale')
|
||||
->withColumn('`ru`.VIEW_ID', 'ru_viewId')
|
||||
->find();
|
||||
$this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl);
|
||||
|
||||
if($search->count() == 0) {
|
||||
if($this->search->count() == 0) {
|
||||
throw new UrlRewritingException('URL NOT FOUND', UrlRewritingException::URL_NOT_FOUND);
|
||||
}
|
||||
|
||||
$this->view = $this->search->getFirst()->getVirtualColumn('ru_view');
|
||||
$this->viewId = $this->search->getFirst()->getVirtualColumn('ru_viewId');
|
||||
$this->locale = $this->search->getFirst()->getVirtualColumn('ru_locale');
|
||||
$this->redirectedToUrl = $this->search->getFirst()->getVirtualColumn('ru_redirected_to_url');
|
||||
|
||||
$this->otherParameters = $this->getOtherParameters();
|
||||
}
|
||||
|
||||
protected function getOtherParameters()
|
||||
{
|
||||
if($this->search === null) {
|
||||
throw new UrlRewritingException('RESOLVER NULL SEARCH', UrlRewritingException::RESOLVER_NULL_SEARCH);
|
||||
}
|
||||
|
||||
$otherParameters = array();
|
||||
foreach($search as $result) {
|
||||
foreach($this->search as $result) {
|
||||
$parameter = $result->getParameter();
|
||||
$value = $result->getValue();
|
||||
|
||||
@@ -74,9 +88,8 @@ class RewritingResolver
|
||||
}
|
||||
}
|
||||
|
||||
$this->view = $search->getFirst()->getVirtualColumn('ru_view');
|
||||
$this->viewId = $search->getFirst()->getVirtualColumn('ru_viewId');
|
||||
$this->locale = $search->getFirst()->getVirtualColumn('ru_locale');
|
||||
$this->otherParameters = $otherParameters;
|
||||
return $otherParameters;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user