/**
* Write $asset to public directory.
*
* @param AssetInterface $asset Asset to write
*/
public function writeAsset(AssetInterface $asset)
{
// We're not interested in saving assets on request
if (!$this->configuration->getBuildOnRequest()) {
return;
}
// Write asset on disk in every request
if (!$this->configuration->getWriteIfChanged()) {
$this->write($asset);
}
$target = $this->configuration->getWebPath($asset->getTargetPath());
$created = is_file($target);
$isChanged = $created && filemtime($target) < $asset->getLastModified();
// And long requested optimization
if (!$created || $isChanged) {
$this->write($asset);
}
}