mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +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;
|
||||
|
||||
if (empty($this->params['action'])) {
|
||||
$this->params['action'] = 'index';
|
||||
}
|
||||
|
||||
$prefixes = Router::prefixes();
|
||||
|
||||
if (!empty($prefixes)) {
|
||||
if (isset($this->params['prefix'])) {
|
||||
$this->params['action'] = $this->params['prefix'] . '_' . $this->params['action'];
|
||||
|
|
|
@ -100,7 +100,8 @@ class Component extends Object {
|
|||
'className' => $this->controller->name,
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $this->controller->base
|
||||
'base' => $this->controller->base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
|
@ -111,7 +112,8 @@ class Component extends Object {
|
|||
'className' => $this->controller->name,
|
||||
'component' => $component,
|
||||
'file' => Inflector::underscore($component) . '.php',
|
||||
'base' => $this->controller->base
|
||||
'base' => $this->controller->base,
|
||||
'code' => 500
|
||||
)));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -103,27 +103,15 @@ class Object {
|
|||
* for call_user_func_array, and improves performance by using straight method calls
|
||||
* in most cases.
|
||||
*
|
||||
* @param string $method Name of the method to call
|
||||
* @param array $params Parameter list to use when calling $method
|
||||
* @param boolean $strict If true, checks to make sure that $method is defined
|
||||
* 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
|
||||
* @param string $method Name of the method to call
|
||||
* @param array $params Parameter list to use when calling $method
|
||||
* @return mixed Returns the result of the method call
|
||||
* @access public
|
||||
*/
|
||||
function dispatchMethod($method, $params = array(), $strict = false) {
|
||||
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);
|
||||
|
||||
function dispatchMethod($method, $params = array()) {
|
||||
switch (count($params)) {
|
||||
case 0:
|
||||
return $this->{$method}();
|
||||
case 1:
|
||||
return $this->{$method}($params[0]);
|
||||
case 2:
|
||||
|
@ -150,13 +138,11 @@ class Object {
|
|||
if (!class_exists('CakeLog')) {
|
||||
uses('cake_log');
|
||||
}
|
||||
|
||||
if (is_null($this->_log)) {
|
||||
$this->_log = new CakeLog();
|
||||
}
|
||||
|
||||
if (!is_string($msg)) {
|
||||
$msg = print_r ($msg, true);
|
||||
$msg = print_r($msg, true);
|
||||
}
|
||||
return $this->_log->write($type, $msg);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue