nette / routing

Nette Routing: two-ways URL conversion
https://doc.nette.org/routing
Other
231 stars 3 forks source link

InvalidLinkException when switching from Nette 2.4 to 3.0 #3

Closed milo closed 5 years ago

milo commented 5 years ago

Description

I'm migrating app to Nette v3 and I'm getting InvalidLinkException with No route for Auth:Sign:in(). The match() pass and presenter runs, but building links by constructUrl() fails.

Steps To Reproduce

Router factory looks like:

$router = new RouteList;
$router[] = new Route('auth/<presenter>[/<action>[/<id>]]', [
        'module' => 'Auth',
        'presenter' => 'Homepage',
        'action' => 'default',
]);
$router[] = new Route('<presenter>[/<action>[/<id>]]', [
        'module' => 'Default',
        'presenter' => 'Homepage',
        'action' => 'default',
]);

and I had to rewrite routes as follow to get it work.

$router = new RouteList;
$router->withModule('Auth')->addRoute('auth/<presenter>[/<action>[/<id>]]', [
        'presenter' => 'Homepage',
        'action' => 'default',
]);
$router->withModule('Default')->addRoute('<presenter>[/<action>[/<id>]]', [
        'presenter' => 'Homepage',
        'action' => 'default',
]);

I digged out to https://github.com/nette/routing/blob/603c697f3df7ed214795d4e8e8c58fbf981232b1/src/Routing/RouteList.php#L105-L108 and found, that $key = null because $params['module'] is not set and $params['presenter'] === 'Auth:Sign' for example.

Not sure it is an intention.

dg commented 5 years ago

I hope the fix will work. Parameter module is big problem.