This repository has been archived by the owner on Sep 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tippy.install
executable file
·134 lines (106 loc) · 3.27 KB
/
tippy.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
/**
* @file
* Requirements page for Tippy.js.
*/
use Drupal\Core\Link;
/**
* Implements hook_requirements().
*/
function tippy_requirements($phase) {
$requirements = [];
// Report the version of Tippy.js.
if ($phase == 'runtime') {
$requirements['tippy'] = [
'title' => t('Tippy.js v5'),
];
// Load the configuration settings.
$configuration_settings = \Drupal::config('tippy.settings');
// Check if Tippy.js is installed.
if (tippy_check_installed()) {
// Get the version.
if ($configuration_settings->get('use_cdn')) {
$version = 'CDN';
} else {
$version = 'Local';
}
$requirements['tippy']['severity'] = REQUIREMENT_OK;
$requirements['tippy']['value'] = t('Tippy.js library is installed. Using %version version. (@moreInfoLink)', [
'%version' => $version,
'@moreInfoLink' => Link::createFromRoute(t('more information'), 'tippy.admin_settings')->toString(),
]);
}
else {
$requirements['tippy']['severity'] = REQUIREMENT_ERROR;
$requirements['tippy']['value'] = t('Not installed');
$requirements['tippy']['description'] = t('The Tippy.js library could not be found. Please verify Tippy.js is installed correctly or that the CDN has been activated and properly configured. Please see the @adminPage and the Tippy.js module README file for more details.', [
'@adminPage' => Link::createFromRoute(t('admin page'), 'tippy.admin_settings')->toString(),
]);
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function tippy_uninstall() {
// Delete set variables.
$query = \Drupal::database()->delete('config');
$query->condition('name', 'tippy.settings');
$query->execute();
$query = \Drupal::database()->delete('key_value');
$query->condition('name', 'tippy');
$query->execute();
}
/**
* Implements hook_update().
*/
function tippy_update_8101() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('tippy.settings');
if($config->get('use_cdn')){
$config->set('external_location', 'https://unpkg.com/tippy.js@4');
}
$config->save(TRUE);
$message = "Tippy: Updated to v4 CDN";
return $message;
}
/**
* Implements hook_update().
*/
function tippy_update_8102() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('tippy.settings');
if($config->get('use_cdn')){
$config->set('external_location', 'https://unpkg.com/tippy.js@5');
}
$config->save(TRUE);
$message = "Tippy: Updated to v5 CDN";
return $message;
}
/**
* Implements hook_update().
*/
function tippy_update_8103() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('tippy.settings');
if(!$config->get('auto_init')){
$config->set('auto_init', 'false');
}
$config->save(TRUE);
$message = "Tippy: Added new config item 'autoinit'";
return $message;
}
/**
* Implements hook_update().
*/
function tippy_update_8104() {
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable('tippy.settings');
if($config->get('use_cdn')){
$config->set('external_location', 'https://unpkg.com/tippy.js@6');
}
$config->save(TRUE);
$message = "Tippy: Updated to v6 CDN";
return $message;
}