Permalink
Browse files

Fix issue in RequestHandlerComponent.

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...
1 parent 6623b7d commit 550076d75ed7f0ea7488486f9f2872cfd9c7fe2d @markstory markstory committed Nov 1, 2011
@@ -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;
}
/**
@@ -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'];
}
@@ -30,13 +30,6 @@
class RequestHandlerTestController extends Controller {
/**
- * name property
- *
- * @var string
- */
- public $name = 'RequestHandlerTest';
-
-/**
* uses property
*
* @var mixed null
@@ -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();
}
@@ -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');
}

0 comments on commit 550076d

Please sign in to comment.