-
Notifications
You must be signed in to change notification settings - Fork 2
/
localgov_microsites.install
62 lines (53 loc) · 1.56 KB
/
localgov_microsites.install
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
<?php
/**
* @file
* Install functions for the LocalGov Microsites installation profile.
*/
use Drupal\user\Entity\Role;
use Drupal\user\Entity\User;
/**
* Implements hook_install().
*/
function localgov_microsites_install() {
// Allow microsites controllers and editors to use redirect module.
$role_names = [
'microsites_controller',
'microsites_trusted_editor',
];
// Set 'administer redirects' permission for controllers and editors.
foreach ($role_names as $role_name) {
$role = Role::load($role_name);
$role->grantPermission('administer redirects');
$role->save();
}
$admin = User::load(1);
$admin->addRole('microsites_controller');
}
/**
* Enable stable9 theme if localgov_base theme is enabled.
*/
function localgov_update_9501() {
if (\Drupal::service('theme_handler')->themeExists('localgov_base')) {
\Drupal::service('theme_installer')->install(['stable9']);
}
}
/**
* Enable redirect module and set 'administer redirects' permission.
*/
function localgov_microsites_update_10001() {
// Enable redirect module if it is not already enabled.
$moduleHandler = \Drupal::service('module_handler');
if (!$moduleHandler->moduleExists('redirect')) {
\Drupal::service('module_installer')->install(['redirect']);
}
// Set 'administer redirects' permission for controllers and editors.
$role_names = [
'microsites_controller',
'microsites_trusted_editor',
];
foreach ($role_names as $role_name) {
$role = Role::load($role_name);
$role->grantPermission('administer redirects');
$role->save();
}
}