You are here

protected function AdminCssEditor::flushAssetCache in Admin CSS 8.2

Flush the asset cache.

See also

drupal_flush_all_caches()

1 call to AdminCssEditor::flushAssetCache()
AdminCssEditor::submitForm in src/Form/AdminCssEditor.php
Form submission handler.

File

src/Form/AdminCssEditor.php, line 171

Class

AdminCssEditor
Admin CSS editor form.

Namespace

Drupal\admincss\Form

Code

protected function flushAssetCache() {
  if ($this
    ->config('system.performance')
    ->get('css.preprocess')) {

    /*
     * CSS aggregation is enabled.
     * Clear the asset resolver cache typically used for storing the
     * aggregated files.
     * @see \Drupal\Core\Asset\AssetResolver::getCssAssets
     * @see \Drupal\Core\Asset\AssetResolver::getJsAssets
     *
     * The invalidation call might be potentially expensive to run.
     * Drupal should add an AssetResolver asset specific tag.
     *
     * An alternative is to disable preprocessing on the admincss asset.
     * But you lose the various optimizations Drupal provides.
     */
    $this->cacheTagsInvalidator
      ->invalidateTags([
      'library_info',
    ]);

    // Delete the optimized CSS and JS asset file caches.
    $this->cssCollectionOptimizer
      ->deleteAll();
    $this->jsCollectionOptimizer
      ->deleteAll();
  }
  else {

    // Regenerate the dummy query string.
    _drupal_flush_css_js();
  }
}