Hi
I have some route groups for my modules:
$di['router'] = function () {
$router = new Router();
$router->setUriSource(Router::URI_SOURCE_SERVER_REQUEST_URI);
$router->removeExtraSlashes(true);
//$router->setDefaultModule("main");
//$router->setDefaultNamespace("Myapp\Main\Controllers");
$routerMain = new \Phalcon\Mvc\Router\Group(array(
'module' => 'main',
'namespace' => "Myapp\Main\Controllers",
'controller' => 'index'
));
$routerMain->setHostName('example.com');
$routerMain->add('/', array(
'action' => 'index'
));
$routerMain->add('/add', array(
'action' => 'add'
));
$routerTravel = new \Phalcon\Mvc\Router\Group(array(
'module' => 'travel',
'namespace' => "Myapp\Travel\Controllers",
'controller' => 'index'
));
$routerTravel->setHostName('travel.example.com');
$routerTravel->add('/', array(
'action' => 'index'
));
$routerTravel->add('/add', array(
'action' => 'add'
));
$router->mount($routerMain);
$router->mount($routerTravel);
return $router;
};
All routes are working perfectly. But I want to add a default route
/:controller/:action/:params
to all groups with their own modules and namespaces.
If I set
$router->setDefaultModule("main");
$router->setDefaultNamespace("Myapp\Main\Controllers");
this applies to module "Main" to all groups.
I only see one way to do id - write this in each group:
$routerGroup->add('/:controller', array(
'controller' => 1
));
$routerGroup->add('/:controller/:action', array(
'controller' => 1,
'action' => 2,
));
$routerGroup->add('/:controller/:action/:params', array(
'controller' => 1,
'action' => 2,
'params' => 3
));
Am I right?