You are here

function scss_compiler_cache_flush in SCSS/Less Compiler 8

Implements hook_cache_flush().

File

./scss_compiler.module, line 131
Module compiles scss files into css via scssphp compiler.

Code

function scss_compiler_cache_flush() {
  if (Drupal::hasService('scss_compiler')) {
    $config = \Drupal::config('scss_compiler.settings');
    $flush_cache_type = $config
      ->get('flush_cache_type');
    switch ($flush_cache_type) {
      case 'default':
        if ($config
          ->get('cache')) {
          return;
        }
      case 'system':
        $cache_folder = ScssCompilerService::CACHE_FOLDER;
        if (Drupal::service('file_system')
          ->prepareDirectory($cache_folder)) {
          Drupal::service('file_system')
            ->deleteRecursive($cache_folder);
        }
        break;
    }
  }
}