Returns child assets.
AssetFactory $factory The asset factory:
string $content The asset content:
string $loadPath An optional load path:
AssetInterface[] Child assets
Overrides DependencyExtractorInterface::getChildren
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;
}