compressCss() public method

public compressCss ( array $files, string $includePath = '' ) : string
$files array
$includePath string The directory where to compressed css is. with trailing slash!
return string
コード例 #1
0
ファイル: CssHandler.php プロジェクト: jarves/jarves
 /**
  * @param array $files
  *
  * @return AssetInfo
  */
 public function compressFiles(array $files)
 {
     $md5String = '';
     foreach ($files as $file) {
         $path = $this->getAssetPath($file);
         $md5String .= '.' . filemtime($path);
     }
     $fileUpToDate = false;
     $md5Line = '/* ' . md5($md5String) . " */\n";
     $oFile = 'cache/compressed-css/' . md5($md5String) . '.css';
     $handle = @fopen($this->getJarves()->getRootDir() . '/../web/' . $oFile, 'r');
     if ($handle) {
         $line = fgets($handle);
         fclose($handle);
         if ($line == $md5Line) {
             $fileUpToDate = true;
         }
     }
     if (!$fileUpToDate) {
         $content = $this->utils->compressCss($files, 'cache/compressed-css/');
         $content = $md5Line . $content;
         $this->webFilesystem->write($oFile, $content);
     }
     $assetInfo = new AssetInfo();
     $assetInfo->setPath($oFile);
     return $assetInfo;
 }