3 * Class Minify_Controller_Files
8 * Controller class for minifying a set of files
10 * E.g. the following would serve the minified Javascript for a site
12 * Minify::serve('Files', array(
16 * ,'/home/username/file.js'
21 * As a shortcut, the controller will replace "//" at the beginning
22 * of a filename with $_SERVER['DOCUMENT_ROOT'] . '/'.
25 * @author Stephen Clay <steve@mrclay.org>
27 class Minify_Controller_Files extends Minify_Controller_Base {
32 * @param array $options controller and Minify options
33 * @return array Minify options
37 * 'files': (required) array of complete file paths, or a single path
39 public function setupSources($options) {
40 // strip controller options
42 $files = $options['files'];
43 // if $files is a single object, casting will break it
44 if (is_object($files)) {
45 $files = array($files);
46 } elseif (! is_array($files)) {
47 $files = (array)$files;
49 unset($options['files']);
52 foreach ($files as $file) {
53 if ($file instanceof Minify_Source) {
57 if (0 === strpos($file, '//')) {
58 $file = $_SERVER['DOCUMENT_ROOT'] . substr($file, 1);
60 $realPath = realpath($file);
61 if (is_file($realPath)) {
62 $sources[] = new Minify_Source(array(
63 'filepath' => $realPath
66 $this->log("The path \"{$file}\" could not be found (or was not a file)");
71 $this->sources = $sources;