updated contrib modules : migrate_tools, migrate_plus, piwik -> matomo, color_field, config_filter, admin_toolbar
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?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;
|
||||
}
|
||||
Reference in New Issue
Block a user