mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
e17a49f8a5
BUG Fix incorrect cache on CacheGeneratedAssetHandler
33 lines
657 B
PHP
33 lines
657 B
PHP
<?php
|
|
|
|
namespace SilverStripe\View;
|
|
|
|
use JSMin;
|
|
use Requirements_Minifier;
|
|
|
|
/**
|
|
* @package framework
|
|
* @subpackage view
|
|
*/
|
|
class JSMinifier implements Requirements_Minifier {
|
|
|
|
public function minify($content, $type, $filename) {
|
|
// Non-js files aren't minified
|
|
if($type !== 'js') {
|
|
return $content . "\n";
|
|
}
|
|
|
|
// Combine JS
|
|
try {
|
|
require_once('thirdparty/jsmin/jsmin.php');
|
|
increase_time_limit_to();
|
|
$content = JSMin::minify($content);
|
|
} catch(Exception $e) {
|
|
$message = $e->getMessage();
|
|
user_error("Failed to minify {$filename}, exception: {$message}", E_USER_WARNING);
|
|
} finally {
|
|
return $content . ";\n";
|
|
}
|
|
}
|
|
}
|