forked from az-digital/az_quickstart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaz_quickstart.install
228 lines (204 loc) · 6.95 KB
/
az_quickstart.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
<?php
/**
* @file
* Install, update and uninstall functions for az_quickstart install profile.
*/
use Drupal\Core\Extension\MissingDependencyException;
use Drupal\user\Entity\User;
use Drupal\shortcut\Entity\Shortcut;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function az_quickstart_install() {
// Assign user 1 the "administrator" role.
$user = User::load(1);
$user->roles[] = 'administrator';
$user->save();
// Populate the default shortcut set.
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
]);
$shortcut->save();
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('All content'),
'weight' => -19,
'link' => ['uri' => 'internal:/admin/content'],
]);
$shortcut->save();
// Install Pantheon module dependencies when running on Pantheon.
if (defined('PANTHEON_ENVIRONMENT')) {
$pantheon_modules = [
'pantheon_advanced_page_cache',
'environment_indicator',
];
foreach ($pantheon_modules as $module) {
try {
\Drupal::service('module_installer')->install([$module]);
}
catch (MissingDependencyException $e) {
\Drupal::logger('az_quickstart')->warning('@module module not available to install.', ['@module' => $module]);
}
}
}
}
/**
* Install az_metrics.
*/
function az_quickstart_update_9201() {
\Drupal::service('module_installer')->install(['az_metrics']);
}
/**
* Set account creation rules, default to admin_only.
*/
function az_quickstart_update_9202() {
$config = \Drupal::service('config.factory')->getEditable('user.settings');
$config->set('register', 'admin_only')
->save(TRUE);
}
/**
* Enable the role_delegation module.
*/
function az_quickstart_update_9203() {
$module_list = ['role_delegation'];
\Drupal::service('module_installer')->install($module_list);
}
/**
* Place system branding block in new region.
*
* Save default barrio settings for new branding theme region,
* and place the new branding block in it.
*/
function az_quickstart_update_9204() {
$config = \Drupal::service('config.factory')->getEditable('az_barrio.settings');
$config
->set('bootstrap_barrio_region_clean_branding', FALSE)
->set('bootstrap_barrio_region_class_branding', '')
->save(TRUE);
$config = \Drupal::service('config.factory')->getEditable('block.block.az_barrio_branding');
$config
->set('status', TRUE)
->set('region', 'branding')
->set('weight', -9)
->set('settings.use_site_name', FALSE)
->set('settings.use_site_slogan', FALSE)
->save(TRUE);
}
/**
* Disable land acknowledgement theme setting by default on existing sites.
*/
function az_quickstart_update_9205() {
$config = \Drupal::service('config.factory')->getEditable('az_barrio.settings');
$config
->set('land_acknowledgment', FALSE)
->save(TRUE);
}
/**
* Update footer logo link destination if it's currently set to "<front>".
*/
function az_quickstart_update_9206() {
$config = \Drupal::service('config.factory')->getEditable('az_barrio.settings');
if ($config->get('footer_logo_link_destination') === '<front>') {
$config
->set('footer_logo_link_destination', '')
->save(TRUE);
}
}
/**
* Enable the az_security module.
*/
function az_quickstart_update_9207() {
$module_list = ['az_security'];
\Drupal::service('module_installer')->install($module_list);
}
/**
* Ensure Pantheon sites have the advanced page cache module installed.
*/
function az_quickstart_update_9208() {
if (defined('PANTHEON_ENVIRONMENT')) {
try {
\Drupal::service('module_installer')->install(['pantheon_advanced_page_cache']);
}
catch (MissingDependencyException $e) {
return t('Pantheon Advanced Page Cache module not available to install.');
}
return t('Pantheon Advanced Page Cache module installed.');
}
}
/**
* Set the default columns classes on the new theme setting (Removed).
*/
function az_quickstart_update_9209() {
// Update removed and moved to az_quickstart_update_920101().
// @see https://github.com/az-digital/az_quickstart/issues/1350
}
/**
* Set the default columns classes on the new theme setting.
*/
function az_quickstart_update_920101() {
$config = \Drupal::service('config.factory')->getEditable('az_barrio.settings');
if ($config->get('header_one_col_classes') === NULL && $config->get('header_two_col_classes') === NULL) {
$config
->set('header_one_col_classes', 'col-12 col-sm-6 col-lg-4')
->set('header_two_col_classes', 'col-12 col-sm-6 col-lg-8')
->save(TRUE);
}
}
/**
* Delete unmodified legacy footer menu blocks to prevent global footer issues.
*/
function az_quickstart_update_920102() {
if (\Drupal::service('module_handler')->moduleExists('az_global_footer')) {
return t('Quickstart Global Footer module already installed. No footer menu blocks need to be deleted.');
}
else {
$delete_blocks = TRUE;
// Default config hashes generated from clean install of Quickstart 2.0.18.
$footer_menu_blocks = [
'block.block.az_barrio_footer_menu_info' => 'UPd_XW4rSu7i2VUmkzxPOWBlNM-ckDDv3p_3YFzTOxw',
'block.block.az_barrio_footer_menu_main' => 'fYhWRgj2xwKqlRJMJgsVftrGWu3Py7p6SQoHslS6eks',
'block.block.az_barrio_footer_menu_resources' => 'NwIzEthgG1SVgWc7GJKsW_44TaWW4HbyY4sZqLqxEKE',
'block.block.az_barrio_footer_menu_social_media' => 'Vk6yulKY8Q3ErOnox11fzDTu4-uBxB1oKTQmcxG94RQ',
'block.block.az_barrio_footer_menu_topics' => '5GU2oFYWqdhXrFxFcxxArQXQd3YBskaIdVS1uJZ7kDg',
];
// Check whether any of the footer menu blocks have been modified.
foreach ($footer_menu_blocks as $block => $default_config_hash) {
$current_config_hash = \Drupal::service('config.factory')
->get($block)
->get('_core.default_config_hash');
if ($current_config_hash !== $default_config_hash) {
$delete_blocks = FALSE;
}
}
if ($delete_blocks) {
foreach ($footer_menu_blocks as $block => $default_config_hash) {
\Drupal::service('config.factory')->getEditable($block)->delete();
}
return t('Deleted legacy global footer menu blocks. Install Quickstart Global Footer module to re-enable footer menu blocks.');
}
else {
return t('Legacy global footer blocks not deleted because config differences detected. Blocks will need to be manually deleted with drush in order to install Quickstart Global Footer module.');
}
}
}
/**
* Ensure Pantheon sites have the environment_indicator module installed.
*/
function az_quickstart_update_920103() {
if (defined('PANTHEON_ENVIRONMENT')) {
try {
\Drupal::service('module_installer')->install(['environment_indicator']);
}
catch (MissingDependencyException $e) {
return t('Environment Indicator module not available to install.');
}
return t('Environment Indicator module installed.');
}
}