-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrcv_slider.module
76 lines (58 loc) · 1.76 KB
/
rcv_slider.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
<?php
/**
* @file
* Contains rcv_slider.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Implements hook_help().
*/
function rcv_slider_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the rcv_slider module.
case 'help.page.rcv_slider':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('React component for ranked choice voting') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function rcv_slider_theme($existing, $type, $theme, $path) {
return [
'rcv_slider_page' => [
'variables' => [
'text' => NULL,
'valuestable' => NULL,
'winningthreshold' => NULL,
'explanation' => NULL,
],
],
];
}
// Needed to allow JSON API access to update custom entity type.
/**
* Implements hook_jsonapi_entity_filter_access() for 'score'.
*/
function rcv_slider_jsonapi_entity_filter_access(\Drupal\Core\Entity\EntityTypeInterface $entity_type, \Drupal\Core\Session\AccountInterface $account) {
return ([
JSONAPI_FILTER_AMONG_ALL => AccessResult::allowed()
]);
}
// Needed to allow JSON API access to update custom entity type.
/**
* Implements hook_jsonapi_ENTITY_TYPE_filter_access() for 'score'.
*/
function rcv_slider_jsonapi_score_filter_access(\Drupal\Core\Entity\EntityTypeInterface $entity_type, \Drupal\Core\Session\AccountInterface $account) {
return ([
JSONAPI_FILTER_AMONG_ALL => AccessResult::allowed(),
JSONAPI_FILTER_AMONG_PUBLISHED => AccessResult::allowed(),
JSONAPI_FILTER_AMONG_OWN => AccessResult::allowed()
]);
}