Extending Router in config.neon

Bill Lions
Member | 48
+
0
-

The docs here → https://doc.nette.org/…/configuring give the impression routes can be added by the config.neon
>

routing:
routes:
‘detail/<id>’: Admin:Home:default
‘<presenter>/<action>’: Front:Home:default

I have tried the following:

routing:
routes:
‘/user’: User:User:default
‘/user/admin’: User:User:admin
‘<module>/<presenter>/<action>’: User:User:default

The /user and the /user/admin urls result in this error:

Nette\Application\BadRequestException #404
Cannot load presenter ‘User’, class ‘App\Presenters\UserPresenter’ was not found

When the routes are added to the routerFactory, it all works fine.

Why does the config option not work?

David Grudl
Nette Core | 7190
+
0
-

You are probably combining your own router and the router in the configuration. Remove this from config:

services:
#	router: App\Router\RouterFactory::createRouter
Bill Lions
Member | 48
+
0
-

David Grudl wrote:

You are probably combining your own router and the router in the configuration. Remove this from config:

services:
#	router: App\Router\RouterFactory::createRouter

Yep, and changed the namespace of my presenter to App\Presenters instead of App and it works fine.
Thank you sir.