mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Adding ability to set configuration from initialize() for RequestHandler.
Tests added.
This commit is contained in:
parent
5760f41124
commit
ff74a599c6
2 changed files with 9 additions and 1 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue