-
Notifications
You must be signed in to change notification settings - Fork 14
/
cloudflare.install
50 lines (42 loc) · 1.47 KB
/
cloudflare.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
<?php
/**
* @file
* Install, update, and uninstall functions for the CloudFlare module.
*/
use Drupal\Core\Url;
/**
* Implements hook_requirements().
*/
function cloudflare_requirements($phase) {
$requirements = [];
if (!class_exists('\CloudFlarePhpSdk\ApiEndpoints\ZoneApi')) {
$requirements['cloudflare_library'] = [
'title' => t('CloudFlare - Php Sdk'),
'description' => t('CloudFlare requires the d8-contrib-modules/cloudflarephpsdk library.'),
'severity' => REQUIREMENT_ERROR,
];
}
if ($phase == 'runtime') {
$config = \Drupal::config('cloudflare.settings');
$valid_credentials = $config->get('valid_credentials') === TRUE;
if (!$valid_credentials) {
$link_to_settings = Url::fromRoute('cloudflare.admin_settings_form')->toString();
$message = t('Missing valid credentials for CloudFlare. Please go <a href="@link_to_settings">here</a> to set.', ['@link_to_settings' => $link_to_settings]);
$requirements['cloudflare'] = [
'title' => t('CloudFlare - Credentials'),
'severity' => REQUIREMENT_ERROR,
'description' => $message,
];
}
if (\Drupal::moduleHandler()->moduleExists('cloudflare_zone_ui')) {
\Drupal::service('module_installer')->uninstall([('cloudflare_zone_ui')]);
}
}
return $requirements;
}
/**
* Installs ctools module. Uninstalls cloudflare_zone_ui.
*/
function cloudflare_update_8001(&$sandbox) {
\Drupal::service('module_installer')->install(['ctools']);
}