-
Notifications
You must be signed in to change notification settings - Fork 16
/
sitefarm_seed.install
197 lines (169 loc) · 4.8 KB
/
sitefarm_seed.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<?php
/**
* @file
* Install, update and uninstall functions for the SiteFarm installation profile.
*/
use Drupal\user\Entity\User;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\Entity\ShortcutSet;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function sitefarm_seed_install() {
// Set the default theme.
_sitefarm_seed_setup_theme();
// Set the default shortcuts
_sitefarm_seed_setup_shortcuts();
// Set up default users
_sitefarm_seed_setup_users();
// Set up Menu items
_sitefarm_seed_setup_menus();
}
/**
* Set the default theme and other theme related settings.
*/
function _sitefarm_seed_setup_theme() {
// Set front page to "node".
\Drupal::configFactory()
->getEditable('system.site')
->set('page.front', '/node')
->save(TRUE);
// Set the path to the logo, favicon and README file based on install
// directory
$sitefarm_seed_path = drupal_get_path('profile', 'sitefarm_seed');
\Drupal::configFactory()
->getEditable('system.theme.global')
->set('logo', [
'path' => $sitefarm_seed_path . '/sitefarm_logo.svg',
'url' => '',
'use_default' => FALSE,
])
->set('favicon', [
'mimetype' => 'image/vnd.microsoft.icon',
'path' => $sitefarm_seed_path . '/favicon.ico',
'url' => '',
'use_default' => FALSE,
])
->save(TRUE);
}
/**
* Set the default shortcuts.
*/
function _sitefarm_seed_setup_shortcuts() {
// 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();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Main Menu'),
'weight' => -18,
'link' => ['uri' => 'internal:/admin/structure/menu/manage/main'],
])->save();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Taxonomy (Categories)'),
'weight' => -17,
'link' => ['uri' => 'internal:/admin/structure/taxonomy'],
])->save();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('People'),
'weight' => -16,
'link' => ['uri' => 'internal:/admin/people'],
])->save();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Blocks'),
'weight' => -17,
'link' => ['uri' => 'internal:/admin/structure/block'],
])->save();
Shortcut::create([
'shortcut_set' => 'default',
'title' => t('SiteFarm Config'),
'weight' => -15,
'link' => ['uri' => 'internal:/admin/config/sitefarm'],
])->save();
// Developer Shortcut Set
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('All content'),
'weight' => -19,
'link' => ['uri' => 'internal:/admin/content'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Content Types'),
'weight' => -18,
'link' => ['uri' => 'internal:/admin/structure/types'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Blocks'),
'weight' => -17,
'link' => ['uri' => 'internal:/admin/structure/block'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Views'),
'weight' => -16,
'link' => ['uri' => 'internal:/admin/structure/views'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Features'),
'weight' => -15,
'link' => ['uri' => 'internal:/admin/config/development/features'],
])->save();
Shortcut::create([
'shortcut_set' => 'development',
'title' => t('Single Config Export'),
'weight' => -14,
'link' => ['uri' => 'internal:/admin/config/development/configuration/single/export'],
])->save();
// Assign the Developer shortcuts to User 1
$account = User::load(1);
$shortcut_set = ShortcutSet::load('development');
\Drupal::entityTypeManager()
->getStorage('shortcut_set')
->assignUser($shortcut_set, $account);
}
/**
* Setup default roles and permissions
*/
function _sitefarm_seed_setup_users() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
}
/**
* Setup Menu links
*/
function _sitefarm_seed_setup_menus() {
// We install some menu links, so we have to rebuild the router, to ensure the
// menu links are valid.
\Drupal::service('router.builder')->rebuildIfNeeded();
}
/**
* Update hooks for regular updates are below
*/