Source of file GssFilter.php
Size: 3,878 Bytes - Last Modified: 2013-06-02T00:13:43+02:00
/home/theseer/Downloads/Symfony/vendor/kriswallsmith/assetic/src/Assetic/Filter/GssFilter.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 | <?php /* * This file is part of the Assetic package, an OpenSky project. * * (c) 2010-2013 OpenSky Project Inc * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Assetic\Filter; use Assetic\Asset\AssetInterface; use Assetic\Exception\FilterException; /** * Filter for the Google Closure Stylesheets Compiler JAR. * * @link http://code.google.com/p/closure-stylesheets/ * @author Matthias Krauser <matthias@krauser.eu> */ class GssFilter extends BaseProcessFilter { private $jarPath; private $javaPath; private $allowUnrecognizedFunctions; private $allowedNonStandardFunctions; private $copyrightNotice; private $define; private $gssFunctionMapProvider; private $inputOrientation; private $outputOrientation; private $prettyPrint; public function __construct($jarPath, $javaPath = '/usr/bin/java') { $this->jarPath = $jarPath; $this->javaPath = $javaPath; } public function setAllowUnrecognizedFunctions($allowUnrecognizedFunctions) { $this->allowUnrecognizedFunctions = $allowUnrecognizedFunctions; } public function setAllowedNonStandardFunctions($allowNonStandardFunctions) { $this->allowedNonStandardFunctions = $allowNonStandardFunctions; } public function setCopyrightNotice($copyrightNotice) { $this->copyrightNotice = $copyrightNotice; } public function setDefine($define) { $this->define = $define; } public function setGssFunctionMapProvider($gssFunctionMapProvider) { $this->gssFunctionMapProvider = $gssFunctionMapProvider; } public function setInputOrientation($inputOrientation) { $this->inputOrientation = $inputOrientation; } public function setOutputOrientation($outputOrientation) { $this->outputOrientation = $outputOrientation; } public function setPrettyPrint($prettyPrint) { $this->prettyPrint = $prettyPrint; } public function filterLoad(AssetInterface $asset) { $cleanup = array(); $pb = $this->createProcessBuilder(array( $this->javaPath, '-jar', $this->jarPath, )); if (null !== $this->allowUnrecognizedFunctions) { $pb->add('--allow-unrecognized-functions'); } if (null !== $this->allowedNonStandardFunctions) { $pb->add('--allowed_non_standard_functions')->add($this->allowedNonStandardFunctions); } if (null !== $this->copyrightNotice) { $pb->add('--copyright-notice')->add($this->copyrightNotice); } if (null !== $this->define) { $pb->add('--define')->add($this->define); } if (null !== $this->gssFunctionMapProvider) { $pb->add('--gss-function-map-provider')->add($this->gssFunctionMapProvider); } if (null !== $this->inputOrientation) { $pb->add('--input-orientation')->add($this->inputOrientation); } if (null !== $this->outputOrientation) { $pb->add('--output-orientation')->add($this->outputOrientation); } if (null !== $this->prettyPrint) { $pb->add('--pretty-print'); } $pb->add($cleanup[] = $input = tempnam(sys_get_temp_dir(), 'assetic_google_closure_stylesheets_compiler')); file_put_contents($input, $asset->getContent()); $proc = $pb->getProcess(); $code = $proc->run(); array_map('unlink', $cleanup); if (0 !== $code) { throw FilterException::fromProcess($proc)->setInput($asset->getContent()); } $asset->setContent($proc->getOutput()); } public function filterDump(AssetInterface $asset) { } } |