Skip to content

Commit

Permalink
Fix issue in RequestHandlerComponent.
Browse files Browse the repository at this point in the history
Fixes issues where response and request properties would
not be set as the initialize() callback would have not fired.

Fixes #2190
Fixes #2189
  • Loading branch information
markstory committed Nov 1, 2011
1 parent 6623b7d commit 550076d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
8 changes: 5 additions & 3 deletions lib/Cake/Controller/Component/RequestHandlerComponent.php
Expand Up @@ -91,8 +91,12 @@ class RequestHandlerComponent extends Component {
* @param array $settings Array of settings.
*/
public function __construct(ComponentCollection $collection, $settings = array()) {
$this->addInputType('xml', array(array($this, 'convertXml')));
parent::__construct($collection, $settings);
$this->addInputType('xml', array(array($this, 'convertXml')));

$Controller = $collection->getController();
$this->request = $Controller->request;
$this->response = $Controller->response;
}

/**
Expand All @@ -107,8 +111,6 @@ public function __construct(ComponentCollection $collection, $settings = array()
* @see Router::parseExtensions()
*/
public function initialize($controller, $settings = array()) {
$this->request = $controller->request;
$this->response = $controller->response;
if (isset($this->request->params['ext'])) {
$this->ext = $this->request->params['ext'];
}
Expand Down
Expand Up @@ -29,13 +29,6 @@
*/
class RequestHandlerTestController extends Controller {

/**
* name property
*
* @var string
*/
public $name = 'RequestHandlerTest';

/**
* uses property
*
Expand Down Expand Up @@ -117,9 +110,8 @@ function _init() {
$request = new CakeRequest('controller_posts/index');
$response = new CakeResponse();
$this->Controller = new RequestHandlerTestController($request, $response);
$this->Controller->constructClasses();
$this->RequestHandler = new RequestHandlerComponent($this->Controller->Components);
$this->RequestHandler->request = $request;
$this->RequestHandler->response = $response;
$this->_extensions = Router::extensions();
}

Expand Down Expand Up @@ -148,6 +140,7 @@ public function testConstructorSettings() {
'ajaxLayout' => 'test_ajax'
);
$Collection = new ComponentCollection();
$Collection->init($this->Controller);
$RequestHandler = new RequestHandlerComponent($Collection, $settings);
$this->assertEqual($RequestHandler->ajaxLayout, 'test_ajax');
}
Expand Down

0 comments on commit 550076d

Please sign in to comment.