You are here

function matomo_uninstall in Matomo Analytics 8

Same name and namespace in other branches
  1. 7.2 matomo.install \matomo_uninstall()

Implements hook_uninstall().

Remove cache directory if module is uninstalled.

File

./matomo.install, line 30
Installation file for Matomo Analytics module.

Code

function matomo_uninstall() {
  $path = 'public://matomo';
  if (\Drupal::service('file_system')
    ->prepareDirectory($path)) {
    \Drupal::service('file_system')
      ->scanDirectory($path, '/.*/', [
      'callback' => '_matomo_uninstall_file_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('matomo')
      ->info('Local cache has been purged.');
  }
}