Adding ability to set configuration from initialize() for RequestHandler.

Tests added.
This commit is contained in:
Mark Story 2009-12-16 23:02:57 -05:00
parent 5760f41124
commit ff74a599c6
2 changed files with 9 additions and 1 deletions

View file

@ -165,14 +165,16 @@ class RequestHandlerComponent extends Object {
* as the first item. * as the first item.
* *
* @param object $controller A reference to the controller * @param object $controller A reference to the controller
* @param array $settings Array of settings to _set().
* @return void * @return void
* @see Router::parseExtensions() * @see Router::parseExtensions()
* @access public * @access public
*/ */
function initialize(&$controller) { function initialize(&$controller, $settings = array()) {
if (isset($controller->params['url']['ext'])) { if (isset($controller->params['url']['ext'])) {
$this->ext = $controller->params['url']['ext']; $this->ext = $controller->params['url']['ext'];
} }
$this->_set($settings);
} }
/** /**

View file

@ -186,6 +186,12 @@ class RequestHandlerComponentTest extends CakeTestCase {
$this->Controller->params['url']['ext'] = 'rss'; $this->Controller->params['url']['ext'] = 'rss';
$this->RequestHandler->initialize($this->Controller); $this->RequestHandler->initialize($this->Controller);
$this->assertEqual($this->RequestHandler->ext, 'rss'); $this->assertEqual($this->RequestHandler->ext, 'rss');
$settings = array(
'ajaxLayout' => 'test_ajax'
);
$this->RequestHandler->initialize($this->Controller, $settings);
$this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax');
} }
/** /**