-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathaz_quickstart.install
More file actions
216 lines (194 loc) · 5.9 KB
/
az_quickstart.install
File metadata and controls
216 lines (194 loc) · 5.9 KB
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
<?php
/**
* @file
* Install, update and uninstall functions for az_quickstart install profile.
*/
use Drupal\Core\Extension\MissingDependencyException;
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() {
// 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 additional modules if site is running on Pantheon (or not).
if (defined('PANTHEON_ENVIRONMENT')) {
// Modules to install only on Pantheon.
$extra_modules = [
'pantheon_advanced_page_cache',
'environment_indicator',
'environment_indicator_toolbar',
];
}
else {
// Modules to install if not on Pantheon.
$extra_modules = [
'big_pipe',
];
}
foreach ($extra_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]);
}
}
}
/**
* Implements hook_update_last_removed().
*/
function az_quickstart_update_last_removed() {
// Remove updates added before 2.6.0.
return 920103;
}
/**
* Uninstall the deprecated media_library_theme_reset module.
*/
function az_quickstart_update_920601() {
\Drupal::service('module_installer')->uninstall(['media_library_theme_reset']);
}
/**
* Change Arizona Bootstrap CDN references (removed).
*/
function az_quickstart_update_920602() {
// This update has been removed.
}
/**
* Uninstall deprecated Drupal core modules.
*/
function az_quickstart_update_920603() {
$deprecated_modules = [
'aggregator',
'color',
'hal',
'quickedit',
'rdf',
];
\Drupal::service('module_installer')->uninstall($deprecated_modules);
}
/**
* Ensure block_class module is installed.
*/
function az_quickstart_update_920604() {
\Drupal::service('module_installer')->install(['block_class']);
}
/**
* Ensure media_entity_file_replace module is installed.
*/
function az_quickstart_update_920701() {
\Drupal::service('module_installer')->install(['media_entity_file_replace']);
}
/**
* Enable az_paragraphs_splitscreen module by default.
*/
function az_quickstart_update_920702() {
\Drupal::service('module_installer')->install(['az_paragraphs_splitscreen']);
}
/**
* Ensure ckeditor5 module is installed.
*/
function az_quickstart_update_1020801() {
\Drupal::service('module_installer')->install(['ckeditor5']);
}
/**
* Enable extlink module by default.
*/
function az_quickstart_update_1020802() {
\Drupal::service('module_installer')->install(['extlink']);
}
/**
* Uninstall unsupported media_library_theme_reset module.
*/
function az_quickstart_update_1020803() {
\Drupal::service('module_installer')->uninstall(['media_library_theme_reset']);
}
/**
* Update langcode for migrated menu links to be the site's default language.
*/
function az_quickstart_update_1020901(&$sandbox) {
if (!isset($sandbox['progress'])) {
$sandbox['progress'] = 0;
$sandbox['max'] = \Drupal::entityQuery('menu_link_content')
->accessCheck(FALSE)
->condition('langcode', 'und')
->count()
->execute();
}
$batch_size = 25;
$default_langcode = \Drupal::languageManager()->getDefaultLanguage()->getId();
$ids = \Drupal::entityQuery('menu_link_content')
->accessCheck(FALSE)
->condition('langcode', 'und')
->range(0, $batch_size)
->execute();
$menu_links = \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadMultiple($ids);
foreach ($menu_links as $menu_link) {
$menu_link->langcode = $default_langcode;
$menu_link->save();
$sandbox['progress']++;
}
$sandbox['#finished'] = empty($sandbox['max']) ? 1 : $sandbox['progress'] / $sandbox['max'];
return t('Updated langcode on %count menu links.', ['%count' => $sandbox['progress']]);
}
/**
* Enable masquerade and masquerade_log modules by default.
*/
function az_quickstart_update_1021301() {
\Drupal::service('module_installer')->install(['masquerade', 'masquerade_log']);
}
/**
* Enable quick_node_clone module by default.
*/
function az_quickstart_update_1021302() {
\Drupal::service('module_installer')->install(['quick_node_clone']);
}
/**
* Enable az_icons module by default (removed).
*/
function az_quickstart_update_1130001() {
// This update was meant for 3.1.x only and was replaced by
// az_quickstart_install_1130101().
}
/**
* Enable environment_indicator_toolbar module if applicable.
*
* This update ensures that environment_indicator_toolbar is enabled on sites
* that have both environment_indicator and toolbar modules enabled, regardless
* of configuration state. This addresses an issue where the module may not
* have been enabled during updates due to config changes happening before the
* environment_indicator module's own update hook could run.
*/
function az_quickstart_update_1130002() {
$module_handler = \Drupal::service('module_handler');
// Check if both environment_indicator and toolbar are enabled.
if ($module_handler->moduleExists('environment_indicator') && $module_handler->moduleExists('toolbar')) {
// Enable environment_indicator_toolbar if not already enabled.
if (!$module_handler->moduleExists('environment_indicator_toolbar')) {
\Drupal::service('module_installer')->install(['environment_indicator_toolbar']);
}
}
}
/**
* Enable az_icons module by default.
*/
function az_quickstart_update_1130101() {
\Drupal::service('module_installer')->install(['az_icons']);
}