1 | <?php |
||
14 | class Module extends ExternalModule |
||
15 | { |
||
16 | /** LESS mixin declaration pattern */ |
||
17 | const P_IMPORT_DECLARATION = '/@import\s+(\'|\")(?<path>[^\'\"]+)(\'|\");/'; |
||
18 | |||
19 | /** @var \lessc LESS compiler */ |
||
20 | protected $less; |
||
21 | |||
22 | /** @var array Collection of LESS variables */ |
||
23 | protected $variables = []; |
||
24 | |||
25 | /** @var array Collection of LESS mixins */ |
||
26 | protected $mixins = []; |
||
27 | |||
28 | /** @var string Cached LESS code */ |
||
29 | protected $lessCode; |
||
30 | |||
31 | /** SamsonFramework load preparation stage handler */ |
||
32 | 3 | public function prepare() |
|
40 | |||
41 | /** |
||
42 | * Recursively replace @import in content of the LESS file |
||
43 | * |
||
44 | * @param string $resource Resource full path |
||
45 | * @param string $content less file content |
||
46 | * |
||
47 | * @return string Content of LESS file with included @imported resources |
||
48 | * @throws ResourceNotFound If importing resource could not be found |
||
49 | */ |
||
50 | 2 | protected function readImport($resource, $content) |
|
71 | |||
72 | /** |
||
73 | * LESS resource compiler. |
||
74 | * |
||
75 | * @param string $resource Resource full path |
||
76 | * @param string $extension Resource extension |
||
77 | * @param string $content Compiled output resource content |
||
78 | * |
||
79 | * @throws \Exception |
||
80 | */ |
||
81 | 2 | public function compiler($resource, &$extension, &$content) |
|
100 | } |
||
101 |