php - phalconphp routing and add postfix to action -
i'd add phalconphp routing rule. when method post call controller x, action x+post postfix + params
$router->addpost('/:action/:params',['controller'=>'print','action'=>1."post",'params'=>2]);
and
$router->addpost('/:action/:params',['controller'=>'print','action'=>str_replace(1,1.'post',1),'params'=>2]);
but not work. idea on solve?
just clear look:
in router:
$router->add('/:action/:params', ['controller'=>'controllername', 'action'=>1, 'params'=>2]) ->via(['post']) ->convert('action', function($action){ return $action.'post'; });
more information @docs:
http://docs.phalconphp.com/en/latest/reference/routing.html#http-method-restrictions
// route matched if http method post or put $router->add("/products/update")->via(array("post", "put"));
convertions allow freely transform route’s parameters before passing them dispatcher, following examples show how use them:
//the action name allows dashes, action can be: /products/new-ipod-nano-4-generation $router ->add('/products/{slug:[a-z\-]+}', array( 'controller' => 'products', 'action' => 'show' )) ->convert('slug', function($slug) { //transform slug removing dashes return str_replace('-', '', $slug); });
Comments
Post a Comment