Exemple #1
0
 /**
  * @param \Magento\Framework\View\Asset\LocalInterface $asset
  * @param string $origContent
  * @param string $origContentType
  */
 public function __construct(\Magento\Framework\View\Asset\LocalInterface $asset, $origContent, $origContentType)
 {
     $this->asset = $asset;
     $this->origContent = $origContent;
     $this->content = $origContent;
     $this->origContentType = $origContentType;
     $this->contentType = $origContentType;
     $this->targetContentType = $asset->getContentType();
 }
Exemple #2
0
 /**
  * @param LocalInterface $asset
  * @param string $origContent
  * @param string $origContentType
  */
 public function __construct(LocalInterface $asset, $origContent, $origContentType)
 {
     $this->asset = $asset;
     $this->origContent = $origContent;
     $this->content = $origContent;
     $this->origContentType = $origContentType;
     $this->contentType = $origContentType;
     $this->targetContentType = $asset->getContentType();
     $this->targetAssetPath = $asset->getPath();
 }
Exemple #3
0
 /**
  * Process the resulting asset after merging content is done
  *
  * @param Asset\LocalInterface $result
  * @param string $content
  * @return string
  */
 private function preProcessMergeResult(Asset\LocalInterface $result, $content)
 {
     if ($result->getContentType() == 'css') {
         $content = $this->cssUrlResolver->aggregateImportDirectives($content);
     }
     return $content;
 }
 /**
  * {@inheritdoc}
  */
 public function getContentType()
 {
     return $this->originalAsset->getContentType();
 }
Exemple #5
0
 /**
  * Creates a chain for pre-processing
  *
  * @param LocalInterface $asset
  * @param string|bool $dir
  * @param string|bool $path
  * @return PreProcessor\Chain
  */
 private function createChain(LocalInterface $asset, $dir, $path)
 {
     if ($path) {
         $origContent = $this->readFactory->create($dir)->readFile($path);
         $origContentType = $this->getContentType($path);
     } else {
         $origContent = '';
         $origContentType = $asset->getContentType();
     }
     $chain = $this->chainFactory->create(['asset' => $asset, 'origContent' => $origContent, 'origContentType' => $origContentType, 'origAssetPath' => $dir . '/' . $path]);
     return $chain;
 }
Exemple #6
0
 /**
  * @param LocalInterface $asset
  * @return bool
  */
 protected function isValidType(LocalInterface $asset)
 {
     $type = $asset->getContentType();
     if (!in_array($type, self::$availableTypes)) {
         return false;
     }
     if ($type == self::ASSET_TYPE_HTML) {
         return $asset->getModule() !== '';
     }
     return true;
 }
Exemple #7
0
    /**
     * @param LocalInterface $asset
     * @return bool
     */
    protected function isValidType(LocalInterface $asset)
    {
        $type = $asset->getContentType();
        if (!in_array($type, self::$availableTypes)) {
            return false;
        }

        return true;
    }