mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-09 04:52:42 +00:00
Merge remote branch 'origin/1.3' into 2.0
Conflicts: cake/dispatcher.php cake/libs/model/behaviors/acl.php cake/libs/model/behaviors/containable.php cake/libs/model/behaviors/tree.php cake/libs/router.php cake/tests/cases/libs/validation.test.php
This commit is contained in:
commit
52cdef900b
25 changed files with 309 additions and 175 deletions
|
@ -362,28 +362,6 @@ class Dispatcher extends Object {
|
|||
}
|
||||
return $base . $file;
|
||||
}
|
||||
/**
|
||||
* Restructure params in case we're serving a plugin.
|
||||
*
|
||||
* @param array $params Array on where to re-set 'controller', 'action', and 'pass' indexes
|
||||
* @param boolean $reverse If true all the params are shifted one forward, so plugin becomes
|
||||
* controller, controller becomes action etc. If false, plugin is made equal to controller
|
||||
* @return array Restructured array
|
||||
*/
|
||||
protected function _restructureParams($params, $reverse = false) {
|
||||
if ($reverse === true) {
|
||||
extract(Router::getArgs($params['action']));
|
||||
$params = array_merge($params, array(
|
||||
'controller'=> $params['plugin'],
|
||||
'action'=> $params['controller'],
|
||||
'pass' => array_merge($pass, $params['pass']),
|
||||
'named' => array_merge($named, $params['named'])
|
||||
));
|
||||
} else {
|
||||
$params['plugin'] = $params['controller'];
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get controller to use, either plugin controller or application controller
|
||||
|
@ -393,32 +371,14 @@ class Dispatcher extends Object {
|
|||
* @access private
|
||||
*/
|
||||
function &__getController() {
|
||||
$original = $params = $this->params;
|
||||
|
||||
$controller = false;
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
$ctrlClass = $this->__loadController($this->params);
|
||||
if (!$ctrlClass) {
|
||||
if (!isset($params['plugin'])) {
|
||||
$params = $this->_restructureParams($params);
|
||||
} else {
|
||||
$params = $this->_restructureParams($params, true);
|
||||
}
|
||||
$ctrlClass = $this->__loadController($params);
|
||||
if (!$ctrlClass) {
|
||||
$this->params = $original;
|
||||
return $controller;
|
||||
}
|
||||
return $controller;
|
||||
}
|
||||
$name = $ctrlClass;
|
||||
$ctrlClass .= 'Controller';
|
||||
if (class_exists($ctrlClass)) {
|
||||
if (
|
||||
empty($params['plugin']) &&
|
||||
strtolower(get_parent_class($ctrlClass)) === strtolower($name . 'AppController')
|
||||
) {
|
||||
$params = $this->_restructureParams($params);
|
||||
}
|
||||
$this->params = $params;
|
||||
$controller =& new $ctrlClass();
|
||||
}
|
||||
return $controller;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue