protected function compress($content, $type, $options = array())
{
$pb = new ProcessBuilder();
$pb
->inheritEnvironmentVariables()
->add($this->javaPath)
->add('-jar')
->add($this->jarPath)
->add('--type')
->add($type)
;
foreach ($options as $option) {
$pb->add($option);
}
if (null !== $this->charset) {
$pb->add('--charset')->add($this->charset);
}
if (null !== $this->lineBreak) {
$pb->add('--line-break')->add($this->lineBreak);
}
$input = tempnam(sys_get_temp_dir(), 'assetic_yui_compressor');
file_put_contents($input, $content);
$pb->add($input);
$proc = $pb->getProcess();
$code = $proc->run();
unlink($input);
if (0 < $code) {
throw new \RuntimeException($proc->getErrorOutput());
}
return $proc->getOutput();
}