-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstepbystep.profile
More file actions
68 lines (61 loc) · 1.96 KB
/
stepbystep.profile
File metadata and controls
68 lines (61 loc) · 1.96 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
<?php
/**
* @file
* Enables modules and site configuration for a Step By Step installation.
*/
use Drupal\user\Entity\User;
/**
* Implements hook_install_tasks().
*/
function stepbystep_install_tasks(array &$install_state): array {
$tasks = [];
$tasks['stepbystep_content'] = [
'display_name' => t('Install content'),
];
$tasks['stepbystep_finish_installation'] = [
'display_name' => t('Finish installation'),
];
return $tasks;
}
/**
* Finish profile installation process.
*
* @param array $install_state
* The install state.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
function stepbystep_content(array &$install_state): void {
\Drupal::service('module_installer')->install(['sbs_content']);
}
/**
* Finish profile installation process.
*
* @param array $install_state
* The install state.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
function stepbystep_finish_installation(array &$install_state): void {
// Clear all status messages generated by modules installed in previous steps.
Drupal::service('messenger')->deleteByType('status');
// Assign user 1 the "developer" role and to the demo storyline.
$user = User::load(1);
$user->roles[] = 'developer';
$storyline = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['name' => 'Women like you']);
if ($storyline) {
$user->field_storyline_choice->entity = reset($storyline);
}
$user->save();
}
/**
* Implements hook_form_FORM_ID_alter().
*
* Allows the profile to alter the site configuration form.
*/
function stepbystep_form_install_configure_form_alter(&$form, $form_state) {
$form['site_information']['site_name']['#default_value'] = 'Step By Step';
// Set not-default name for user 1.
$form['admin_account']['account']['name']['#default_value'] = 'SBS Super Admin';
$form['admin_account']['account']['name']['#description'] .= ' ' . t('For security reasons avoid generic user names such as "admin".');
}