-
Notifications
You must be signed in to change notification settings - Fork 0
/
baidu_analytics.install
38 lines (33 loc) · 1.13 KB
/
baidu_analytics.install
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
<?php
/**
* @file
* Installation file for Baidu Analytics module.
*/
/**
* Implements hook_uninstall().
*/
function baidu_analytics_uninstall() {
// Remove cache directory if module is uninstalled.
baidu_analytics_clear_js_cache();
}
/**
* Implements hook_requirements().
*/
function baidu_analytics_requirements($phase) {
$requirements = array();
$t = 't';
if ($phase == 'runtime') {
// Raise warning if Baidu Analytics user account has not been set yet or
// does not contain exactly 32 hexadecimal characters.
if (!preg_match('/^[a-f0-9]{32}$/', \Drupal::config('baidu_analytics.settings')->get('baidu_analytics_account'))) {
$url = \Drupal::url('baidu_analytics.admin_settings_form');
$requirements['baidu_analytics'] = array(
'title' => $t('Baidu Analytics module'),
'description' => $t('Baidu Analytics module has not been properly configured yet. Please configure its settings from the <a href="@url">Baidu Analytics settings page</a>.', array('@url' => $url)),
'severity' => REQUIREMENT_WARNING,
'value' => $t('Not configured'),
);
}
}
return $requirements;
}