mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding performance optimizations to dispatch cycle
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6570 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
49a092f1d0
commit
a9378fb681
3 changed files with 12 additions and 25 deletions
|
@ -147,14 +147,13 @@ class Dispatcher extends Object {
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
$missingAction = $missingView = $privateAction = false;
|
$missingAction = $missingView = $privateAction = false;
|
||||||
|
|
||||||
if (empty($this->params['action'])) {
|
if (empty($this->params['action'])) {
|
||||||
$this->params['action'] = 'index';
|
$this->params['action'] = 'index';
|
||||||
}
|
}
|
||||||
|
|
||||||
$prefixes = Router::prefixes();
|
$prefixes = Router::prefixes();
|
||||||
|
|
||||||
if (!empty($prefixes)) {
|
if (!empty($prefixes)) {
|
||||||
if (isset($this->params['prefix'])) {
|
if (isset($this->params['prefix'])) {
|
||||||
$this->params['action'] = $this->params['prefix'] . '_' . $this->params['action'];
|
$this->params['action'] = $this->params['prefix'] . '_' . $this->params['action'];
|
||||||
|
|
|
@ -100,7 +100,8 @@ class Component extends Object {
|
||||||
'className' => $this->controller->name,
|
'className' => $this->controller->name,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
'file' => Inflector::underscore($component) . '.php',
|
'file' => Inflector::underscore($component) . '.php',
|
||||||
'base' => $this->controller->base
|
'base' => $this->controller->base,
|
||||||
|
'code' => 500
|
||||||
)));
|
)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +112,8 @@ class Component extends Object {
|
||||||
'className' => $this->controller->name,
|
'className' => $this->controller->name,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
'file' => Inflector::underscore($component) . '.php',
|
'file' => Inflector::underscore($component) . '.php',
|
||||||
'base' => $this->controller->base
|
'base' => $this->controller->base,
|
||||||
|
'code' => 500
|
||||||
)));
|
)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,25 +105,13 @@ class Object {
|
||||||
*
|
*
|
||||||
* @param string $method Name of the method to call
|
* @param string $method Name of the method to call
|
||||||
* @param array $params Parameter list to use when calling $method
|
* @param array $params Parameter list to use when calling $method
|
||||||
* @param boolean $strict If true, checks to make sure that $method is defined
|
* @return mixed Returns the result of the method call
|
||||||
* in this object. Throws a warning if not.
|
|
||||||
* @return mixed Returns the result of the method call, or null if $strict is
|
|
||||||
* true and the method was not found
|
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function dispatchMethod($method, $params = array(), $strict = false) {
|
function dispatchMethod($method, $params = array()) {
|
||||||
if ($strict) {
|
|
||||||
if (!method_exists($this, $method)) {
|
|
||||||
trigger_error("Object::dispatchMethod() - Method {$method} not found in " . get_class($this), E_USER_WARNING);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($params)) {
|
|
||||||
return $this->{$method}();
|
|
||||||
}
|
|
||||||
$params = array_values($params);
|
|
||||||
|
|
||||||
switch (count($params)) {
|
switch (count($params)) {
|
||||||
|
case 0:
|
||||||
|
return $this->{$method}();
|
||||||
case 1:
|
case 1:
|
||||||
return $this->{$method}($params[0]);
|
return $this->{$method}($params[0]);
|
||||||
case 2:
|
case 2:
|
||||||
|
@ -150,11 +138,9 @@ class Object {
|
||||||
if (!class_exists('CakeLog')) {
|
if (!class_exists('CakeLog')) {
|
||||||
uses('cake_log');
|
uses('cake_log');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($this->_log)) {
|
if (is_null($this->_log)) {
|
||||||
$this->_log = new CakeLog();
|
$this->_log = new CakeLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($msg)) {
|
if (!is_string($msg)) {
|
||||||
$msg = print_r($msg, true);
|
$msg = print_r($msg, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue