Created
July 21, 2011 05:39
-
-
Save jondavidjohn/1096571 to your computer and use it in GitHub Desktop.
Codeigniter: Remap params to index() function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
function _remap($method) | |
{ | |
$param_offset = 2; | |
// Default to index | |
if ( ! method_exists($this, $method)) | |
{ | |
// We need one more param | |
$param_offset = 1; | |
$method = 'index'; | |
} | |
// Since all we get is $method, load up everything else in the URI | |
$params = array_slice($this->uri->rsegment_array(), $param_offset); | |
// Call the determined method with all params | |
call_user_func_array(array($this, $method), $params); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment