Skip to content

Commit

Permalink
Route: changed internal getTargetPresenter() to getTargetPresenters()…
Browse files Browse the repository at this point in the history
… that returns array (inspired by #40)
  • Loading branch information
dg committed Jan 26, 2015
1 parent d8c7ad8 commit bb43c79
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
9 changes: 4 additions & 5 deletions src/Application/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
14 changes: 3 additions & 11 deletions src/Application/Routers/RouteList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}

Expand Down

0 comments on commit bb43c79

Please sign in to comment.