Merge "Make autoblocks update with the parent block"
[lhc/web/wiklou.git] / includes / actions / CachedAction.php
index d21f9ae..186ad46 100644 (file)
@@ -1,22 +1,8 @@
 <?php
-
 /**
  * Abstract action class with scaffolding for caching HTML and other values
  * in a single blob.
  *
- * Before using any of the caching functionality, call startCache.
- * After the last call to either getCachedValue or addCachedHTML, call saveCache.
- *
- * To get a cached value or compute it, use getCachedValue like this:
- * $this->getCachedValue( $callback );
- *
- * To add HTML that should be cached, use addCachedHTML like this:
- * $this->addCachedHTML( $callback );
- *
- * The callback function is only called when needed, so do all your expensive
- * computations here. This function should returns the HTML to be cached.
- * It should not add anything to the PageOutput object!
- *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * http://www.gnu.org/copyleft/gpl.html
  *
  * @file
- * @ingroup Action
+ * @ingroup Actions
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  * @since 1.20
  */
+
+/**
+ * Abstract action class with scaffolding for caching HTML and other values
+ * in a single blob.
+ *
+ * Before using any of the caching functionality, call startCache.
+ * After the last call to either getCachedValue or addCachedHTML, call saveCache.
+ *
+ * To get a cached value or compute it, use getCachedValue like this:
+ * $this->getCachedValue( $callback );
+ *
+ * To add HTML that should be cached, use addCachedHTML like this:
+ * $this->addCachedHTML( $callback );
+ *
+ * The callback function is only called when needed, so do all your expensive
+ * computations here. This function should returns the HTML to be cached.
+ * It should not add anything to the PageOutput object!
+ *
+ * @ingroup Actions
+ */
 abstract class CachedAction extends FormlessAction implements ICacheHelper {
 
        /**
@@ -127,7 +133,8 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper {
         * @param string|null $key
         */
        public function addCachedHTML( $computeFunction, $args = array(), $key = null ) {
-               $this->getOutput()->addHTML( $this->cacheHelper->getCachedValue( $computeFunction, $args, $key ) );
+               $html = $this->cacheHelper->getCachedValue( $computeFunction, $args, $key );
+               $this->getOutput()->addHTML( $html );
        }
 
        /**
@@ -141,7 +148,8 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper {
        }
 
        /**
-        * Sets the time to live for the cache, in seconds or a unix timestamp indicating the point of expiry.
+        * Sets the time to live for the cache, in seconds or a unix timestamp
+        * indicating the point of expiry.
         *
         * @since 1.20
         *
@@ -178,5 +186,4 @@ abstract class CachedAction extends FormlessAction implements ICacheHelper {
                        $this->getOutput()->setSubtitle( $this->cacheHelper->getCachedNotice( $this->getContext() ) );
                }
        }
-
 }