Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function process(\Magento\Framework\View\Asset\PreProcessor\Chain $chain)
 {
     $asset = $chain->getAsset();
     $contentType = $chain->getContentType();
     $replaceCallback = function ($matchContent) use($asset, $contentType) {
         return $this->replace($matchContent, $asset, $contentType);
     };
     $content = $this->removeComments($chain->getContent());
     $processedContent = preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $content);
     $this->relatedFileGenerator->generate($this);
     if ($processedContent !== $content) {
         $chain->setContent($processedContent);
     }
 }
Esempio n. 2
0
 /**
  * Create a tree of self-sustainable files and return the topmost source file,
  * ready for passing to 3rd party library
  *
  * @param Chain $chain
  * @return string Absolute path of generated topmost source file
  */
 public function generateFileTree(Chain $chain)
 {
     /**
      * wait if generation process has already started
      */
     while ($this->isProcessLocked()) {
         sleep(1);
     }
     $lockFilePath = $this->config->getMaterializationRelativePath() . '/' . self::LOCK_FILE;
     $this->tmpDirectory->writeFile($lockFilePath, time());
     $this->magentoImportProcessor->process($chain);
     $this->importProcessor->process($chain);
     $this->relatedGenerator->generate($this->importProcessor);
     $contentType = $chain->getContentType();
     $relativePath = preg_replace('#\\.css$#', '.' . $contentType, $chain->getAsset()->getPath());
     $tmpFilePath = $this->temporaryFile->createFile($relativePath, $chain->getContent());
     $this->tmpDirectory->delete($lockFilePath);
     return $tmpFilePath;
 }