public static function GetTree() { $blnCache = false; $arrFormattedParseTree = false; // Since the result of Category::parseTree depends on the language we // need one cache entry per language. $cacheKey = self::PARSE_TREE_CACHE_ID . '::' . Yii::app()->getLanguage(); if (isset(Yii::app()->cache)) { $blnCache = true; $arrFormattedParseTree = Yii::app()->cache->get($cacheKey); } if ($arrFormattedParseTree === false) { $criteria = new CDbCriteria(); $criteria->alias = 'Category'; $criteria->order = 'menu_position'; $criteria->index = 'id'; $arrCategories = Category::model()->findAll($criteria); $arrCategoriesChildren = self::_getCategoriesChildren($arrCategories); $arrFormattedParseTree = Category::parseTree($arrCategories, $arrCategoriesChildren, array('Category', 'formatForCMenuAndCTreeView')); if ($blnCache) { Yii::app()->cache->set($cacheKey, $arrFormattedParseTree, self::PARSE_TREE_CACHE_TIME); } } return $arrFormattedParseTree; }