From bb43c79c3b2a01161221668c8a3099fbb14ffade Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 26 Jan 2015 00:43:05 +0100 Subject: [PATCH] Route: changed internal getTargetPresenter() to getTargetPresenters() that returns array (inspired by #40) --- src/Application/Routers/Route.php | 9 ++++----- src/Application/Routers/RouteList.php | 14 +++----------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/Application/Routers/Route.php b/src/Application/Routers/Route.php index bd374ed07..10c934cac 100644 --- a/src/Application/Routers/Route.php +++ b/src/Application/Routers/Route.php @@ -21,7 +21,6 @@ * @property-read string $mask * @property-read array $defaults * @property-read int $flags - * @property-read string|FALSE $targetPresenter */ class Route extends Nette\Object implements Application\IRouter { @@ -674,12 +673,12 @@ public function getFlags() /** * Proprietary cache aim. * @internal - * @return string|FALSE + * @return string[]|NULL */ - public function getTargetPresenter() + public function getTargetPresenters() { if ($this->flags & self::ONE_WAY) { - return FALSE; + return array(); } $m = $this->metadata; @@ -694,7 +693,7 @@ public function getTargetPresenter() } if (isset($m[self::PRESENTER_KEY]['fixity']) && $m[self::PRESENTER_KEY]['fixity'] === self::CONSTANT) { - return $module . $m[self::PRESENTER_KEY][self::VALUE]; + return array($module . $m[self::PRESENTER_KEY][self::VALUE]); } return NULL; } diff --git a/src/Application/Routers/RouteList.php b/src/Application/Routers/RouteList.php index d612bc97b..588776b2c 100644 --- a/src/Application/Routers/RouteList.php +++ b/src/Application/Routers/RouteList.php @@ -62,22 +62,14 @@ public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\U $routes['*'] = array(); foreach ($this as $route) { - $presenter = $route instanceof Route ? $route->getTargetPresenter() : NULL; + $presenters = $route instanceof Route && is_array($tmp = $route->getTargetPresenters()) + ? $tmp : array_keys($routes); - if ($presenter === FALSE) { - continue; - } - - if (is_string($presenter)) { + foreach ($presenters as $presenter) { if (!isset($routes[$presenter])) { $routes[$presenter] = $routes['*']; } $routes[$presenter][] = $route; - - } else { - foreach ($routes as $id => $foo) { - $routes[$id][] = $route; - } } }