You are here

public function ScssCompilerService::flushCache in SCSS/Less Compiler 8

Flushes all compiler caches and reset css aggregation.

Overrides ScssCompilerInterface::flushCache

File

src/ScssCompilerService.php, line 524

Class

ScssCompilerService
Defines a class for scss compiler service.

Namespace

Drupal\scss_compiler

Code

public function flushCache() {
  $this
    ->messenger()
    ->addStatus($this
    ->t('Compiler cache cleared.'));
  $cache_folder = $this
    ->getCacheFolder();
  if ($this->fileSystem
    ->prepareDirectory($cache_folder)) {
    $this->fileSystem
      ->deleteRecursive($cache_folder);
  }
  $this
    ->compileAll(TRUE, TRUE);

  // Reset data cache to rebuild aggregated css files.
  \Drupal::service('cache.data')
    ->deleteAll();
  \Drupal::service('asset.css.collection_optimizer')
    ->deleteAll();
}