summaryrefslogtreecommitdiffstats
path: root/system/core/Router.php
diff options
context:
space:
mode:
authorJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-23 20:52:46 +0200
committerJonatas Miguel <jonatas.df.miguel@gmail.com>2012-10-23 20:52:46 +0200
commitefb81669b8f90352fdabd109e14fdec25bbce8fe (patch)
tree67d1d031b3d3de6f0d094e1261d4c3eb4eb5db9d /system/core/Router.php
parent24296ca1e940ac32841cc24a5fdc2f49a0f8ec8a (diff)
users' default values are now respected in callback routes
Diffstat (limited to 'system/core/Router.php')
-rw-r--r--system/core/Router.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/system/core/Router.php b/system/core/Router.php
index 3428ff07b..e8addf962 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -391,6 +391,21 @@ class CI_Router {
{
// Any params without matches will be set to an empty string.
$matches = array_merge($matches, array_fill($match_count, $param_count - $match_count, ''));
+
+ $match_count = $param_count;
+ }
+
+ // Get the parameters so we can use their default values.
+ $params = $reflection->getParameters();
+
+ for ($m = 0; $m < $match_count; $m++)
+ {
+ // Is the match empty and does a default value exist?
+ if (empty($matches[$m]) && $params[$m]->isDefaultValueAvailable())
+ {
+ // Substitute the empty match for the default value.
+ $matches[$m] = $params[$m]->getDefaultValue();
+ }
}
// Execute the callback using the values in matches as its parameters.