Permalink
Browse files

added support for MvcRouter::public_url to support additional query-s…

…tring parameters

Just pass additional params in the $options array, and anything not used to match the route is converted into a query-string param

$url = MvcRouter::public_url(array('controller'=>$trl, 'action'=>$act, 'object'=>$obj, ‘code’=>$code, 'step'=>$step); // generates /controller/action/id/?code=X&step=Y
  • Loading branch information...
zoul0813 committed Jan 31, 2014
1 parent ce1186a commit d24fce73db8bc8128ce7935f0e687437ff69a70f
Showing with 8 additions and 0 deletions.
  1. +8 −0 core/mvc_router.php
View
@@ -14,6 +14,11 @@ public function public_url($options=array()) {
$routes = self::get_public_routes();
$controller = $options['controller'];
$action = $options['action'];
$query = array_diff_key($options, array('controller'=>true, 'action'=>true, 'object'=>true));
$querystring = null;
if(!empty($query)) {
$querystring = http_build_query($query);
}
$matched_route = null;
if (!empty($options['object']) && is_object($options['object'])) {
if (!empty($options['object']->__model_name) && !$controller) {
@@ -79,6 +84,9 @@ public function public_url($options=array()) {
$url .= $options['id'].'/';
}
}
if(!empty($querystring)) {
$url .= '?' . $querystring;
}
return $url;
}

0 comments on commit d24fce7

Please sign in to comment.