Skip to content
Permalink
Browse files

Re-arrange the arguments of triggerCallback. Modifying Dispatcher so …

…its not calling methods on Component directly. Additional methods added to Controller.
  • Loading branch information...
markstory committed Feb 28, 2010
1 parent e75f6fe commit cec6692123ce6e2af4381ed72f73de7971ce74e9
Showing with 32 additions and 10 deletions.
  1. +2 −5 cake/dispatcher.php
  2. +4 −4 cake/libs/controller/component.php
  3. +26 −1 cake/libs/controller/controller.php
@@ -182,9 +182,7 @@ function dispatch($url = null, $additionalParams = array()) {
*/
function _invoke(&$controller, $params) {
$controller->constructClasses();
$controller->Component->initialize($controller);
$controller->beforeFilter();
$controller->Component->startup($controller);
$controller->startupProcess();
$methods = array_flip($controller->methods);
@@ -208,8 +206,7 @@ function _invoke(&$controller, $params) {
} elseif (empty($controller->output)) {
$controller->output = $output;
}
$controller->Component->shutdown($controller);
$controller->afterFilter();
$controller->shutdownProcess();
if (isset($params['return'])) {
return $controller->output;
@@ -109,7 +109,7 @@ function initialize(&$controller) {
* @link http://book.cakephp.org/view/65/MVC-Class-Access-Within-Components
*/
function startup(&$controller) {
$this->triggerCallback($controller, 'startup');
$this->triggerCallback('startup', $controller);
}
/**
@@ -121,7 +121,7 @@ function startup(&$controller) {
* @access public
*/
function beforeRender(&$controller) {
$this->triggerCallback($controller, 'beforeRender');
$this->triggerCallback('beforeRender', $controller);
}
/**
@@ -156,7 +156,7 @@ function beforeRedirect(&$controller, $url, $status = null, $exit = true) {
* @access public
*/
function shutdown(&$controller) {
$this->triggerCallback($controller, 'shutdown');
$this->triggerCallback('shutdown', $controller);
}
/**
@@ -169,7 +169,7 @@ function shutdown(&$controller) {
* @return void
* @access public
*/
function triggerCallback(&$controller, $callback) {
function triggerCallback($callback, &$controller) {
foreach ($this->_primary as $name) {
$component =& $this->_loaded[$name];
if (method_exists($component, $callback) && $component->enabled === true) {
@@ -514,6 +514,31 @@ function constructClasses() {
return true;
}
/**
* Perform the startup process for this controller.
* Fire the Component and Controller callbacks in the correct order.
*
* @return void
* @access public
*/
function startupProcess() {
$this->Component->initialize($this);
$this->beforeFilter();
$this->Component->triggerCallback('startup', $this);
}
/**
* Perform the various shutdown processes for this controller.
* Fire the Component and Controller callbacks in the correct order.
*
* @return void
* @access public
*/
function shutdownProcess() {
$this->Component->triggerCallback('shutdown', $controller);
$this->afterFilter();
}
/**
* Queries & sets valid HTTP response codes & messages.
*
@@ -835,7 +860,7 @@ function render($action = null, $layout = null, $file = null) {
App::import('View', $this->view);
}
$this->Component->beforeRender($this);
$this->Component->triggerCallback('beforeRender', $this);
$this->params['models'] = $this->modelNames;

0 comments on commit cec6692

Please sign in to comment.
You can’t perform that action at this time.