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