-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathos2forms_forloeb_profile.install
More file actions
77 lines (64 loc) · 1.98 KB
/
os2forms_forloeb_profile.install
File metadata and controls
77 lines (64 loc) · 1.98 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
<?php
/**
* @file
* Install, update and uninstall functions for the os2forms_forloeb_profile.
*/
use Drupal\user\Entity\User;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function os2forms_forloeb_profile_install() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// We install some menu links, so we have to rebuild the router, to ensure the
// menu links are valid.
\Drupal::service('router.builder')->rebuildIfNeeded();
// Set Gin as default theme.
$theme_list = [
'claro',
'gin',
];
// Install themes.
\Drupal::service('theme_installer')->install($theme_list);
// Get theme manager.
$system_theme = \Drupal::configFactory()->getEditable('system.theme');
// Set default and admin themes.
$system_theme
->set('default', 'gin')
->set('admin', 'gin')
->save();
// Enable recommended (but optional) modules.
\Drupal::service('module_installer')->install(['cache_control_override']);
}
/**
* Implements hook_install_tasks().
*
* Enabled.
*/
function os2forms_forloeb_profile_install_tasks(&$install_state) {
$tasks = [
'os2forms_forloeb_profile_install_simplesaml_roles' => [
'display_name' => t('Set up SimpleSAML roles mapping'),
'type' => 'normal',
],
];
return $tasks;
}
/**
* Callback function to install default profile content.
*
* @see os2forms_forloeb_profile_install_tasks()
*/
function os2forms_forloeb_profile_install_simplesaml_roles() {
$config = \Drupal::service('config.factory')
->getEditable('simplesamlphp_auth.settings');
$roles = 'authenticated:http¤//schemas.xmlsoap.org/claims/Group,=,OS2Forms_Godkendtbruger|selvbetjeningsdesigner:http¤//schemas.xmlsoap.org/claims/Group,=,OS2Forms_Designer|administrator:http¤//schemas.xmlsoap.org/claims/Group,=,OS2Forms_Administrator';
$config->set('role.population', $roles);
$config->save();
}