Ejemplo n.º 1
0
 public static function includeAsset($file, $type)
 {
     if ($type !== 'js' && $type !== 'css') {
         return array();
     }
     if (preg_match('/^https:|http:/i', $file)) {
         return array($file);
     }
     $serverRootPath = Config::getServerRootPath();
     $file = ltrim($file, DIRECTORY_SEPARATOR) . '.' . $type;
     if (Config::isPrecompileable()) {
         $compiledCacheFile = $serverRootPath . DIRECTORY_SEPARATOR . '.assetsrc';
         if (file_exists($compiledCacheFile)) {
             $compiledCaches = unserialize(file_get_contents($compiledCacheFile));
             if (!empty($compiledCaches[$file])) {
                 return array($compiledCaches[$file]);
             }
         }
         $uglifyClass = '\\Assets\\Uglify\\' . ucfirst($type);
         $distFile = $uglifyClass::uglify($file);
         return $distFile === false ? array() : array($distFile);
     }
     return static::loadCompiledFiles($file, $type);
 }