Permalink
Browse files

Re-factoring duplicated code out.

  • Loading branch information...
1 parent 39b1203 commit dcf8c0fd04f7de10e88cddc4b74962e3e452e2c1 @markstory markstory committed Oct 9, 2011
Showing with 11 additions and 4 deletions.
  1. +11 −4 lib/Cake/View/Helper/CacheHelper.php
@@ -53,15 +53,23 @@ class CacheHelper extends AppHelper {
*/
protected $_counter = 0;
+/**
+ * Is CacheHelper enabled? should files + output be parsed.
+ *
+ * @return boolean
+ */
+ protected function _enabled() {
+ return (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
+ }
+
/**
* Parses the view file and stores content for cache file building.
*
* @param string $viewFile
* @return void
*/
public function afterRender($viewFile) {
- $caching = (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
- if ($caching) {
+ if ($this->_enabled()) {
$this->_View->output = $this->cache($viewFile, $this->_View->output, false);
}
}
@@ -73,8 +81,7 @@ public function afterRender($viewFile) {
* @return void
*/
public function afterLayout($layoutFile) {
- $caching = (($this->_View->cacheAction != false)) && (Configure::read('Cache.check') === true);
- if ($caching) {
+ if ($this->_enabled()) {
$this->_View->output = $this->cache($layoutFile, $this->_View->output, true);
}
$this->_View->output = preg_replace('/<!--\/?nocache-->/', '', $this->_View->output);

0 comments on commit dcf8c0f

Please sign in to comment.