public function LessphpFilter::filterLoad

Filters an asset after it has been loaded.

Parameters

AssetInterface $asset An asset:

Overrides FilterInterface::filterLoad

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/LessphpFilter.php, line 82

Class

LessphpFilter
Loads LESS files using the PHP implementation of less, lessphp.

Namespace

Assetic\Filter

Code

public function filterLoad(AssetInterface $asset) {
  $root = $asset
    ->getSourceRoot();
  $path = $asset
    ->getSourcePath();
  $lc = new \lessc();
  if ($root && $path) {
    $lc->importDir = dirname($root . '/' . $path);
  }
  foreach ($this->loadPaths as $loadPath) {
    $lc
      ->addImportDir($loadPath);
  }
  if ($this->formatter) {
    $lc
      ->setFormatter($this->formatter);
  }
  if (null !== $this->preserveComments) {
    $lc
      ->setPreserveComments($this->preserveComments);
  }
  $asset
    ->setContent($lc
    ->parse($asset
    ->getContent(), $this->presets));
}