class GssFilter

Filter for the Google Closure Stylesheets Compiler JAR.

@link http://code.google.com/p/closure-stylesheets/ @author Matthias Krauser <matthias@krauser.eu>

Hierarchy

Expanded class hierarchy of GssFilter

1 file declares its use of GssFilter
GssFilterTest.php in drupal/core/vendor/kriswallsmith/assetic/tests/Assetic/Test/Filter/GssFilterTest.php

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/GssFilter.php, line 24

Namespace

Assetic\Filter
View source
class GssFilter implements FilterInterface {
  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 = new ProcessBuilder(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) {
  }

}

Members

Namesort descending Modifiers Type Description Overrides
GssFilter::$allowedNonStandardFunctions private property
GssFilter::$allowUnrecognizedFunctions private property
GssFilter::$copyrightNotice private property
GssFilter::$define private property
GssFilter::$gssFunctionMapProvider private property
GssFilter::$inputOrientation private property
GssFilter::$jarPath private property
GssFilter::$javaPath private property
GssFilter::$outputOrientation private property
GssFilter::$prettyPrint private property
GssFilter::filterDump public function Filters an asset just before it's dumped. Overrides FilterInterface::filterDump
GssFilter::filterLoad public function Filters an asset after it has been loaded. Overrides FilterInterface::filterLoad
GssFilter::setAllowedNonStandardFunctions public function
GssFilter::setAllowUnrecognizedFunctions public function
GssFilter::setCopyrightNotice public function
GssFilter::setDefine public function
GssFilter::setGssFunctionMapProvider public function
GssFilter::setInputOrientation public function
GssFilter::setOutputOrientation public function
GssFilter::setPrettyPrint public function
GssFilter::__construct public function