Repository navigation
Expand file tree
/
Copy pathpendulum_arc.module
More file actions
100 lines (89 loc) · 2.64 KB
/
Copy pathpendulum_arc.module
File metadata and controls
100 lines (89 loc) · 2.64 KB
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
<?php
/**
* @file
* Connects this Drupal site to a Pendulum Arc account.
*/
declare(strict_types=1);
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_theme().
*/
function pendulum_arc_theme($existing, $type, $theme, $path): array {
return [
'pendulum_arc_page' => [
'variables' => [
'title' => '',
'mark' => '',
'bootstrap' => '{}',
'message' => '',
],
],
'pendulum_arc_widget' => [
'variables' => [
'dashboard_url' => '',
'connect_url' => '',
'portal_url' => '',
'connected' => '0',
],
],
];
}
/**
* Implements hook_page_attachments().
*/
function pendulum_arc_page_attachments(array &$attachments): void {
if (\Drupal::currentUser()->hasPermission('administer pendulum arc')) {
$attachments['#attached']['library'][] = 'pendulum_arc/menu';
}
}
/**
* Implements hook_page_top().
*/
function pendulum_arc_page_top(array &$page_top): void {
\Drupal::service('pendulum_arc.consent_front')->pageTop($page_top);
}
/**
* Implements hook_page_bottom().
*/
function pendulum_arc_page_bottom(array &$page_bottom): void {
\Drupal::service('pendulum_arc.consent_front')->pageBottom($page_bottom);
}
/**
* Implements hook_preprocess_page().
*/
function pendulum_arc_preprocess_page(array &$variables): void {
\Drupal::service('pendulum_arc.consent_front')->placeInRegion($variables);
}
/**
* Implements hook_js_alter().
*/
function pendulum_arc_js_alter(array &$javascript, AttachedAssetsInterface $assets, LanguageInterface $language): void {
\Drupal::service('pendulum_arc.consent_front')->alterJavascript($javascript, $assets);
}
/**
* Implements hook_requirements().
*/
function pendulum_arc_requirements(string $phase): array {
if (function_exists('sodium_crypto_secretbox')) {
return [];
}
return [
'pendulum_arc_sodium' => [
'title' => t('Arc Analytics'),
'value' => t('PHP sodium extension is missing'),
'description' => t('Arc Analytics needs the PHP sodium extension before it can store a connection.'),
'severity' => REQUIREMENT_ERROR,
],
];
}
/**
* Implements hook_help().
*/
function pendulum_arc_help(string $route_name, RouteMatchInterface $route_match): string {
if ($route_name !== 'help.page.pendulum_arc') {
return '';
}
return '<p>' . t('Arc Analytics connects this site to an Arc studio so the dashboard can show the latest site scores and a preview of each report. GDPR Consent is a local cookie banner. It does not call Arc and works before the site is paired.') . '</p>';
}