Ejemplo n.º 1
0
 private function getFlatData()
 {
     if (isset(self::$flat)) {
         return self::$flat;
     }
     $config = $this->getConfig();
     $flat = array();
     $all = array();
     $cacheId = 'flat';
     $cached = $this->getCache($cacheId);
     if ($cached && isset($config['php: cache scripts.json']) && $config['php: cache scripts.json']) {
         self::$flat = $cached;
         return $cached;
     }
     foreach ($config['libs'] as $libraryName => $library) {
         $scripts = $this->getScriptsFromLibraryName($libraryName);
         if (!is_array($scripts)) {
             die($libraryName . ' scripts.json file did not parse correctly. (Located at ' . realpath($this->addRoot($library['scripts']) . '/' . self::ScriptsFilename) . ')');
         }
         foreach ($scripts as $categoryName => $categotyScripts) {
             foreach ($categotyScripts as $scriptName => $script) {
                 $script['library'] = $libraryName;
                 $script['category'] = $categoryName;
                 $script['name'] = $scriptName;
                 $script['path'] = $this->addRoot($library['scripts']) . '/' . $script['category'] . '/' . $script['name'] . '.js';
                 $all[$scriptName] = $script;
             }
         }
     }
     $this->setCache($cacheId, $all);
     self::$flat = $all;
     return $all;
 }