Beispiel #1
0
 private static function writeFile($fileName, $content)
 {
     $rootData = \Yii::getAlias('@data');
     TFileHelper::writeFile([$rootData, 'cache', $fileName], $content);
 }
Beispiel #2
0
 public static function createChannelCache()
 {
     $newLine = "\r\n";
     $content = '<?php' . $newLine;
     $dataList = Channel::_getChannelArrayTree(0, 0);
     foreach ($dataList as $row) {
         $id = $row['id'];
         $parentIds = Channel::getParentIds($id);
         $childrenIds = Channel::getChildrenIds($id);
         $leafIds = Channel::getLeafIds($id);
         $content .= '$cachedChannels[' . $row['id'] . ']=[' . $newLine;
         $content .= self::getCacheItem('id', $row, 'int');
         $content .= self::getCacheItem('parent_id', $row, 'int');
         $content .= self::getCacheItemValue('parent_ids', implode(',', $parentIds));
         $content .= self::getCacheItemValue('children_ids', implode(',', $childrenIds));
         $content .= self::getCacheItemValue('leaf_ids', implode(',', $leafIds));
         $content .= self::getCacheItem('name', $row);
         $content .= self::getCacheItem('name_alias', $row);
         $content .= self::getCacheItem('name_url', $row);
         $content .= self::getCacheItem('redirect_url', $row);
         $content .= self::getCacheItem('level', $row, true);
         $content .= self::getCacheItem('is_leaf', $row, true);
         $content .= self::getCacheItem('is_nav', $row, true);
         $content .= self::getCacheItem('sort_num', $row, true);
         $content .= self::getCacheItem('table', $row);
         $content .= self::getCacheItem('channel_tpl', $row);
         $content .= self::getCacheItem('list_tpl', $row);
         $content .= self::getCacheItem('detail_tpl', $row);
         $content .= self::getCacheItem('page_size', $row, true);
         $content .= "];" . $newLine;
     }
     $rootData = \Yii::getAlias('@data');
     TFileHelper::writeFile([$rootData, 'cache', 'cachedChannels.php'], $content);
     return $content;
 }