REGEX BUG : if a parameter is optionnal in the regex, don't show an error
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1263 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -537,6 +537,8 @@ class route
|
||||
// URL === REGEXP ROUTE
|
||||
// Variables are exposed in url/{var1}/{var2}
|
||||
$regex = "#^$route$#U";
|
||||
//$regex = str_replace ("?", "\?", $regex);
|
||||
//$regex = str_replace (".", "\.", $regex);
|
||||
$regex = str_replace ("{", "(?P<", $regex);
|
||||
$regex = str_replace ("}", ">.+)", $regex);
|
||||
unset ($matches);
|
||||
@@ -548,7 +550,12 @@ class route
|
||||
$params = array ();
|
||||
$reflect = new ReflectionFunction ($function);
|
||||
foreach ($reflect->getParameters() as $key=>$val)
|
||||
$params[] = $matches[$val->name];
|
||||
{
|
||||
if (isset ($matches[$val->name]))
|
||||
$params[] = $matches[$val->name];
|
||||
else
|
||||
$params[] = null;
|
||||
}
|
||||
call_user_func_array ($function, $params);
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user