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 Matomo settings page.', [':url' => Url::fromRoute('matomo.admin_settings_form')->toString()]), 'severity' => REQUIREMENT_WARNING, 'value' => t('Not configured'), ]; } } return $requirements; }