piwik.install 994 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * @file
  4. * Installation file for Piwik - Web analytics module.
  5. */
  6. use Drupal\Core\Url;
  7. /**
  8. * Implements hook_uninstall().
  9. *
  10. * Remove cache directory if module is uninstalled.
  11. */
  12. function piwik_uninstall() {
  13. piwik_clear_js_cache();
  14. }
  15. /**
  16. * Implements hook_requirements().
  17. */
  18. function piwik_requirements($phase) {
  19. $requirements = [];
  20. if ($phase == 'runtime') {
  21. $config = \Drupal::config('piwik.settings');
  22. // Raise warning if Piwik user account has not been set yet.
  23. if (!preg_match('/^\d{1,}$/', $config->get('site_id'))) {
  24. $requirements['piwik_site_id'] = [
  25. 'title' => t('Piwik module'),
  26. 'description' => t('Piwik module has not been configured yet. Please configure its settings from the <a href=":url">Piwik settings page</a>.', [':url' => Url::fromRoute('piwik.admin_settings_form')->toString()]),
  27. 'severity' => REQUIREMENT_WARNING,
  28. 'value' => t('Not configured'),
  29. ];
  30. }
  31. }
  32. return $requirements;
  33. }