Extending Router in config.neon

about a month ago

Bill Lions
Member | 46
+
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?

about a month ago

David Grudl
Nette Core | 7148
+
0
-

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

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

about a month ago

Bill Lions
Member | 46
+
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.