private readonly string
$missingImportMode = self::MISSING_IMPORT_WARN,
private readonly ?LoggerInterface
$logger = null,
) { } public function compile(string
$content, MappedAsset
$asset, AssetMapperInterface
$assetMapper): string
{ return preg_replace_callback(self::ASSET_URL_PATTERN,
function D
$matches) use ($asset,
$assetMapper) { try { $resolvedPath =
$this->
resolvePath(\
dirname($asset->logicalPath
),
$matches[1
]);
} catch (RuntimeException
$e) { $this->
handleMissingImport(sprintf('Error processing import in "%s": ',
$asset->sourcePath
).
$e->
getMessage(),
$e);
return $matches[0
];
} $dependentAsset =
$assetMapper->
getAsset($resolvedPath);
if (null ===
$dependentAsset) { $this->
handleMissingImport(sprintf('Unable to find asset "%s" referenced in "%s".',
$matches[1
],
$asset->sourcePath
));
// return original, unchanged path
return $matches[0
];
}