-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvivial_profiler.module
41 lines (37 loc) · 1.17 KB
/
convivial_profiler.module
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
<?php
/**
* @file
* Convivial Profiler module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function convivial_profiler_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.convivial_profiler':
$output = '';
$output .= '<h3>' . t('Convivial Profiler') . '</h3>';
$output .= '<p>' . t('Provides ability for personalization and visitor data collection') . '</p>';
return $output;
}
}
/**
* Implements hook_page_attachments().
*/
function convivial_profiler_page_attachments(array &$attachments) {
$config = \Drupal::config('convivial_profiler.settings');
if (empty($site = $config->get('site_id')) || empty($license_key = $config->get('license_key'))) {
return;
}
$attachments['#attached']['library'][] = 'convivial_profiler/init';
$attachments['#attached']['drupalSettings']['convivialProfiler'] = [
'site' => $site,
'license_key' => $license_key,
'client_cleanup' => $config->get('client_cleanup'),
'event_tracking' => $config->get('event_tracking'),
'config' => [
'profilers' => $config->get('profilers') ?? (object) [],
],
];
}