-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmukurtu.install
152 lines (139 loc) · 4.72 KB
/
mukurtu.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
<?php
/**
* @file
* Install, update and uninstall functions for the mukurtu install profile.
*/
use Drupal\block\Entity\Block;
use Drupal\block_content\Entity\BlockContent;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function mukurtu_install() {
// First, do everything in standard profile.
include_once DRUPAL_ROOT . '/core/profiles/standard/standard.install';
standard_install();
// Uninstall search.
\Drupal::service('module_installer')->uninstall(['search']);
// Message digest UI doesn't seem to get correctly resolved as a
// dependency, so we'll install it here.
\Drupal::service('module_installer')->install(['message_digest_ui']);
// Rebuild node access permissions.
node_access_rebuild();
// Install default themes.
\Drupal::service('theme_installer')->install(['mukurtu_v4', 'claro']);
\Drupal::configFactory()
->getEditable('system.theme')
->set('default', 'mukurtu_v4')
->set('admin', 'claro')
->save();
// Add default blocks.
// Hero Image for the front page.
$block_content = BlockContent::create([
'type' => 'image_with_description',
'info' => t('Mukurtu v4 Hero Image and Site Description'),
'region' => 'content',
'weight' => 2,
'theme' => 'mukurtu_v4',
]);
$block_content->save();
$block = Block::create([
'id' => 'mukurtu_v4_hero_image_and_site_description',
'settings' => [
'id' => 'block_content:' . $block_content->uuid(),
'label' => t('Mukurtu v4 Hero Image and Site Description'),
'label_display' => 0,
'provider' => 'block_content',
'status' => 1,
],
'region' => 'content',
'plugin' => 'block_content:' . $block_content->uuid(),
'theme' => 'mukurtu_v4',
]);
$block->save();
$block = Block::load('mukurtu_v4_hero_image_and_site_description');
$block->setRegion('content');
$visibility = $block->getVisibility();
$visibility['request_path']['pages'] = '<front>';
$block->setVisibilityConfig('request_path', $visibility['request_path']);
$block->setRegion('content');
$block->setStatus(TRUE);
$block->setWeight(-4);
$block->save();
// Featured Content for the front page.
$block_content = BlockContent::create([
'type' => 'featured_content',
'info' => t('Mukurtu v4 Front Page Featured Content'),
'region' => 'content',
'weight' => 3,
'theme' => 'mukurtu_v4',
]);
$block_content->save();
$block = Block::create([
'id' => 'mukurtu_v4_front_page_featured_content',
'settings' => [
'id' => 'block_content:' . $block_content->uuid(),
'label' => t('Mukurtu v4 Featured Content'),
'label_display' => 1,
'provider' => 'block_content',
'status' => 1,
],
'region' => 'content',
'plugin' => 'block_content:' . $block_content->uuid(),
'theme' => 'mukurtu_v4',
]);
$block->save();
$block = Block::load('mukurtu_v4_front_page_featured_content');
$block->setRegion('content');
$visibility = $block->getVisibility();
$visibility['request_path']['pages'] = '<front>';
$block->setVisibilityConfig('request_path', $visibility['request_path']);
$block->setRegion('content');
$block->setStatus(TRUE);
$block->setWeight(-3);
$block->save();
// Delete unused user flags that crash user registration page.
$flagStorage = \Drupal::entityTypeManager()->getStorage('flag');
foreach (['email_user', 'subscribe_user'] as $userFlagID) {
$flag = $flagStorage->load($userFlagID);
if ($flag) {
$flag->delete();
}
}
// function mukurtu_create_default_blocks() {
// $block_content = BlockContent::create([
// 'type' => 'image_with_description',
// 'info' => t('Hero Image and Site Description'),
// 'region' => 'content',
// 'weight' => 2,
// 'theme' => 'mukurtu_v4',
// ]);
// $block_content->save();
// $block = Block::create([
// 'id' => 'heroimageandsitedescription',
// 'settings' => [
// 'id' => 'block_content:' . $block_content->uuid(),
// 'label' => t('Hero Image and Site Description'),
// 'label_display' => 0,
// 'provider' => 'block_content',
// 'status' => 1,
// ],
// 'region' => 'content',
// 'plugin' => 'block_content:' . $block_content->uuid(),
// 'theme' => 'mukurtu_v4',
// 'weight' => 4,
// ]);
// $block->setRegion('content');
// $visibility = $block->getVisibility();
// $visibility['request_path']['pages'] = '<front>';
// $block->setVisibilityConfig('request_path', $visibility['request_path']);
// $block = Block::load('heroimageandsitedescription');
// $block->setRegion('content');
// $block->setStatus(TRUE);
// $block->setWeight(4);
// $block->save();
// }
}