Skip to content

Commit 032d6b4

Browse files
committed
Route: changed internal getTargetPresenter() to getTargetPresenters() that returns array (inspired by #40)
1 parent d8c7ad8 commit 032d6b4

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/Application/Routers/Route.php

+6-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
* @property-read string $mask
2222
* @property-read array $defaults
2323
* @property-read int $flags
24-
* @property-read string|FALSE $targetPresenter
2524
*/
2625
class Route extends Nette\Object implements Application\IRouter
2726
{
@@ -674,12 +673,12 @@ public function getFlags()
674673
/**
675674
* Proprietary cache aim.
676675
* @internal
677-
* @return string|FALSE
676+
* @return string[]|NULL
678677
*/
679-
public function getTargetPresenter()
678+
public function getTargetPresenters()
680679
{
681680
if ($this->flags & self::ONE_WAY) {
682-
return FALSE;
681+
return array();
683682
}
684683

685684
$m = $this->metadata;
@@ -689,14 +688,14 @@ public function getTargetPresenter()
689688
if (isset($m[self::MODULE_KEY]['fixity']) && $m[self::MODULE_KEY]['fixity'] === self::CONSTANT) {
690689
$module = $m[self::MODULE_KEY][self::VALUE] . ':';
691690
} else {
692-
return NULL;
691+
return;
693692
}
694693
}
695694

696695
if (isset($m[self::PRESENTER_KEY]['fixity']) && $m[self::PRESENTER_KEY]['fixity'] === self::CONSTANT) {
697-
return $module . $m[self::PRESENTER_KEY][self::VALUE];
696+
return array($module . $m[self::PRESENTER_KEY][self::VALUE]);
698697
}
699-
return NULL;
698+
return;
700699
}
701700

702701

src/Application/Routers/RouteList.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -62,22 +62,14 @@ public function constructUrl(Nette\Application\Request $appRequest, Nette\Http\U
6262
$routes['*'] = array();
6363

6464
foreach ($this as $route) {
65-
$presenter = $route instanceof Route ? $route->getTargetPresenter() : NULL;
65+
$presenters = $route instanceof Route && is_array($tmp = $route->getTargetPresenters())
66+
? $tmp : array_keys($routes);
6667

67-
if ($presenter === FALSE) {
68-
continue;
69-
}
70-
71-
if (is_string($presenter)) {
68+
foreach ($presenters as $presenter) {
7269
if (!isset($routes[$presenter])) {
7370
$routes[$presenter] = $routes['*'];
7471
}
7572
$routes[$presenter][] = $route;
76-
77-
} else {
78-
foreach ($routes as $id => $foo) {
79-
$routes[$id][] = $route;
80-
}
8173
}
8274
}
8375

0 commit comments

Comments
 (0)