function getOutput($work_unit) { $debug = $this->getConfig()->getDebugMode() == 3; if ($work_unit['file']) { $css = @file_get_contents($work_unit['file']); if (!$css) { return "/* error accessing file */"; } $source_file = $work_unit['file']; } else { $css = $work_unit['content']; $source_file = $this->getSourceFile(); } if (ExternalProcessorRegistry::typeIsSupported($work_unit['type'])) { $opts = array(); if ($work_unit['paths']) { $opts['library_path'] = $work_unit['paths']; } $css = ExternalProcessorRegistry::getTransformerForType($work_unit['type'])->transform($css, $source_file, $opts); } else { if ($work_unit['type'] == 'text/x-less') { $less = new \lessc(); $less->importDir = dirname($source_file) . '/'; #lessphp concatenates without a / $css = $less->parse($css); } if (PhpSassSacy::isAvailable() && $work_unit['type'] == 'text/x-scss') { $css = PhpSassSacy::compile($source_file, $work_unit['paths'] ?: array(dirname($source_file))); } elseif (in_array($work_unit['type'], array('text/x-scss', 'text/x-sass'))) { $config = array('cache' => false, 'debug_info' => $debug, 'line' => $debug, 'load_paths' => $work_unit['paths'] ?: array(dirname($source_file)), 'filename' => $source_file, 'quiet' => true, 'style' => $debug ? 'nested' : 'compressed'); $sass = new \SassParser($config); $css = $sass->toCss($css, false); // isFile? } } if ($debug) { return \Minify_CSS_UriRewriter::rewrite($css, dirname($source_file), $this->getConfig()->getDocumentRoot(), array()); } else { return \Minify_CSS::minify($css, array('currentDir' => dirname($source_file), 'docRoot' => $this->getConfig()->getDocumentRoot())); } }