Example #1
0
 /**
  * Saves or loads the Shortcode cache
  *
  * If your Shortcodes will remain the same for a long period of time,
  * use this to reload the Shortcodes from the cache rather than redefining
  * them on every page load.
  *
  * Example:
  * ~~~
  * if ( ! Shortcode::cache())
  * {
  *     // Set Shortcodes here
  *     Shortcode::cache(TRUE);
  * }
  * ~~~
  *
  * @param   boolean  $save    Cache the current Shortcodes [Optional]
  * @param   boolean  $append  Append, rather than replace, cached Shortcodes when loading [Optional]
  *
  * @return  boolean
  *
  * @uses    Kohana::cache
  */
 public static function cache($save = FALSE, $append = FALSE)
 {
     $cache = Cache::instance();
     if ($save === TRUE) {
         // Cache all defined shortcodes
         return $cache->set('Shortcode::cache()', self::$_tags);
     } else {
         if ($tags = $cache->get('Shortcode::cache()')) {
             if ($append) {
                 // Append cached Shortcodes
                 self::$_tags += $tags;
             } else {
                 // Replace existing Shortcodes
                 self::$_tags = $tags;
             }
             // Shortcodes were cached
             return self::$_cache = TRUE;
         } else {
             // Shortcodes were not cached
             return self::$_cache = FALSE;
         }
     }
 }