-
Notifications
You must be signed in to change notification settings - Fork 0
/
bibcite.module
60 lines (53 loc) · 1.26 KB
/
bibcite.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
<?php
/**
* @file
* Main module hooks.
*/
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Url;
/**
* Implements hook_theme().
*/
function bibcite_theme($existing, $type, $theme, $path) {
return [
'bibcite_citation' => [
'variables' => [
'data' => [],
'style' => NULL,
],
],
];
}
/**
* Implements hook_preprocess_HOOK().
*/
function bibcite_preprocess_bibcite_citation(&$variables) {
/** @var \Drupal\bibcite\CitationStylerInterface $styler */
$styler = \Drupal::service('bibcite.citation_styler');
$data = $variables['data'];
if ($variables['style']) {
$styler->setStyleById($variables['style']);
}
else {
$styler->setStyle(NULL);
}
$variables['content'] = [
'#markup' => $styler->render($data),
];
}
/**
* Implements hook_help().
*/
function bibcite_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.bibcite':
$links = [
':proc' => Url::fromRoute('bibcite.settings')->toString(),
':csl' => Url::fromRoute('entity.bibcite_csl_style.collection')
->toString(),
];
$module = 'bibcite';
return \Drupal::service('bibcite.help_service')
->getHelpMarkup($links, $route_name, $module);
}
}