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-js/' . md5($md5String) . '.js';
$handle = @fopen($this->getJarves()->getRootDir() . '/../web/' . $oFile, 'r');
if ($handle) {
$line = fgets($handle);
fclose($handle);
if ($line == $md5Line) {
$fileUpToDate = true;
}
}
if (!$fileUpToDate) {
// googles minifier
// $result = $this->getJarves()->getUtils()->compressJs(
// $files,
// $oFile
// );
$content = '';
foreach ($files as $assetPath) {
$content .= "\n/* {$assetPath} */\n\n";
$path = $this->getAssetPath($assetPath);
$content .= file_get_contents($path);
}
$content = $md5Line . $content;
$this->webFilesystem->write($oFile, $content);
}
$assetInfo = new AssetInfo();
$assetInfo->setPath($oFile);
return $assetInfo;
}