Skip to content

Commit

Permalink
Removing response injection into controller from dispatcher.
Browse files Browse the repository at this point in the history
Modifying Dispatcher to use accessor method.
  • Loading branch information
markstory committed Aug 22, 2010
1 parent 7221f9c commit 91c9c74
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions cake/dispatcher.php
Expand Up @@ -78,10 +78,9 @@ class Dispatcher {
public $request = null;

/**
* The response object
* Response object used for asset/cached responses.
*
* @var CakeResponse
* @access public
*/
public $response = null;

Expand Down Expand Up @@ -195,19 +194,20 @@ protected function _invoke(&$controller, $request) {
'base' => $request->base
)));
}
$output =& call_user_func_array(array(&$controller, $request->params['action']), $request->params['pass']);
$result =& call_user_func_array(array(&$controller, $request->params['action']), $request->params['pass']);
$response = $controller->getResponse();

if ($controller->autoRender) {
$controller->render();
} elseif ($this->response->body() === null) {
$this->response->body($output);
} elseif ($response->body() === null) {
$response->body($result);
}
$controller->shutdownProcess();

if (isset($request->params['return'])) {
return $this->response->body();
return $response->body();
}
$this->response->send();
$response->send();
}

/**
Expand Down Expand Up @@ -256,14 +256,9 @@ protected function &_getController() {
if (!$ctrlClass) {
return $controller;
}
if (!$this->response) {
$this->response = new CakeResponse(array(
'charset' => Configure::read('App.encoding')
));
}
$ctrlClass .= 'Controller';
if (class_exists($ctrlClass)) {
$controller = new $ctrlClass($this->request, $this->response);
$controller = new $ctrlClass($this->request);
}
return $controller;
}
Expand Down

0 comments on commit 91c9c74

Please sign in to comment.