Proč router hledá další routu když už jednu našel

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
jasin755
Člen | 116
+
0
-

Zdravím,
řeším pro mě nepochopitelný problém. Napsal jsem si vlastní router a router list. Router se dotazuje nějakých jiných tříd zda ta adresa je platná vrací to jenom TRUE nebo FALSE. No a nastala situace kdy to najde správnou routu, ale z nepochopitelného důvodu je tam další redirect (viz. screen) a na uplný nesmysl. Může mi prosím někdo toto chování objasnit nějak tomu nerozumim :(

Screen
https://scontent-a-ams.xx.fbcdn.net/…646332_o.jpg

Router

<?php

namespace Exsys\Router;

class Router extends \Nette\Application\Routers\Route{

	/**
	 *
	 * @var string
	 */
	private $url_facade;

	public function __construct($mask,$metadata = array(),\Exsys\Url\UrlFacade $url_facade,$flags = 0){
		$this->url_facade = $url_facade;
		parent::__construct($mask,$metadata,$flags);

	}

	private function modificateParams(array &$params,\Exsys\Url\ProtectedUrl $protected_url = NULL){
		$values = $protected_url->getValues();
		if(is_array($values)){
			$values = implode('+',$values);
		}
		$params[$protected_url->getValueName()] = $values;

		$child = $protected_url->getChild();
		if(!empty($child)){
			$this->modificateParams($params, $child['object']);
		}
	}

	private function translateParams(\Nette\Application\Request $request){

	}

	public function constructUrl(\Nette\Application\Request $appRequest, \Nette\Http\Url $refUrl){

		return parent::constructUrl($appRequest, $refUrl);
	}

	public function match(\Nette\Http\IRequest $http_request){
		$app_request = parent::match($http_request);

		if(is_null($app_request)){
			return NULL;
		}

		$params = $app_request->getParameters();
		$protected_url = $this->url_facade->getProtectedUrl($params);

		if(!empty($protected_url)){
			$result = $this->url_facade->checkProtectedValues($protected_url);
		}

		if(!empty($result)){
			if($result === TRUE){
				$this->modificateParams($params, $protected_url);
			}else{
				return NULL;
			}
		}elseif(!empty($protected_url)){
			return NULL;
		}
		//print_r($app_request);
		$app_request->setParameters($params);
		return $app_request;
	}

}

RouterList

<?php

namespace Exsys\Router;

use Nette\Application\Routers\RouteList;
use Exsys\Errors\RouterError;


class RouterList{

	private $httprequest;
	private $repository;
	private $shop_facade;
	private $product_facade;
	private $category_facade;
	private $url_facade;

	public function __construct(
			\Nette\Http\Request $httprequest,
			\Exsys\Router\RouterRepository $router_repository,
			\Exsys\Shop\ShopFacade $shop_facade,
			\Exsys\Products\ProductsFacade $product_facade,
			\Exsys\Categories\CategoriesFacade $category_facade,
			\Exsys\Url\UrlFacade $url_facade
			){
		$this->httprequest = $httprequest;
		$this->router_repository = $router_repository;
		$this->shop_facade = $shop_facade;
		$this->category_facade = $category_facade;
		$this->product_facade = $product_facade;
		$this->url_facade = $url_facade;
	}

	public function getRouterList($host = false){

		if($host === false){
			$host = $this->httprequest->getUrl()->getHost();
		}

		$routes = $this->router_repository->getWebRouterList($host);

		if(!$routes){
			throw new RouterError('Nenalezena routa pro tento web');
		}


		$routelist = new RouteList();
		$url_facade = $this->url_facade;
		foreach($routes AS $route){
			$web = $route->getWeb();
			if($web->getActive() === 0){
				continue;
			}
			$module = ucfirst($web->getModule());
			$submodule = FALSE;


			preg_match("@^/(-?\d+)/@",$this->httprequest->url->getPath(),$matches);

			if($matches){
				$shop_id = $matches[1];
			}else{
				$shop_id = null;
			}

			if($this->shop_facade instanceof \Exsys\Shop\ShopFacade && $module === 'Web1localhost' && (int)$shop_id === -1){
				$submodule = 'System';
			}elseif($module === 'Web1localhost'){
				$submodule = 'Shop';
			}else{
				$submodule = FALSE;
			}


			$routelist[] = new \Exsys\Router\Router('//'.$host.$route->router_declaration,array(
					'module' => $module.($submodule ? ':'.$submodule : ''),
					'presenter' => ucfirst($route->presenter),
					'action' => $route->action
			),$this->url_facade);

		}
		return $routelist;
	}

}
jasin755
Člen | 116
+
0
-

Typuji, že to má něco společného s ONE_WAY, ale nechápu moc jak.