Filters an asset after it has been loaded.
AssetInterface $asset An asset:
Overrides FilterInterface::filterLoad
public function filterLoad(AssetInterface $asset) {
$sassProcessArgs = array(
$this->sassPath,
);
if (null !== $this->rubyPath) {
$sassProcessArgs = array_merge(explode(' ', $this->rubyPath), $sassProcessArgs);
}
$pb = $this
->createProcessBuilder($sassProcessArgs);
$root = $asset
->getSourceRoot();
$path = $asset
->getSourcePath();
if ($root && $path) {
$pb
->add('--load-path')
->add(dirname($root . '/' . $path));
}
if ($this->unixNewlines) {
$pb
->add('--unix-newlines');
}
if (true === $this->scss || null === $this->scss && 'scss' == pathinfo($path, PATHINFO_EXTENSION)) {
$pb
->add('--scss');
}
if ($this->style) {
$pb
->add('--style')
->add($this->style);
}
if ($this->quiet) {
$pb
->add('--quiet');
}
if ($this->debugInfo) {
$pb
->add('--debug-info');
}
if ($this->lineNumbers) {
$pb
->add('--line-numbers');
}
foreach ($this->loadPaths as $loadPath) {
$pb
->add('--load-path')
->add($loadPath);
}
if ($this->cacheLocation) {
$pb
->add('--cache-location')
->add($this->cacheLocation);
}
if ($this->noCache) {
$pb
->add('--no-cache');
}
if ($this->compass) {
$pb
->add('--compass');
}
// input
$pb
->add($input = tempnam(sys_get_temp_dir(), 'assetic_sass'));
file_put_contents($input, $asset
->getContent());
$proc = $pb
->getProcess();
$code = $proc
->run();
unlink($input);
if (0 !== $code) {
throw FilterException::fromProcess($proc)
->setInput($asset
->getContent());
}
$asset
->setContent($proc
->getOutput());
}