Split router lists into modules
Notice: This thread is very old.
- Ambee
- Member | 1
I’ve developed an application with Nette. And now I want to host at hostforlife.eu. I have this router list:
$router[] = $adminRouter = new RouteList('Admin');
$adminRouter[] = new Route('admin/<presenter>/<action>', 'Dashboard:default');
$router[] = $frontRouter = new RouteList('Front');
$frontRouter[] = new Route('<presenter>/<action>[/<id>]', 'Homepage:default');
But it would be better to separate those two router lists into module folders. In the future I will probably create more modules with different router lists. How can I separate it and after how can I register it?
- newPOPE
- Member | 648
The simplest way (from my point of view) is:
class AdminRouter {
public static function register(Router $router) {
$list = new RouteList('Admin');
$list[] = new Route(...);
$router[] = $list;
}
}
// in RouteFactory
AdminRouter::register($router);
Last edited by newPOPE (2015-06-09 11:01)