Example #1
0
 /**
  * Receives all module <-> id combinations from the database.
  *
  * This is somewhat a pretty stupid caching mechanism,
  * but as the module id itself is used often,
  * we try not to do it using active record.
  *
  * The method returns an array of the following format:
  *  array( MODULENAME => MODULEID,
  *         MODULENAME => MODULEID );
  *
  * @return array Array with 'id', 'label' and 'saveType'.
  */
 protected static function _getCachedIds()
 {
     if (isset(self::$_cache) && null !== self::$_cache) {
         return self::$_cache;
     }
     $moduleNamespace = new Zend_Session_Namespace('Phprojekt_Module_Module-_getCachedIds');
     if (!isset($moduleNamespace->modules)) {
         $db = Phprojekt::getInstance()->getDb();
         $select = $db->select()->from('module');
         $stmt = $db->query($select);
         $rows = $stmt->fetchAll();
         foreach ($rows as $row) {
             self::$_cache[$row['name']] = array('id' => $row['id'], 'label' => $row['label'], 'saveType' => $row['save_type']);
         }
         $moduleNamespace->modules = self::$_cache;
     } else {
         self::$_cache = $moduleNamespace->modules;
     }
     if (isset(self::$_cache)) {
         return self::$_cache;
     } else {
         return array();
     }
 }
Example #2
0
 /**
  * Removes the cached data.
  *
  * @return void
  */
 public static function clearCache()
 {
     Phprojekt::getInstance()->getCache()->load(self::CACHE_ID);
     Phprojekt::getInstance()->getCache()->clean(Zend_Cache::CLEANING_MODE_ALL);
     self::$_cache = null;
 }