forked from mjordan/islandora_riprap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathislandora_riprap.module
45 lines (41 loc) · 1.26 KB
/
islandora_riprap.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
<?php
/**
* Implements hook_theme().
*/
function islandora_riprap_theme($existing, $type, $theme, $path) {
return [
'islandora_riprap_summary' => [
'variables' => ['content' => null, 'outcome' => null, 'mid' => null],
],
'islandora_riprap_report' => [
'variables' => ['report' => null, 'mid' => null, 'binary_resource_url' => null],
],
];
}
/**
* Default preprocessor function for the islandora_riprap_theme hook.
*/
function template_preprocess_islandora_riprap_report(&$variables) {
$variables['attributes'] = [
'id' => ['islandora_riprap_report'],
];
}
/**
* Default preprocessor function for the islandora_riprap_theme hook.
*/
function template_preprocess_islandora_riprap_summary(&$variables) {
$variables['attributes'] = [
'class' => [$variables['outcome']],
];
}
/**
* Implements hook_page_attachments().
*/
function islandora_riprap_page_attachments(array &$attachments) {
$current_path = \Drupal::service('path.current')->getPath();
$path_args = explode('/', ltrim($current_path, '/'));
// E.g., the Manage Media View for each Islandora object.
if (count($path_args) >= 3 && $path_args[0] == 'node' && $path_args[2] == 'media') {
$attachments['#attached']['library'][] = 'islandora_riprap/islandora_riprap';
}
}