/** * Fill the properties by copying properties from original asset and adding '.min' inside them * * @return void */ protected function fillPropertiesByOriginalAssetWithMin() { $this->file = $this->composeMinifiedName($this->originalAsset->getSourceFile()); $this->path = $this->composeMinifiedName($this->originalAsset->getPath()); $this->filePath = $this->composeMinifiedName($this->originalAsset->getFilePath()); $this->context = $this->originalAsset->getContext(); $this->url = $this->composeMinifiedName($this->originalAsset->getUrl()); }
/** * Check if asset file in excluded directory * * @param string $directoryPath * @param LocalInterface $asset * @return bool */ protected function isExcludedDirectory($directoryPath, $asset) { /** @var $asset LocalInterface */ $assetDirectory = dirname($asset->getFilePath()); $assetDirectory .= substr($assetDirectory, -1) != '/' ? '/' : ''; $directoryPath .= substr($directoryPath, -1) != '/' ? '/' : ''; /** @var $asset LocalInterface */ $directoryPathInfo = $this->splitPath($directoryPath); if ($directoryPathInfo && $this->compareModules($directoryPathInfo, $asset)) { return strpos($assetDirectory, $directoryPathInfo['excludedPath']) === 0; } return false; }
/** * Find asset file by simply appending its path to the directory in context * * @param LocalInterface $asset * @param \Magento\Framework\View\Asset\File\Context $context * @return string */ private function findFile(LocalInterface $asset, \Magento\Framework\View\Asset\File\Context $context) { $dir = $this->filesystem->getDirectoryRead($context->getBaseDirType()); Simple::assertFilePathFormat($asset->getFilePath()); return $dir->getAbsolutePath($asset->getPath()); }
/** * Build asset key * * @param LocalInterface $asset * @return string */ protected function getAssetKey(LocalInterface $asset) { $result = ($asset->getModule() == '' ? '' : $asset->getModule() . '/') . $asset->getFilePath(); $result = $this->minification->addMinifiedSign($result); return $result; }
/** * @param LocalInterface $asset * @return bool */ protected function isAssetMinification(LocalInterface $asset) { $sourceFile = $asset->getSourceFile(); if (in_array($asset->getFilePath(), $this->excluded)) { return false; } if ($this->assetConfig->isAssetMinification($asset->getContentType())) { if (strpos($sourceFile, '.min.') !== false) { $this->excluded[] = str_replace('.min.', '', $sourceFile); return true; } $extension = $asset->getContentType(); $minAbsolutePath = str_replace($extension, "min.{$extension}", $sourceFile); if (file_exists($minAbsolutePath)) { return false; } return true; } if (strpos($sourceFile, '.min.') !== false) { $absolutePath = str_replace('.min.', '', $asset->getFilePath()); if (file_exists($absolutePath)) { return false; } } else { $extension = $asset->getContentType(); $this->excluded[] = str_replace($extension, "min.{$extension}", $asset->getFilePath()); } return true; }
/** * Build asset key * * @param LocalInterface $asset * @return string */ protected function getAssetKey(LocalInterface $asset) { return $asset->getModule() == '' ? $asset->getFilePath() : $asset->getModule() . '/' . $asset->getFilePath(); }