mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding settings['callbacks'] as a way to define enabled/disabled state of helpers in settings arrays. This should replace the separate parameter.
Tests updated.
This commit is contained in:
parent
92fec4588a
commit
1ba28c246b
2 changed files with 18 additions and 1 deletions
|
@ -38,6 +38,9 @@ class HelperCollection extends ObjectCollection {
|
|||
|
||||
/**
|
||||
* Loads/constructs a helper. Will return the instance in the registry if it already exists.
|
||||
* By setting `$enable` to false you can disable callbacks for a helper. Alternatively you
|
||||
* can set `$settings['callbacks'] = false` to disable callbacks. This alias is provided so that when
|
||||
* declaring $helpers arrays you can disable callbacks on helpers.
|
||||
*
|
||||
* @param string $helper Helper name to load
|
||||
* @param array $settings Settings for the helper.
|
||||
|
@ -72,7 +75,7 @@ class HelperCollection extends ObjectCollection {
|
|||
foreach ($vars as $var) {
|
||||
$this->_loaded[$name]->{$var} = $this->_View->{$var};
|
||||
}
|
||||
|
||||
$enable = isset($settings['callbacks']) ? $settings['callbacks'] : $enable;
|
||||
if ($enable === true) {
|
||||
$this->_enabled[] = $name;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,20 @@ class HelperCollectionTest extends CakeTestCase {
|
|||
|
||||
$this->assertFalse($this->Helpers->enabled('Html'), 'Html should be disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* test that the callbacks setting disables the helper.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testLoadWithCallbacksFalse() {
|
||||
$result = $this->Helpers->load('Html', array('callbacks' => false));
|
||||
$this->assertType('HtmlHelper', $result);
|
||||
$this->assertType('HtmlHelper', $this->Helpers->Html);
|
||||
|
||||
$this->assertFalse($this->Helpers->enabled('Html'), 'Html should be disabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* test missinghelper exception
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue