My Custom Routing is as follows:-
$router = new \Phalcon\Mvc\Router(false);
$router->removeExtraSlashes(true);
$router->add( '/:module', array( 'module' => 1, 'controller' => 'index', 'action' => 'index' ) )
->setName("oml");
$router->add( '/:module/:controller', array( 'module' => 1, 'controller' => 2, 'action' => 'index' ) )
->setName("mct");
$router->add( '/:module/:controller/:action', array( 'module' => 1, 'controller' => 2, 'action' => 3 ) )
->setName("mvc");
$router->add( '/:module/:controller/:action/:params', array( 'module' => 1, 'controller' => 2, 'action' => 3, 'params' => 4 ) )
->setName("mvcp");
$router->add( '/', array( 'module' => 'user', 'controller' => 'index', 'action' => 'index' ) );
When I try to get URL using below syntax in volt, It doen't show any parameter in URL and there is value for board.id
url(['for' : 'mvcp', 'module' : 'admin', 'controller' : 'board', 'action' : 'edit', 'id' : board.id])
I also modify dispatcher in DI using below code:-
$eventsManager = new EventsManager();
$eventsManager->attach('dispatch', function($event, $dispatcher) {
if ($event->getType() == 'beforeDispatchLoop') {
$keyParams = array();
$params = $dispatcher->getParams();
foreach ($params as $number => $value) {
if ($number & 1) {
$keyParams[$params[$number - 1]] = $value;
}
}
$dispatcher->setParams($keyParams);
$dispatcher->setDefaultNamespace(ucfirst($dispatcher->getModuleName())."\Controllers");
}
});
$dispatcher = new Phalcon\MVc\Dispatcher();
$dispatcher->setEventsManager($eventsManager);
return $dispatcher;
Please help me out.
Sorry if there is some problem with code formatting in this discussion. It's my first question