/**
  * {@inheritdoc}
  */
 public function process(Chain $chain)
 {
     $asset = $chain->getAsset();
     $callback = function ($path) use($asset) {
         return $this->notationResolver->convertModuleNotationToPath($asset, $path);
     };
     $chain->setContent($this->cssResolver->replaceRelativeUrls($chain->getContent(), $callback));
 }
Example #2
0
 /**
  * @covers \Magento\Framework\Css\PreProcessor\Instruction\Import::resetRelatedFiles
  */
 public function testGetRelatedFiles()
 {
     $this->assertSame([], $this->object->getRelatedFiles());
     $this->notationResolver->expects($this->once())->method('convertModuleNotationToPath')->with($this->asset, 'Magento_Module::something.css')->will($this->returnValue('Magento_Module/something.css'));
     $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, '@import (type) "Magento_Module::something.css" media;', 'css', 'path');
     $this->object->process($chain);
     $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, 'color: #000000;', 'css', 'path');
     $this->object->process($chain);
     $expected = [['Magento_Module::something.css', $this->asset]];
     $this->assertSame($expected, $this->object->getRelatedFiles());
     $this->object->resetRelatedFiles();
     $this->assertSame([], $this->object->getRelatedFiles());
 }
Example #3
0
 /**
  * Return replacement of an original @import directive
  *
  * @param array $matchedContent
  * @param LocalInterface $asset
  * @param string $contentType
  * @return string
  */
 protected function replace(array $matchedContent, LocalInterface $asset, $contentType)
 {
     $matchedFileId = $this->fixFileExtension($matchedContent['path'], $contentType);
     $this->recordRelatedFile($matchedFileId, $asset);
     $resolvedPath = $this->notationResolver->convertModuleNotationToPath($asset, $matchedFileId);
     $typeString = empty($matchedContent['type']) ? '' : '(' . $matchedContent['type'] . ') ';
     $mediaString = empty($matchedContent['media']) ? '' : ' ' . trim($matchedContent['media']);
     return "@import {$typeString}'{$resolvedPath}'{$mediaString};";
 }