-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstanford_earth_r25.module
77 lines (71 loc) · 2.35 KB
/
stanford_earth_r25.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
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
<?php
/**
* @file
* Implements Drupal hooks for stanford_earth_r25 module.
*/
/**
* Hook to format emailed error messages to site admin.
*
* @param string $key
* The type of email being sent.
* @param array $message
* The message array that can be modified by this hook.
* @param array $params
* The parameter array whose contents can be used to format the message.
*/
function stanford_earth_r25_mail($key, array &$message, array $params) {
$options = array(
'langcode' => $message['langcode'],
);
$body = '';
if (!empty($params['message']) && is_array($params['message'])) {
foreach ($params['message'] as $msgline) {
$body .= $msgline . '<br />';
}
}
switch ($key) {
case 'r25_operation':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('@operation', array('@operation' => $params['r25_operation']), $options);
$message['body'][] = $body;
break;
case 'r25_error':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('R25 API error: @title', ['@title' => $params['r25']]);
$message['body'][] = $body;
break;
}
}
/**
* Hook to establish twig template for module.
*
* @param array $existing
* Array of existing implementations.
* @param string $type
* How the theme is being implemented.
* @param string $theme
* The name of the theme being implemented.
* @param string $path
* The directory path of the module.
* @return array
* Theme template information.
*/
function stanford_earth_r25_theme($existing, $type, $theme, $path) {
return [
// Name of the theme hook. This is used in the controller to trigger the hook.
'stanford_earth_r25-theme-hook' => [
'render element' => 'children',
// If no template name is defined here, it defaults to the name of the theme hook, ie. module-name-theme-hook.html.twig
'template' => 'stanford_earth_r25-theme-hook',
// Optionally define path to Twig template files. Defaults to the module's ./templates/ directory.
'path' => $path . '/templates',
// Optionally define variables that will be passed to the Twig template and set default values for them.
'variables' => [
'r25_location' => NULL,
'photo_url' => '',
'form' => NULL,
'canBook' => FALSE,
],
],
];
}