-
Notifications
You must be signed in to change notification settings - Fork 10
/
bcelndora.module
98 lines (86 loc) · 3.09 KB
/
bcelndora.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* @file
* bcelndora.module
*/
use Drupal\scss_compiler\ScssCompilerAlterStorage;
use Symfony\Component\Routing\Generator\UrlGenerator;
/**
* Implements hook_theme_suggestions_alter().
*/
function bcelndora_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
// Add a views template suggestion for the taxonomy term 'person' vocab.
if (in_array($hook, ['views_view'])) {
$parameters = \Drupal::routeMatch()->getParameters()->all();
if (isset($parameters['taxonomy_term'])) {
$term = $parameters['taxonomy_term'];
$vid = $term->bundle();
$vocabulary = \Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->load($vid);
if ($vocabulary->getOriginalId() === "person") {
$suggestions[] = $hook . '__' . 'taxonomy_term__person';
}
}
}
}
/**
* Implements hook_theme().
*/
function bcelndora_theme($existing, $type, $theme, $path) {
return [
'views_view__taxonomy_term__person' => [
'template' => 'views-view--taxonomy-term--person',
'base hook' => 'views_view',
],
];
}
/**
* Implements hook_scss_compiler_import_paths_alter().
*/
function bcelndora_scss_compiler_import_paths_alter(array &$additional_import_paths) {
$theme_list = \Drupal::service('extension.list.theme');
$file_system = \Drupal::service('file_system');
$additional_import_paths[] = $file_system->realpath($theme_list->getPath('dgi_i8_base')) . "/scss/";
}
/**
* Implements hook_scss_compiler_variables_alter().
*/
function bcelndora_scss_compiler_variables_alter(ScssCompilerAlterStorage $storage) {
if (function_exists('dgi_i8_base_scss_compiler_variables_alter')) {
dgi_i8_base_scss_compiler_variables_alter($storage);
}
$theme_list = \Drupal::service('extension.list.theme');
$theme_path = $theme_list->getPath('dgi_i8_base');
$module_list = \Drupal::service('extension.list.module');
$module_path = $module_list->getPath('bcelndora');
/** @var \Drupal\scss_compiler\ScssCompilerInterface $scss_compiler */
$scss_compiler = \Drupal::service('scss_compiler');
$upstream = $storage->getByFile($scss_compiler->replaceTokens('@dgi_i8_base/scss/style.scss'));
$to_set = array_merge(
$upstream,
[
'theme-path' => UrlGenerator::getRelativePath("/{$module_path}/", "/{$theme_path}"),
],
);
$storage->setByFile($to_set, '@bcelndora/scss/styles.scss');
}
/**
* Implements hook_page_attachments().
*
* Attach AUC specific base theme overrides via the module library.
*/
function bcelndora_page_attachments(array &$page) {
if (\Drupal::theme()->getActiveTheme()->getName() === "dgi_i8_base") {
$page['#attached']['library'][] = 'bcelndora/theme_overrides';
}
}
/**
* Implements hook_library_info_alter().
*
* Unset the theme's 'framework' library CSS, as this module provides its own
* via this module's 'hook_page_attachments' implementation.
*/
function bcelndora_library_info_alter(&$libraries, $extension) {
if ($extension == 'dgi_i8_base' && isset($libraries['framework']['css']['theme']['scss/style.scss'])) {
unset($libraries['framework']['css']['theme']['scss/style.scss']);
}
}