public function SassFilter::getChildren

Returns child assets.

Parameters

AssetFactory $factory The asset factory:

string $content The asset content:

string $loadPath An optional load path:

Return value

AssetInterface[] Child assets

Overrides DependencyExtractorInterface::getChildren

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Filter/Sass/SassFilter.php, line 184

Class

SassFilter
Loads SASS files.

Namespace

Assetic\Filter\Sass

Code

public function getChildren(AssetFactory $factory, $content, $loadPath = null) {
  $loadPaths = $this->loadPaths;
  if ($loadPath) {
    array_unshift($loadPaths, $loadPath);
  }
  if (!$loadPaths) {
    return array();
  }
  $children = array();
  foreach (CssUtils::extractImports($content) as $reference) {
    if ('.css' === substr($reference, -4)) {

      // skip normal css imports
      // todo: skip imports with media queries
      continue;
    }

    // the reference may or may not have an extension or be a partial
    if (pathinfo($reference, PATHINFO_EXTENSION)) {
      $needles = array(
        $reference,
        '_' . $reference,
      );
    }
    else {
      $needles = array(
        $reference . '.scss',
        $reference . '.sass',
        '_' . $reference . '.scss',
        '_' . $reference . '.sass',
      );
    }
    foreach ($loadPaths as $loadPath) {
      foreach ($needles as $needle) {
        if (file_exists($file = $loadPath . '/' . $needle)) {
          $coll = $factory
            ->createAsset($file, array(), array(
            'root' => $loadPath,
          ));
          foreach ($coll as $leaf) {
            $leaf
              ->ensureFilter($this);
            $children[] = $leaf;
            goto next_reference;
          }
        }
      }
    }
    next_reference:
  }
  return $children;
}