41 private $preProcessorPool;
57 private $chainFactory;
67 private $themeProvider;
82 PreProcessor\Pool $preProcessorPool,
84 \
Magento\Framework\View\Design\Theme\ListInterface $themeList,
88 $this->readFactory = $readFactory;
91 $this->preProcessorPool = $preProcessorPool;
94 $this->chainFactory = $chainFactory;
105 $result = $this->preProcess($asset);
110 return $this->readFactory->create($dir)->getAbsolutePath(
$path);
121 $result = $this->preProcess($asset);
126 return $this->readFactory->create($dir)->readFile(
$path);
143 $sourceFile = $this->findSourceFile($asset);
144 $dir = $this->rootDir->getAbsolutePath();
147 $path = basename($sourceFile);
148 $dir = dirname($sourceFile);
151 $chain = $this->createChain($asset, $dir,
$path);
152 $this->preProcessorPool->process($chain);
153 $chain->assertValid();
154 if ($chain->isChanged()) {
155 $dir = $this->tmpDir->getAbsolutePath();
156 $path = $chain->getTargetAssetPath();
157 $this->tmpDir->writeFile(
$path, $chain->getContent());
173 list(,,
$type) = $this->preProcess($asset);
183 return $this->findSourceFile($asset);
194 return strtolower(pathinfo(
$path, PATHINFO_EXTENSION));
208 $result = $this->findFileThroughFallback($asset, $context);
210 $result = $this->findFile($asset, $context);
212 $type = get_class($context);
213 throw new \LogicException(
"Support for {$type} is not implemented.");
225 private function findFileThroughFallback(
226 LocalInterface $asset,
227 \
Magento\Framework\View\Asset\File\FallbackContext $context
229 $themeModel = $this->getThemeProvider()->getThemeByFullPath(
230 $context->getAreaCode() .
'/' . $context->getThemePath()
232 $sourceFile = $this->fallback->getFile(
233 $context->getAreaCode(),
235 $context->getLocale(),
236 $asset->getFilePath(),
245 private function getThemeProvider()
247 if (
null === $this->themeProvider) {
251 return $this->themeProvider;
261 private function findFile(LocalInterface $asset, \
Magento\Framework\View\Asset\File\
Context $context)
263 $dir = $this->filesystem->getDirectoryRead($context->getBaseDirType());
264 Simple::assertFilePathFormat($asset->getFilePath());
265 return $dir->getAbsolutePath($asset->getPath());
277 $sourceFile = $this->findSourceFile($asset);
281 return $this->rootDir->getRelativePath($sourceFile);
295 $origContent = $this->readFactory->create($dir)->readFile(
$path);
302 $chain = $this->chainFactory->create(
305 'origContent' => $origContent,
306 'origContentType' => $origContentType,
307 'origAssetPath' => $dir .
'/' .
$path
getContent(LocalInterface $asset)
__construct(\Magento\Framework\Filesystem $filesystem, ReadFactory $readFactory, PreProcessor\Pool $preProcessorPool, \Magento\Framework\View\Design\FileResolution\Fallback\StaticFile $fallback, \Magento\Framework\View\Design\Theme\ListInterface $themeList, ChainFactoryInterface $chainFactory)
elseif(isset( $params[ 'redirect_parent']))
const TMP_MATERIALIZATION_DIR
getFile(LocalInterface $asset)
getSourceContentType(LocalInterface $asset)
findRelativeSourceFilePath(LocalInterface $asset)
findSource(LocalInterface $asset)