You are here

function piwik_clear_js_cache in Piwik Web Analytics 8

Same name and namespace in other branches
  1. 6.2 piwik.module \piwik_clear_js_cache()
  2. 6 piwik.module \piwik_clear_js_cache()
  3. 7.2 piwik.module \piwik_clear_js_cache()
  4. 7 piwik.module \piwik_clear_js_cache()

Delete cached files and directory.

2 calls to piwik_clear_js_cache()
PiwikAdminSettingsForm::validateForm in src/Form/PiwikAdminSettingsForm.php
Form validation handler.
piwik_uninstall in ./piwik.install
Implements hook_uninstall().

File

./piwik.module, line 544
Drupal Module: Piwik.

Code

function piwik_clear_js_cache() {
  $path = 'public://piwik';
  if (file_prepare_directory($path)) {
    file_scan_directory($path, '/.*/', [
      'callback' => 'file_unmanaged_delete',
    ]);
    \Drupal::service('file_system')
      ->rmdir($path);

    // Change query-strings on css/js files to enforce reload for all users.
    _drupal_flush_css_js();
    \Drupal::logger('piwik')
      ->info('Local cache has been purged.');
  }
}