Пример #1
0
 static function loadFor($apps)
 {
     if (empty(self::$app_config)) {
         self::$loaded = true;
         if (false === ($cache = Cache::get('appconfig', join(DIRECTORY_SEPARATOR, array_filter($apps))))) {
             $appspath = array('');
             $buffer = '';
             foreach ($apps as $app) {
                 if (!empty($app)) {
                     $buffer .= DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . $app;
                     $appspath[] = $buffer;
                 }
             }
             foreach ($appspath as $currentpath) {
                 $app_config = array();
                 $path = ROOT . DIRECTORY_SEPARATOR . 'app' . $currentpath . DIRECTORY_SEPARATOR . 'config';
                 $configfiles = is_dir($path) ? Tools::file_get_contents_loop($path) : array();
                 foreach ($configfiles as $name => $content) {
                     $app_config[$name] = json_decode($content, true);
                 }
                 $app_config = Tools::flatten($app_config);
                 self::$app_config = array_merge(self::$app_config, $app_config);
             }
             Cache::create('appconfig', join(DIRECTORY_SEPARATOR, array_filter($apps)), self::$app_config, 'on_demand');
         } else {
             self::$app_config = $cache;
         }
     }
 }