/** * @inheritdoc * @throws ContentProcessorException */ public function processContent(File $asset) { $path = $asset->getPath(); try { $parser = new \Less_Parser(['relativeUrls' => false, 'compress' => $this->appState->getMode() !== State::MODE_DEVELOPER]); $content = $this->assetSource->getContent($asset); if (trim($content) === '') { return ''; } $tmpFilePath = $this->temporaryFile->createFile($path, $content); gc_disable(); $parser->parseFile($tmpFilePath, ''); $content = $parser->getCss(); gc_enable(); if (trim($content) === '') { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path; $this->logger->critical($errorMessage); throw new ContentProcessorException(new Phrase($errorMessage)); } return $content; } catch (\Exception $e) { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage(); $this->logger->critical($errorMessage); throw new ContentProcessorException(new Phrase($errorMessage)); } }
public function processContent(File $asset) { $path = $asset->getPath(); try { $scssIn = $this->assetSource->getContent($asset); $compiler = new \Leafo\ScssPhp\Compiler(); $cssOut = $compiler->compile($scssIn); return $cssOut; } catch (\Exception $e) { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage(); $this->logger->critical($errorMessage); } }
/** * Process file content * * @param File $asset * @return string */ public function processContent(File $asset) { $path = $asset->getPath(); try { $compiler = new \scssc(); $content = $this->assetSource->getContent($asset); if (trim($content) === '') { return ''; } return $compiler->compile($content); } catch (\Exception $e) { $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage(); $this->logger->critical($errorMessage); return $errorMessage; } }
/** * @param string $contextPath * @param string $module * @param string $filePath * @param string $expected * @dataProvider getPathDataProvider */ public function testGetPath($contextPath, $module, $filePath, $expected) { $this->context->expects($this->once())->method('getPath')->will($this->returnValue($contextPath)); $object = new File($this->source, $this->context, $filePath, $module, '', $this->minificationMock); $this->assertEquals($expected, $object->getPath()); }