strategy = $strategy; $this->filesystem = $filesystem; } /** * {@inheritdoc} */ public function merge(array $assetsToMerge, \Magento\Framework\View\Asset\LocalInterface $resultAsset) { $sourceDir = $this->filesystem->getDirectoryRead(DirectoryList::ROOT); $mTime = null; /** @var \Magento\Framework\View\Asset\MergeableInterface $asset */ foreach ($assetsToMerge as $asset) { $mTime .= $sourceDir->stat($sourceDir->getRelativePath($asset->getSourceFile()))['mtime']; } if (null === $mTime) { return; // nothing to merge } $dat = $resultAsset->getPath() . '.dat'; $targetDir = $this->filesystem->getDirectoryWrite(DirectoryList::STATIC_VIEW); if (!$targetDir->isExist($dat) || strcmp($mTime, $targetDir->readFile($dat)) !== 0) { $this->strategy->merge($assetsToMerge, $resultAsset); $targetDir->writeFile($dat, $mTime); } } }