mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding ability to specify named arguments in the URL
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3115 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
79ba4fa94d
commit
0d707d4360
2 changed files with 42 additions and 1 deletions
|
@ -192,8 +192,17 @@ class Dispatcher extends Object {
|
|||
}
|
||||
|
||||
if (!empty($controller->params['pass'])) {
|
||||
if ($controller->namedArgs !== false) {
|
||||
if (is_array($controller->namedArgs) && in_array($params['action'], array_keys($controller->namedArgs))) {
|
||||
$this->_getNamedArgs($controller->params['pass'], $controller->namedArgs[$params['action']]);
|
||||
} elseif (is_int($controller->namedArgs) && $controller->namedArgs > 0) {
|
||||
$this->_getNamedArgs($controller->params['pass'], $controller->namedArgs);
|
||||
} elseif ($controller->namedArgs === true) {
|
||||
$this->_getNamedArgs($controller->params['pass']);
|
||||
}
|
||||
}
|
||||
$controller->passed_args =& $controller->params['pass'];
|
||||
$controller->passedArgs =& $controller->params['pass'];
|
||||
$controller->passedArgs =& $controller->params['pass'];
|
||||
} else {
|
||||
$controller->passed_args = null;
|
||||
$controller->passedArgs = null;
|
||||
|
@ -414,5 +423,31 @@ class Dispatcher extends Object {
|
|||
}
|
||||
return $params;
|
||||
}
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param unknown_type $params
|
||||
* @return unknown
|
||||
*/
|
||||
function _getNamedArgs(&$params, $start = 0) {
|
||||
if(is_array($params)) {
|
||||
$a = array();
|
||||
$args = $params;
|
||||
$c = count($args);
|
||||
|
||||
for ($l = $start; $l < $c; $l++) {
|
||||
if(isset($args[$l])) {
|
||||
if ($l+1 < count($args)) {
|
||||
$a[$args[$l]] = $args[$l+1];
|
||||
} else {
|
||||
$a[$args[$l]] = null;
|
||||
}
|
||||
}
|
||||
$l++;
|
||||
}
|
||||
$params = $a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -200,6 +200,12 @@ class Controller extends Object{
|
|||
* @var boolean
|
||||
*/
|
||||
var $persistModel = false;
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
var $namedArgs = false;
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue