Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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());
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * @param LocalInterface $asset
  * @return int
  */
 protected function getMaxPartSize(LocalInterface $asset)
 {
     return $this->bundleConfig->getPartSize($asset->getContext());
 }
Ejemplo n.º 6
0
 /**
  * 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));
 }
Ejemplo n.º 7
0
 /**
  * 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();
 }
Ejemplo n.º 8
0
 /**
  * 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();
 }
Ejemplo n.º 9
0
 /**
  * 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)]);
 }