| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Installation file for Matomo Analytics module.
 
-  */
 
- use Drupal\Core\Url;
 
- use Drupal\user\Entity\Role;
 
- /**
 
-  * Implements hook_install().
 
-  */
 
- function matomo_install() {
 
-   // Make the default install more user and GDPR friendly.
 
-   $role = Role::load('authenticated');
 
-   $role->grantPermission('opt-in or out of matomo tracking');
 
-   $success = $role->save();
 
-   if ($success) {
 
-     drupal_set_message(t('Module %module granted %permission permission to authenticated users.', ['%module' => 'Matomo Analytics', '%permission' => t('Opt-in or out of tracking')]), 'status');
 
-   }
 
- }
 
- /**
 
-  * Implements hook_uninstall().
 
-  *
 
-  * Remove cache directory if module is uninstalled.
 
-  */
 
- function matomo_uninstall() {
 
-   matomo_clear_js_cache();
 
- }
 
- /**
 
-  * Implements hook_requirements().
 
-  */
 
- function matomo_requirements($phase) {
 
-   $requirements = [];
 
-   if ($phase == 'runtime') {
 
-     $config = \Drupal::config('matomo.settings');
 
-     // Raise warning if Matomo user account has not been set yet.
 
-     if (!preg_match('/^\d{1,}$/', $config->get('site_id'))) {
 
-       $requirements['matomo_site_id'] = [
 
-         'title' => t('Matomo module'),
 
-         'description' => t('Matomo module has not been configured yet. Please configure its settings from the <a href=":url">Matomo settings page</a>.', [':url' => Url::fromRoute('matomo.admin_settings_form')->toString()]),
 
-         'severity' => REQUIREMENT_WARNING,
 
-         'value' => t('Not configured'),
 
-       ];
 
-     }
 
-   }
 
-   return $requirements;
 
- }
 
 
  |