Welcome Guest, Not a member yet? Register   Sign In
remapping controllers' function calls: what about arguments?
#4

[eluser]Michael Ekoka[/eluser]
ok, I think I found a solution. The URI::$rsegments property contains the rerouted request (the one that the framework uses to call your controller/method/params). It's safer to use for this purpose than the URI::$segments which rather contains the original pre-routed url, because unlike the $segments array the $rsegments always has a controller, a method and no subdirectory.

This is what I have:
Code:
function _remap($method){
    // first lets get rid of the controller and method
    $args = array_slice($this->uri->rsegments,2);
    if(method_exists($this,$method)){    
        return call_user_func_array(array(&$this,$method),$args);            
    }
}
I let your imagination wander as to all the possibilities this little functionality offers.


Messages In This Thread
remapping controllers' function calls: what about arguments? - by El Forum - 10-23-2007, 01:45 PM



Theme © iAndrew 2016 - Forum software by © MyBB