public static function createDictCache() { self::createCacheFile(); $content = '<?php' . self::$newLine; $categories = DictCategory::findAll(); foreach ($categories as $category) { $content .= '$cachedDicts[\'' . $category['id'] . '\']=[' . self::$newLine; $dicts = Dict::_getDictArrayTree($category['id'], 0, 0); foreach ($dicts as $row) { $id = $row['id']; $childrenIds = Dict::getChildrenIds($id); $content .= ' \'' . $id . '\'=>[' . self::$newLine; $content .= ' ' . self::getCacheItem('id', $row, 'int'); $content .= ' ' . self::getCacheItem('parent_id', $row, 'int'); $content .= ' ' . self::getCacheItemValue('child_ids', implode(',', $childrenIds)); $content .= ' ' . self::getCacheItem('category_id', $row); $content .= ' ' . self::getCacheItem('name', $row); $content .= ' ' . self::getCacheItem('value', $row); $content .= ' ' . self::getCacheItem('level', $row, 'int'); $content .= ' ' . self::getCacheItem('sort_num', $row, 'int'); $content .= "\t]," . self::$newLine; } $content .= "];" . self::$newLine; } self::writeFile('cachedDicts.php', $content); }