public static function getSourceCode($minifier, $cacheHashOrSourceReport, $skipCache = false)
 {
     $cacheHash = is_string($cacheHashOrSourceReport) ? $cacheHashOrSourceReport : $cacheHashOrSourceReport['hash'];
     $cacheKey = "{$minifier}:{$cacheHash}";
     if (!$skipCache && ($code = Cache::fetch($cacheKey))) {
         return $code;
     }
     if (is_array($cacheHashOrSourceReport) && is_array($cacheHashOrSourceReport['files'])) {
         $code = '';
         foreach ($cacheHashOrSourceReport['files'] as $path => $fileData) {
             $code .= $minifier::minify(file_get_contents(SiteFile::getRealPathByID($fileData['ID'])));
         }
         Cache::store($cacheKey, $code);
         return $code;
     }
     return null;
 }
Beispiel #2
0
 public static function loadConfig($className)
 {
     $cacheKey = 'class-config:' . $className;
     if (!($configFileIds = Cache::fetch($cacheKey))) {
         $configFileIds = array();
         // look for primary config file
         if ($lastNsPos = strrpos($className, '\\')) {
             $namespace = substr($className, 0, $lastNsPos);
             $className = substr($className, $lastNsPos + 1);
             $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
         } else {
             $path = '';
         }
         $path .= str_replace('_', DIRECTORY_SEPARATOR, $className);
         $configFileNode = Site::resolvePath("php-config/{$path}.config.php");
         // Fall back on looking for Old_School_Underscore_Namespacing in root
         if (!$configFileNode && empty($namespace) && $path != $className) {
             $configFileNode = Site::resolvePath("php-config/{$className}.config.php");
         }
         if ($configFileNode && $configFileNode->MIMEType == 'application/php') {
             $configFileIds[] = $configFileNode->ID;
         }
         // look for composite config files
         $collectionPath = "php-config/{$path}.config.d";
         Emergence_FS::cacheTree($collectionPath);
         foreach (Emergence_FS::getAggregateChildren($collectionPath) as $filename => $node) {
             if ($node->Type == 'application/php') {
                 $configFileIds[] = $node->ID;
             }
         }
         Cache::store($cacheKey, $configFileIds);
     }
     foreach ($configFileIds as $id) {
         require SiteFile::getRealPathByID($id);
     }
 }