1: | <?php
2: | namespace Opencart\Admin\Controller\Startup;
3: | /**
4: | * Class Sass
5: | *
6: | * @package Opencart\Admin\Controller\Startup
7: | */
8: | class Sass extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * @throws \Exception&\ScssPhp\ScssPhp\Exception\SassException
13: | *
14: | * @return void
15: | */
16: | public function index(): void {
17: | $files = glob(DIR_APPLICATION . 'view/stylesheet/*.scss');
18: |
19: | if ($files) {
20: | foreach ($files as $file) {
21: | // Get the filename
22: | $filename = basename($file, '.scss');
23: |
24: | $stylesheet = DIR_APPLICATION . 'view/stylesheet/' . $filename . '.css';
25: |
26: | if (!is_file($stylesheet) || !$this->config->get('developer_sass')) {
27: | $scss = new \ScssPhp\ScssPhp\Compiler();
28: | $scss->setImportPaths(DIR_APPLICATION . 'view/stylesheet/');
29: |
30: | $output = $scss->compileString('@import "' . $filename . '.scss"')->getCss();
31: |
32: | $handle = fopen($stylesheet, 'w');
33: |
34: | flock($handle, LOCK_EX);
35: |
36: | fwrite($handle, $output);
37: |
38: | fflush($handle);
39: |
40: | flock($handle, LOCK_UN);
41: |
42: | fclose($handle);
43: | }
44: | }
45: | }
46: | }
47: | }
48: |

OpenCart API API documentation generated by ApiGen dev-master