forked from localgovdrupal/localgov_core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalgov_core.module
More file actions
79 lines (68 loc) · 2.18 KB
/
localgov_core.module
File metadata and controls
79 lines (68 loc) · 2.18 KB
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
<?php
/**
* @file
* LocalGovDrupal Core module file.
*/
use Drupal\Core\Installer\InstallerKernel;
/**
* Implements hook_theme().
*/
function localgov_core_theme($existing, $type, $theme, $path) {
return [
'localgov_page_header_block' => [
'variables' => [
'title' => '',
'subtitle' => NULL,
'lede' => NULL,
],
'render element' => 'block',
],
];
}
/**
* Implements hook_template_preprocess_default_variables_alter().
*/
function localgov_core_template_preprocess_default_variables_alter(&$variables) {
$remove_css = (bool) theme_get_setting('localgov_base_remove_css');
$remove_js = (bool) theme_get_setting('localgov_base_remove_js');
if ($remove_css) {
$variables['localgov_base_remove_css'] = TRUE;
}
if ($remove_js) {
$variables['localgov_base_remove_js'] = TRUE;
}
}
/**
* Implements hook_modules_installed().
*
* This installs default blocks for modules when they're enabled on an existing
* site. (IE, not in the installer.)
*/
function localgov_core_modules_installed(array $modules, bool $is_syncing): void {
if ($is_syncing) {
return;
}
// If we're in the installer, do nothing.
if (InstallerKernel::installationAttempted()) {
return;
}
/** @var \Drupal\localgov_core\Service\DefaultBlockInstaller $defaultBlockInstaller */
$defaultBlockInstaller = \Drupal::service('localgov_core.default_block_installer');
$defaultBlockInstaller->install($modules);
}
/**
* Implements hook_localgov_post_install().
*
* This installs default blocks as part of the installation of a new LocalGov
* site. All LocalGov modules (IE ones whose name starts with 'localgov_') will
* have default blocks that they define installed.
*/
function localgov_core_localgov_post_install(): void {
$moduleList = \Drupal::moduleHandler()->getModuleList();
$localgovModules = array_filter(array_keys($moduleList), function ($moduleName) {
return str_starts_with($moduleName, 'localgov_');
});
/** @var \Drupal\localgov_core\Service\DefaultBlockInstaller $defaultBlockInstaller */
$defaultBlockInstaller = \Drupal::service('localgov_core.default_block_installer');
$defaultBlockInstaller->install($localgovModules);
}