/** * Check if asset in exclude list * * @param LocalInterface $asset * @return bool */ protected function isExcluded(LocalInterface $asset) { $excludedFiles = array_merge($this->bundleConfig->getConfig($asset->getContext())->getExcludedFiles(), $this->excluded); if (in_array($asset->getFilePath(), $excludedFiles)) { return true; } // check if file in excluded directory $assetDirectory = dirname($asset->getFilePath()); foreach ($this->bundleConfig->getConfig($asset->getContext())->getExcludedDir() as $dir) { if (strpos($assetDirectory, $dir) !== false) { return true; } } return false; }
/** * 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 in exclude list * * @param LocalInterface $asset * @return bool */ protected function isExcluded(LocalInterface $asset) { $excludedFiles = array_merge($this->bundleConfig->getConfig($asset->getContext())->getExcludedFiles(), $this->excluded); foreach ($excludedFiles as $file) { if ($this->isExcludedFile($file, $asset)) { return true; } } foreach ($this->bundleConfig->getConfig($asset->getContext())->getExcludedDir() as $directory) { if ($this->isExcludedDirectory($directory, $asset)) { return true; } } return false; }
/** * Search for asset file depending on its context type * * @param LocalInterface $asset * @return bool|string * @throws \LogicException */ private function findSourceFile(LocalInterface $asset) { $context = $asset->getContext(); if ($context instanceof \Magento\Framework\View\Asset\File\FallbackContext) { $result = $this->findFileThroughFallback($asset, $context); } elseif ($context instanceof \Magento\Framework\View\Asset\File\Context) { $result = $this->findFile($asset, $context); } else { $type = get_class($context); throw new \LogicException("Support for {$type} is not implemented."); } return $result; }
/** * @param LocalInterface $asset * @return int */ protected function getMaxPartSize(LocalInterface $asset) { return $this->bundleConfig->getPartSize($asset->getContext()); }
/** * Create a file asset similar to an existing local asset by using its context * * @param string $fileId * @param LocalInterface $similarTo * @return File */ public function createSimilar($fileId, LocalInterface $similarTo) { list($module, $filePath) = self::extractModule($fileId); if (!$module) { $module = $similarTo->getModule(); } return new File($this->assetSource, $similarTo->getContext(), $filePath, $module, $this->assetSource->getContentType($filePath)); }
/** * Get theme model based on the information from asset * * @param LocalInterface $asset * @return \Magento\Framework\View\Design\ThemeInterface */ protected function getTheme(LocalInterface $asset) { $context = $asset->getContext(); if ($context instanceof FallbackContext) { return $this->themeList->getThemeByFullPath($context->getAreaCode() . '/' . $context->getThemePath()); } return $this->design->getDesignTheme(); }
/** * Get theme model based on the information from asset * * @param LocalInterface $asset * @return \Magento\Framework\View\Design\ThemeInterface */ protected function getTheme(LocalInterface $asset) { $context = $asset->getContext(); if ($context instanceof FallbackContext) { return $this->themeProvider->getThemeModel($context->getThemePath(), $context->getAreaCode()); } return $this->design->getDesignTheme(); }
/** * Create a file asset similar to an existing local asset by using its context * * @param string $fileId * @param LocalInterface $similarTo * @return File */ public function createSimilar($fileId, LocalInterface $similarTo) { list($module, $filePath) = self::extractModule($fileId); if (!$module) { $module = $similarTo->getModule(); } return $this->fileFactory->create(['source' => $this->assetSource, 'context' => $similarTo->getContext(), 'filePath' => $filePath, 'module' => $module, 'contentType' => $this->assetSource->getContentType($filePath)]); }