mirror of
https://github.com/mrclay/minify.git
synced 2025-08-16 11:03:59 +02:00
V1.9.0 overhaul
This commit is contained in:
46
lib/Minify/Controller/Files.php
Normal file
46
lib/Minify/Controller/Files.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
require_once 'Minify/Controller/Base.php';
|
||||
|
||||
/**
|
||||
* Controller class for minifying a set of files
|
||||
*
|
||||
* E.g. the following would serve minified Javascript for a site
|
||||
* <code>
|
||||
* $dr = $_SERVER['DOCUMENT_ROOT'];
|
||||
* Minify::minify('Files', array(
|
||||
* $dr . '/js/jquery.js'
|
||||
* ,$dr . '/js/plugins.js'
|
||||
* ,$dr . '/js/site.js'
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
class Minify_Controller_Files extends Minify_Controller_Base {
|
||||
|
||||
/**
|
||||
* @param array $spec array or full paths of files to be minified
|
||||
*
|
||||
* @param array $options optional options to pass to Minify
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function __construct($spec, $options = array()) {
|
||||
$sources = array();
|
||||
foreach ($spec as $file) {
|
||||
$file = realpath($file);
|
||||
if (file_exists($file)) {
|
||||
$sources[] = new Minify_Source(array(
|
||||
'filepath' => $file
|
||||
));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ($sources) {
|
||||
$this->requestIsValid = true;
|
||||
}
|
||||
parent::__construct($sources, $options);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user