/**
  * {@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));
 }
Beispiel #2
0
 /**
  * @covers \Magento\Framework\Less\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');
     $this->object->process($chain);
     $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, 'color: #000000;', 'css');
     $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());
 }
Beispiel #3
0
 /**
  * Return replacement of an original @import directive
  *
  * @param array $matchedContent
  * @param LocalInterface $asset
  * @return string
  */
 protected function replace(array $matchedContent, LocalInterface $asset)
 {
     $matchedFileId = $this->fixFileExtension($matchedContent['path']);
     $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};";
 }