-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbricky.install
85 lines (75 loc) · 2.12 KB
/
bricky.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<?php
/**
* @file
* Distribution installation file.
*/
use Drupal\user\Entity\User;
use Drupal\user\RoleInterface;
use Drupal\shortcut\Entity\Shortcut;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function bricky_install() {
// Set front page to "node".
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/node')
->save(TRUE);
// Allow visitor account creation with administrative approval.
\Drupal::configFactory()
->getEditable('user.settings')
->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)
->save(TRUE);
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// Enable default permissions for system roles.
user_role_grant_permissions(
RoleInterface::ANONYMOUS_ID,
[
'access comments',
'access site-wide contact form',
'search content',
]
);
user_role_grant_permissions(
RoleInterface::AUTHENTICATED_ID,
[
'access comments',
'post comments',
'skip comment approval',
'access site-wide contact form',
'access shortcuts',
'search content',
]
);
// We install some menu links, so we have to rebuild the router, to ensure the
// menu links are valid.
\Drupal::service('router.builder')->rebuildIfNeeded();
// Enable the Contact link in the footer menu.
\Drupal::service('plugin.manager.menu.link')
->updateDefinition('contact.site_page', ['enabled' => TRUE]);
// Populate the default shortcut set.
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
])->save();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => ['uri' => 'internal:/admin/content'],
])->save();
// Enable the admin theme.
\Drupal::configFactory()
->getEditable('node.settings')
->set('use_admin_theme', TRUE)
->save(TRUE);
}