Skip to content

Commit faf7954

Browse files
author
Lars Nyström
committed
Added BundleOn toggle.
1 parent 0e39710 commit faf7954

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

BundlePhu/View/Helper/BundleLink.php

+21-2
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ class BundlePhu_View_Helper_BundleLink extends Zend_View_Helper_HeadLink
117117
* @var callback
118118
*/
119119
protected $_minifyCallback;
120+
121+
/**
122+
* Toggle, whether to bundle or not.
123+
*
124+
* @var bundleOn
125+
*/
126+
protected $_bundleOn = true;
120127

121128
public function setView(Zend_View_Interface $view) {
122129
$this->view = $view;
@@ -273,6 +280,18 @@ public function setGzipEncoding($encodingMode)
273280
$this->_gzipEncoding = $encodingMode;
274281
return $this;
275282
}
283+
284+
/**
285+
* Turn off or on bundling
286+
*
287+
* @param boolean $bundle True to bundle, false otherwise.
288+
* @return BundlePhu_View_Helper_BundleLink $this
289+
*/
290+
public function setBundleOn($bundle)
291+
{
292+
$this->_bundleOn = (bool) $bundle;
293+
return $this;
294+
}
276295

277296
/**
278297
* Iterates over stylesheets, concatenating, optionally minifying,
@@ -290,7 +309,7 @@ public function setGzipEncoding($encodingMode)
290309
*/
291310
public function toString($indent = null)
292311
{
293-
if (isset($_REQUEST['bundle_off'])) {
312+
if (false == $this->_bundleOn || isset($_REQUEST['bundle_off'])) {
294313
return parent::toString($indent);
295314
}
296315

@@ -402,4 +421,4 @@ protected function _writeCompressed($cacheFile, $data)
402421
$data = gzencode($data, $this->_gzipLevel);
403422
file_put_contents("$cacheFile.gz", $data);
404423
}
405-
}
424+
}

BundlePhu/View/Helper/BundleScript.php

+22-3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ class BundlePhu_View_Helper_BundleScript extends Zend_View_Helper_HeadScript
118118
* @var callback
119119
*/
120120
protected $_minifyCallback;
121+
122+
/**
123+
* Toggle, whether to bundle or not.
124+
*
125+
* @var bundleOn
126+
*/
127+
protected $_bundleOn = true;
121128

122129
public function setView(Zend_View_Interface $view)
123130
{
@@ -275,7 +282,19 @@ public function setGzipEncoding($encodingMode)
275282
$this->_gzipEncoding = $encodingMode;
276283
return $this;
277284
}
278-
285+
286+
/**
287+
* Turn off or on bundling
288+
*
289+
* @param boolean $bundle True to bundle, false otherwise.
290+
* @return BundlePhu_View_Helper_BundleLink $this
291+
*/
292+
public function setBundleOn($bundle)
293+
{
294+
$this->_bundleOn = (bool) $bundle;
295+
return $this;
296+
}
297+
279298
/**
280299
* Iterates over scripts, concatenating, optionally minifying,
281300
* optionally compressiong, and caching them.
@@ -295,7 +314,7 @@ public function setGzipEncoding($encodingMode)
295314
*/
296315
public function toString($indent = null)
297316
{
298-
if (isset($_REQUEST['bundle_off'])) {
317+
if (false == $this->_bundleOn || isset($_REQUEST['bundle_off'])) {
299318
return parent::toString($indent);
300319
}
301320

@@ -415,4 +434,4 @@ protected function _writeCompressed($cacheFile, $data)
415434
$data = gzencode($data, $this->_gzipLevel);
416435
file_put_contents("$cacheFile.gz", $data);
417436
}
418-
}
437+
}

0 commit comments

Comments
 (0)