public function testProcess() { $expectedContent = 'updated content'; $tmpFile = 'tmp/file.ext'; $this->fileGenerator->expects($this->once())->method('generateFileTree')->with($this->chain)->will($this->returnValue($tmpFile)); $this->adapter->expects($this->once())->method('process')->with($tmpFile)->will($this->returnValue($expectedContent)); $this->object->process($this->chain); $this->assertEquals($expectedContent, $this->chain->getContent()); $this->assertEquals('css', $this->chain->getContentType()); }
public function testGettersAndSetters() { $this->assertEquals('origType', $this->object->getOrigContentType()); $this->assertEquals('origType', $this->object->getContentType()); $this->assertEquals('origContent', $this->object->getOrigContent()); $this->assertEquals('origContent', $this->object->getContent()); $this->assertEquals('assetType', $this->object->getTargetContentType()); $this->object->setContent('anotherContent'); $this->object->setContentType('anotherType'); $this->assertEquals('origType', $this->object->getOrigContentType()); $this->assertEquals('anotherType', $this->object->getContentType()); $this->assertEquals('origContent', $this->object->getOrigContent()); $this->assertEquals('anotherContent', $this->object->getContent()); $this->assertEquals('assetType', $this->object->getTargetContentType()); }
/** * {@inheritdoc} */ public function process(Chain $chain) { $callback = function ($path) { return $this->notationResolver->convertVariableNotation($path); }; $chain->setContent($this->cssResolver->replaceRelativeUrls($chain->getContent(), $callback)); }
/** * Transform content and/or content type for the specified preprocessing chain object * * @param PreProcessor\Chain $chain * @return void */ public function process(PreProcessor\Chain $chain) { if ($this->minification->isEnabled(pathinfo($chain->getTargetAssetPath(), PATHINFO_EXTENSION)) && $this->minification->isMinifiedFilename($chain->getTargetAssetPath()) && !$this->minification->isMinifiedFilename($chain->getOrigAssetPath())) { $content = $this->adapter->minify($chain->getContent()); $chain->setContent($content); } }
/** * {@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)); }
/** * {@inheritdoc} */ public function process(\Magento\Framework\View\Asset\PreProcessor\Chain $chain) { $asset = $chain->getAsset(); $replaceCallback = function ($matchContent) use($asset) { return $this->replace($matchContent, $asset); }; $chain->setContent(preg_replace_callback(self::REPLACE_PATTERN, $replaceCallback, $chain->getContent())); }
/** * {@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); if ($processedContent !== $content) { $chain->setContent($processedContent); } }
/** * Transform content and/or content type for the specified preprocessing chain object * * @param Chain $chain * @return void */ public function process(Chain $chain) { if ($this->config->isEmbeddedStrategy()) { $context = $chain->getAsset()->getContext(); $areaCode = \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE; if ($context instanceof FallbackContext) { $areaCode = $context->getAreaCode(); $this->translate->setLocale($context->getLocale()); } $area = $this->areaList->getArea($areaCode); $area->load(\Magento\Framework\App\Area::PART_TRANSLATE); $chain->setContent($this->translate($chain->getContent())); } }
/** * @inheritdoc * @throws \UnexpectedValueException */ public function process(Chain $chain) { $path = $chain->getAsset()->getFilePath(); $content = $chain->getContent(); if (trim($content) !== '') { return; } try { $this->lockerProcess->lockProcess($this->lockName); $module = $chain->getAsset()->getModule(); /** @var FallbackContext $context */ $context = $chain->getAsset()->getContext(); $chain->setContent($this->processContent($path, $content, $module, $context)); } finally { $this->lockerProcess->unlockProcess(); } }
/** * Transform content and/or content type for the specified preprocessing chain object * * @param Chain $chain * @return void */ public function process(Chain $chain) { if ($this->config->isEmbeddedStrategy()) { $chain->setContent($this->translate($chain->getContent())); } }