mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
Disabling caching of JS files by default. Requiring webroot to be
writable by default it not a good idea.
This commit is contained in:
parent
0bd3cc97c1
commit
f15b793a4a
2 changed files with 5 additions and 3 deletions
|
@ -122,7 +122,7 @@ class JsHelper extends AppHelper {
|
||||||
*
|
*
|
||||||
* - 'inline' - Set to true to have scripts output as a script block inline
|
* - 'inline' - Set to true to have scripts output as a script block inline
|
||||||
* if 'cache' is also true, a script link tag will be generated. (default true)
|
* if 'cache' is also true, a script link tag will be generated. (default true)
|
||||||
* - 'cache' - Set to true to have scripts cached to a file and linked in (default true)
|
* - 'cache' - Set to true to have scripts cached to a file and linked in (default false)
|
||||||
* - 'clear' - Set to false to prevent script cache from being cleared (default true)
|
* - 'clear' - Set to false to prevent script cache from being cleared (default true)
|
||||||
* - 'onDomReady' - wrap cached scripts in domready event (default true)
|
* - 'onDomReady' - wrap cached scripts in domready event (default true)
|
||||||
* - 'safe' - if an inline block is generated should it be wrapped in <![CDATA[ ... ]]> (default true)
|
* - 'safe' - if an inline block is generated should it be wrapped in <![CDATA[ ... ]]> (default true)
|
||||||
|
@ -131,7 +131,7 @@ class JsHelper extends AppHelper {
|
||||||
* @return string completed javascript tag.
|
* @return string completed javascript tag.
|
||||||
**/
|
**/
|
||||||
function writeScripts($options = array()) {
|
function writeScripts($options = array()) {
|
||||||
$defaults = array('onDomReady' => true, 'inline' => true, 'cache' => true, 'clear' => true, 'safe' => true);
|
$defaults = array('onDomReady' => true, 'inline' => true, 'cache' => false, 'clear' => true, 'safe' => true);
|
||||||
$options = array_merge($defaults, $options);
|
$options = array_merge($defaults, $options);
|
||||||
$script = implode("\n", $this->getCache($options['clear']));
|
$script = implode("\n", $this->getCache($options['clear']));
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ class JsHelperTestCase extends CakeTestCase {
|
||||||
$this->Js->JsBaseEngine = new TestJsEngineHelper();
|
$this->Js->JsBaseEngine = new TestJsEngineHelper();
|
||||||
$this->Js->writeCache('one = 1;');
|
$this->Js->writeCache('one = 1;');
|
||||||
$this->Js->writeCache('two = 2;');
|
$this->Js->writeCache('two = 2;');
|
||||||
$result = $this->Js->writeScripts(array('onDomReady' => false));
|
$result = $this->Js->writeScripts(array('onDomReady' => false, 'cache' => true));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'),
|
'script' => array('type' => 'text/javascript', 'src' => 'preg:/(.)*\.js/'),
|
||||||
);
|
);
|
||||||
|
@ -180,6 +180,8 @@ class JsHelperTestCase extends CakeTestCase {
|
||||||
$this->assertTrue(file_exists(WWW_ROOT . $filename[1]));
|
$this->assertTrue(file_exists(WWW_ROOT . $filename[1]));
|
||||||
$contents = file_get_contents(WWW_ROOT . $filename[1]);
|
$contents = file_get_contents(WWW_ROOT . $filename[1]);
|
||||||
$this->assertPattern('/one\s=\s1;\ntwo\s=\s2;/', $contents);
|
$this->assertPattern('/one\s=\s1;\ntwo\s=\s2;/', $contents);
|
||||||
|
|
||||||
|
@unlink(WWW_ROOT . $filename[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue