1 | <?php |
||
13 | class ScssAssetConverter extends Component implements AssetConverterInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var Storage |
||
17 | */ |
||
18 | public $storage; |
||
19 | |||
20 | /** |
||
21 | * @var boolean whether the source asset file should be converted even if |
||
22 | * its result already exists. You may want to set this to be `true` during |
||
23 | * the development stage to make sure the converted assets are always up-to- |
||
24 | * date. Do not set this to true on production servers as it will |
||
25 | * significantly degrade the performance. |
||
26 | */ |
||
27 | public $forceConvert = false; |
||
28 | |||
29 | private $compiler; |
||
30 | |||
31 | 10 | public function init() |
|
39 | |||
40 | /** |
||
41 | * Converts a given SCSS asset file into a CSS file. |
||
42 | * @param string $asset the asset file path, relative to $basePath |
||
43 | * @param string $basePath the directory the $asset is relative to. |
||
44 | * @return string the converted asset file path, relative to $basePath. |
||
45 | */ |
||
46 | 9 | public function convert($asset, $basePath) |
|
66 | |||
67 | 9 | private function getExtension(string $filename): string |
|
71 | |||
72 | 7 | private function replaceExtension(string $filename, string $newExtension): string |
|
77 | |||
78 | 6 | private function convertAndSaveIfNeeded(string $inFile, string $outFile) |
|
85 | |||
86 | 6 | private function shouldConvert(string $inFile, string $outFile): bool |
|
101 | |||
102 | 3 | private function isOlder(string $fileA, string $fileB): bool |
|
106 | } |
||
107 |