-
Notifications
You must be signed in to change notification settings - Fork 1
/
taoti.install
306 lines (287 loc) · 8.01 KB
/
taoti.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
<?php
/**
* @file
* Install, update and uninstall functions for the Taoti installation profile.
*/
use Drupal\field\Entity\FieldStorageConfig;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function taoti_install() {
module_set_weight('taoti', 9999);
}
/**
* Implements hook_site_install_finished().
*
* Perform post install action after the install has completed.
*/
function taoti_site_install_finished() {
// Uninstall default modules from standard that we don't actually want.
// Have to remove the default comment field first.
$field = FieldStorageConfig::loadByName('node', 'comment');
if ($field) {
$field->delete();
}
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
$module_installer->uninstall([
'big_pipe',
'comment',
'contact',
'quickedit',
'tour',
]);
// Set gin as the admin theme
$config = \Drupal::configFactory()->getEditable('system.theme');
$config->set('admin', 'gin')->save();
$module_installer->install([
'gin_toolbar',
]);
taoti_set_custom_role_overrides();
// Install Vocabulary and terms for Media Directory
\Drupal::entityTypeManager()->getStorage('taxonomy_vocabulary')->create([
'name' => 'Directories',
'vid' => 'directories',
'description' => 'This vocabulary is for media directory'
])->save();
$arr = array('Decorative','Nature','2022');
foreach ($arr as &$value) {
//add term to the vocabulary
\Drupal::entityTypeManager()->getStorage('taxonomy_term')->create([
'name' => $value,
'vid' => 'directories',
])->save();
}
}
/**
* Overrides some Standard install profile config items.
*
* @link https://taoti.teamwork.com/#/tasks/34149086
*/
function taoti_set_custom_role_overrides(): void {
$configFactory = \Drupal::configFactory();
$configFactory->getEditable('user.role.administrator')
->set('weight', -10)
->save(TRUE);
$configFactory->getEditable('user.role.anonymous')
->set('weight', -6)
->save(TRUE);
$configFactory->getEditable('user.role.content_editor')
->set('label', 'Content Creator')
->set('weight', -7)
->set('permissions', [
'access administration pages',
'access content overview',
'access contextual links',
'access files overview',
'access toolbar',
'administer url aliases',
'create article content',
'create audio media',
'create document media',
'create image media',
'create media',
'create page content',
'create remote_video media',
'create terms in tags',
'create url aliases',
'create video media',
'delete article revisions',
'delete media',
'delete own article content',
'delete own audio media',
'delete own document media',
'delete own image media',
'delete own page content',
'delete own remote_video media',
'delete own video media',
'delete page revisions',
'edit own article content',
'edit own audio media',
'edit own document media',
'edit own image media',
'edit own page content',
'edit own remote_video media',
'edit own video media',
'edit terms in tags',
'revert all revisions',
'update media',
'view all revisions',
'view media',
'view own unpublished content',
'view own unpublished media',
'view the administration theme',
])
->save(TRUE);
$configFactory->getEditable('user.role.authenticated')
->set('weight', -5)
->set('permissions', [
'access content',
'access shortcuts',
'search content',
'use text format basic_html',
])
->save(TRUE);
}
/**
* Override standard profile content type settings.
*
* Use field groups on basic pages.
*/
function taoti_override_core_content_types(): void {
/** @var \Drupal\Core\Entity\Entity\EntityFormDisplay $entity_form */
$entity_form = \Drupal::entityTypeManager()
->getStorage('entity_form_display')
->load('node.page.default');
$entity_form->setThirdPartySetting('field_group', 'group_groups', [
'children' =>
[
0 => 'group_hero',
1 => 'group_content',
2 => 'group_attributes_relationships',
],
'label' => 'Groups',
'region' => 'content',
'parent_name' => '',
'weight' => 1,
'format_type' => 'tabs',
'format_settings' =>
[
'classes' => '',
'show_empty_fields' => FALSE,
'id' => '',
'direction' => 'vertical',
'width_breakpoint' => 640,
],
])
->setThirdPartySetting('field_group', 'group_content', [
'children' =>
[
0 => 'field_layout',
],
'label' => 'Content',
'region' => 'content',
'parent_name' => 'group_groups',
'weight' => 10,
'format_type' => 'tab',
'format_settings' =>
[
'classes' => '',
'show_empty_fields' => FALSE,
'id' => '',
'formatter' => 'closed',
'description' => '',
'required_fields' => TRUE,
],
])
->setThirdPartySetting('field_group', 'group_attributes_relationships', [
'children' =>
[
],
'label' => 'Attributes/Relationships',
'region' => 'content',
'parent_name' => 'group_groups',
'weight' => 11,
'format_type' => 'tab',
'format_settings' =>
[
'classes' => '',
'show_empty_fields' => FALSE,
'id' => '',
'formatter' => 'closed',
'description' => '',
'required_fields' => TRUE,
],
])
->setThirdPartySetting('field_group', 'group_hero', [
'children' =>
[
0 => 'field_hero',
1 => 'body',
],
'label' => 'Hero / Summary',
'region' => 'content',
'parent_name' => 'group_groups',
'weight' => 9,
'format_type' => 'tab',
'format_settings' =>
[
'classes' => '',
'show_empty_fields' => FALSE,
'id' => '',
'formatter' => 'open',
'description' => '',
'required_fields' => TRUE,
],
])
->setComponent('body', [
'type' => 'text_textarea_with_summary',
'weight' => 11,
'region' => 'content',
'settings' =>
[
'rows' => 9,
'summary_rows' => 3,
'placeholder' => '',
'show_summary' => FALSE,
],
'third_party_settings' =>
[
],
])
->setComponent('field_hero', [
'type' => 'paragraphs',
'weight' => 10,
'region' => 'content',
'settings' =>
[
'title' => 'Paragraph',
'title_plural' => 'Paragraphs',
'edit_mode' => 'open',
'closed_mode' => 'summary',
'autocollapse' => 'none',
'closed_mode_threshold' => 0,
'add_mode' => 'dropdown',
'form_display_mode' => 'default',
'default_paragraph_type' => '',
'features' =>
[
'collapse_edit_all' => 'collapse_edit_all',
'duplicate' => 'duplicate',
],
],
'third_party_settings' =>
[
],
])
->setComponent('field_layout', [
'type' => 'paragraphs',
'weight' => 12,
'region' => 'content',
'settings' =>
[
'title' => 'Paragraph',
'title_plural' => 'Paragraphs',
'edit_mode' => 'open',
'closed_mode' => 'summary',
'autocollapse' => 'none',
'closed_mode_threshold' => 0,
'add_mode' => 'dropdown',
'form_display_mode' => 'default',
'default_paragraph_type' => '',
'features' =>
[
'collapse_edit_all' => 'collapse_edit_all',
'duplicate' => 'duplicate',
],
],
'third_party_settings' =>
[
],
])
->save();
}