Skip to content

Commit a07984d

Browse files
committed
Route: fixed bug for constant module & presenter [Closes #216]
1 parent 4b06d01 commit a07984d

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/Application/Routers/Route.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,10 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri
139139
public function getConstantParameters(): array
140140
{
141141
$res = parent::getConstantParameters();
142-
unset($res['module']);
142+
if (isset($res[self::MODULE_KEY], $res[self::PRESENTER_KEY])) {
143+
$res[self::PRESENTER_KEY] = $res[self::MODULE_KEY] . ':' . $res[self::PRESENTER_KEY];
144+
}
145+
unset($res[self::MODULE_KEY]);
143146
return $res;
144147
}
145148

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/**
4+
* Test: Nette\Application\Routers\Route & fixed module & presenter.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
use Nette\Application\Routers\Route;
10+
use Tester\Assert;
11+
12+
13+
require __DIR__ . '/../bootstrap.php';
14+
15+
16+
$route = new Route('auth[/<action>]', [
17+
'module' => 'Auth',
18+
'presenter' => 'Homepage',
19+
'action' => 'default',
20+
]);
21+
22+
Assert::same(['presenter' => 'Auth:Homepage'], $route->getConstantParameters());

0 commit comments

Comments
 (0)