private function minifyCSS($file)
{
$fileName = md5($file) . '.css';
$finalURL = FRONTEND_CACHE_URL . '/MinifiedCss/' . $fileName;
$finalPath = FRONTEND_CACHE_PATH . '/MinifiedCss/' . $fileName;
// check that file does not yet exist or has been updated already
$filesystem = new Filesystem();
if (!$filesystem->exists($finalPath) || filemtime(PATH_WWW . $file) > filemtime($finalPath)) {
// create directory if it does not exist
if (!$filesystem->exists(dirname($finalPath))) {
$filesystem->mkdir(dirname($finalPath));
}
// minify the file
$css = new Minify\CSS(PATH_WWW . $file);
$css->minify($finalPath);
}
return $finalURL;
}