Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @file
* Installation file for Google Analytics module.
*/
use Drupal\Core\Url;
/**
* Implements hook_uninstall().
*
* Remove cache directory if module is uninstalled.
*/
function google_analytics_uninstall() {
google_analytics_clear_js_cache();
}
/**
* Implements hook_requirements().
*/
function google_analytics_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$config = \Drupal::config('google_analytics.settings');
// Raise warning if Google user account has not been set yet.
if (!preg_match('/^UA-\d+-\d+$/', $config->get('account'))) {
$requirements['google_analytics_account'] = [
'title' => t('Google Analytics module'),
'description' => t('Google Analytics module has not been configured yet. Please configure its settings from the <a href=":url">Google Analytics settings page</a>.', [':url' => Url::fromRoute('google_analytics.admin_settings_form')->toString()]),
'severity' => REQUIREMENT_WARNING,
'value' => t('Not configured'),
];
}
// Raise warning if debugging is enabled.
if ($config->get('debug')) {
$requirements['google_analytics_debugging'] = [
'title' => t('Google Analytics module'),
'description' => t('Google Analytics module has debugging enabled. Please disable debugging setting in production sites from the <a href=":url">Google Analytics settings page</a>.', [':url' => Url::fromRoute('google_analytics.admin_settings_form')->toString()]),
'severity' => REQUIREMENT_WARNING,
'value' => t('Debugging enabled'),
];
}
}
return $requirements;
}