Skip to content

Commit

Permalink
Adding ability to set configuration from initialize() for RequestHand…
Browse files Browse the repository at this point in the history
…ler.

Tests added.
  • Loading branch information
markstory committed Dec 17, 2009
1 parent 5760f41 commit ff74a59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cake/libs/controller/components/request_handler.php
Expand Up @@ -165,14 +165,16 @@ function __construct() {
* as the first item.
*
* @param object $controller A reference to the controller
* @param array $settings Array of settings to _set().
* @return void
* @see Router::parseExtensions()
* @access public
*/
function initialize(&$controller) {
function initialize(&$controller, $settings = array()) {
if (isset($controller->params['url']['ext'])) {
$this->ext = $controller->params['url']['ext'];
}
$this->_set($settings);
}

/**
Expand Down
Expand Up @@ -186,6 +186,12 @@ function testInitializeCallback() {
$this->Controller->params['url']['ext'] = 'rss';
$this->RequestHandler->initialize($this->Controller);
$this->assertEqual($this->RequestHandler->ext, 'rss');

$settings = array(
'ajaxLayout' => 'test_ajax'
);
$this->RequestHandler->initialize($this->Controller, $settings);
$this->assertEqual($this->RequestHandler->ajaxLayout, 'test_ajax');
}

/**
Expand Down

0 comments on commit ff74a59

Please sign in to comment.