This repository has been archived by the owner on Dec 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
cr.install
431 lines (374 loc) · 9.6 KB
/
cr.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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<?php
/**
* @file
* Install, update and uninstall functions for the Comic Relief installation profile.
*/
use Drupal\Core\Database\Database;
function deleteConfig($file) {
\Drupal::configFactory()->getEditable($file)->delete();
}
function installer() {
return \Drupal::service('module_installer');
}
/**
* Implements hook_install().
*/
function cr_install() {
// Disable the user pictures on nodes.
\Drupal::configFactory()
->getEditable('system.theme.global')
->set('features.node_user_picture', false)
->save(true);
}
/**
* Install config_readonly
*/
function cr_update_8001() {
installer()->install(['config_readonly']);
}
/**
* Install cr_cards and cr_single_msg
*/
function cr_update_8002() {
installer()->install(['cr_cards', 'cr_single_msg']);
}
/**
* Install cr_downloadables
*/
function cr_update_8003() {
installer()->install(['cr_downloadables']);
}
/**
* Install cr_navigation
*/
function cr_update_8004() {
installer()->install(['cr_navigation']);
}
/**
* Remove field_youtube_url and uninstall youtube module
*/
function cr_update_8005() {
$field = Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_youtube_url');
$field->delete();
field_purge_batch('field_youtube_url');
installer()->uninstall(['youtube']);
}
/**
* Install cr_user
*/
function cr_update_8006() {
installer()->install(['cr_user']);
}
/**
* Delete old config
*/
function cr_update_8007() {
deleteConfig('system.menu.main-navigation');
}
/**
* Kill crop & delete old fields.
*/
function cr_update_8008() {
$query = "DELETE FROM key_value WHERE collection='system.schema' AND name='crop'";
Database::getConnection()->query($query);
deleteConfig('field.storage.block_content.field_teaser_link');
deleteConfig('field.field.block_content.teaser.field_teaser_link');
}
/**
* Install cdn
*/
function cr_update_8009() {
installer()->install(['cdn']);
}
/**
* Remove field_article_tags
*/
function cr_update_8010() {
$field = Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_article_tags');
$field->delete();
field_purge_batch('field_article_tags');
}
/**
* Remove field_partner_image
*/
function cr_update_8011() {
$field = Drupal\field\Entity\FieldStorageConfig::loadByName('node', 'field_partner_image');
$field->delete();
field_purge_batch('field_partner_image');
}
/**
* Remove Search view + search configs
*/
function cr_update_8012() {
$entityTypeManager = \Drupal::service('entity_type.manager');
$view = $entityTypeManager->getStorage('view')->load('search');
$view->delete();
deleteConfig('views.view.search');
deleteConfig('search_api.server.database');
$query = 'ALTER TABLE {search_api_task}
CHANGE COLUMN server_id server_id VARCHAR(50) NULL';
Database::getConnection()->query($query);
}
/**
* Install cr_social
*/
function cr_update_8013() {
installer()->install(['cr_social']);
}
/**
* Install cr_story
*/
function cr_update_8015() {
installer()->install(['cr_story']);
}
/**
* Install cr_iframe
*/
function cr_update_8016() {
installer()->install(['cr_iframe']);
}
/**
* Install cr_video cr_media
*/
function cr_update_8017() {
installer()->install(['cr_video']);
installer()->install(['cr_media']);
}
/**
* Install cr_content_reference
*/
function cr_update_8018() {
installer()->install(['cr_content_reference']);
}
/**
* Install cr_quote
*/
function cr_update_8019() {
installer()->install(['cr_quote']);
}
/**
* Remove title field from teaser block
*/
function cr_update_8020() {
deleteConfig('field.storage.block_content.field_teaser_title');
deleteConfig('field.field.block_content.teaser.field_teaser_title');
field_purge_batch('field_teaser_title');
}
/**
* Install twig_tweak
*/
function cr_update_8021() {
installer()->install(['twig_tweak', 'field_group']);
}
/**
* Remove cr_single_message_row
*/
function cr_update_8022() {
// Remove any orphaned paragraphs
$result = \Drupal::entityQuery('paragraph')
->condition('type', 'cr_single_message_row')
->execute();
entity_delete_multiple('paragraph', $result);
// Disable the containing module
installer()->uninstall(['cr_single_message_row_paragraph']);
}
/**
* Delete old schedule config
*/
function cr_update_8023() {
deleteConfig('scheduled_updates.scheduled_update_type.node__status');
}
/**
* Delete old varnish config
*/
function cr_update_8024() {
deleteConfig('purge_purger_http.settings.0e73130559');
deleteConfig('purge_purger_http.settings.52aab9005f');
}
/**
* Deletes config in landing pages & news block
*/
function cr_update_8025() {
deleteConfig('core.entity_view_display.node.landing.landing_page_header');
deleteConfig('core.entity_view_mode.node.landing_page_header');
deleteConfig('block.block.views_block__what_s_going_on_block_1');
}
/**
* Remove update module
*/
function cr_update_8026() {
installer()->uninstall(['update']);
deleteConfig('update.settings');
}
/**
* Install cr_meta_icons
*/
function cr_update_8027() {
installer()->install(['cr_meta_icons']);
}
/**
* Delete cr_search_db config
*/
function cr_update_8028() {
deleteConfig('search_api.server.cr_database');
deleteConfig('search_api.index.cr_content');
deleteConfig('views.view.search_db');
deleteConfig('search_api_db.settings');
installer()->uninstall(['search_api_db']);
}
/**
* Install blazy and remove dblog settings
*/
function cr_update_8029() {
installer()->install(['blazy']);
installer()->uninstall(['update']);
deleteConfig('dblog.settings');
}
/**
* Install better_exposed_filters & cr_image
*/
function cr_update_8030() {
installer()->install(['better_exposed_filters'], ['cr_image']);
}
/**
* Install crop
*/
function cr_update_8031() {
installer()->install(['crop']);
}
/**
* Install cr_colours
*/
function cr_update_8032() {
installer()->install(['cr_colours']);
}
/**
* Install cr_feature_articles
*/
function cr_update_8033() {
installer()->install(['cr_feature_articles']);
}
/**
* Re-save all Article content to add new exclude from aggregator field.
*/
function cr_update_8034() {
// Reinstall the cr_article configuration.
\Drupal::service('config.installer')->installDefaultConfig('module', 'cr_article');
// Get an array of all 'article' node ids.
$article_nids = \Drupal::entityQuery('node')
->condition('type', 'article')
->execute();
// Load all the articles.
$articles = \Drupal\node\Entity\Node::loadMultiple($article_nids);
foreach ($articles as $article) {
$article->set('field_article_exclude_aggr', 0);
$article->save();
}
}
/**
* Install views_ajax_history.
*/
function cr_update_8035() {
installer()->install(['views_ajax_history']);
}
/**
* Rerun article save due to previously incorrectly named field in hook 8034.
*/
function cr_update_8036() {
// Get an array of all 'article' node ids.
$article_nids = \Drupal::entityQuery('node')
->condition('type', 'article')
->execute();
// Load all the articles.
$articles = \Drupal\node\Entity\Node::loadMultiple($article_nids);
foreach ($articles as $article) {
$article->set('field_article_exclude_aggr', 0);
$article->save();
}
}
/**
* Re-install the feature articles module configuration to allow null taxonomies.
*/
function cr_update_8037() {
// Reinstall the cr_feature_articles configuration.
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_feature_articles');
}
/**
* Re-install the config from email_signup module
*/
function cr_update_8038() {
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_email_signup');
}
/**
* Re-install the cr_article configuration to bring in changes to category requirement.
*/
function cr_update_8039() {
// Reinstall the cr_article configuration.
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_article');
}
/**
* Update all articles without an article type to be news.
*/
function cr_update_8040() {
// Get an array of all 'article' node ids.
$article_nids = \Drupal::entityQuery('node')
->condition('type', 'article')
->notExists('field_article_type')
->execute();
// Load all the articles.
$articles = \Drupal\node\Entity\Node::loadMultiple($article_nids);
foreach ($articles as $article) {
$article->set('field_article_type', 'news');
$article->save();
}
}
/**
* Re-install the cr_article configuration to bring in changes to teaser articles display.
*/
function cr_update_8041() {
// Reinstall the cr_article configuration.
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_article');
}
/**
* Re-install the cr_iframe configuration to bring in the initial height field.
*/
function cr_update_8042() {
// Reinstall the cr_article configuration.
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_iframe');
}
/**
* Install override_node_options & view_unpublished to allow content editors to see unpublished articles.
*/
function cr_update_8043() {
installer()->install(['view_unpublished']);
installer()->install(['override_node_options']);
}
/**
* Install advanced aggregator and advanced js minifier.
*/
function cr_update_8044() {
installer()->install(['advagg']);
installer()->install(['advagg_js_minify']);
}
/**
* Re-install the CR Image module for new BG-Graphics config
*/
function cr_update_8045() {
// Reinstall the cr_image configuration.
\Drupal::service('config.installer')
->installDefaultConfig('module', 'cr_image');
}
/**
* Remove Sitemap module and config to reinstall in next step to fix DB issue
*/
function cr_update_8046() {
installer()->uninstall(['simple_sitemap']);
}
function cr_update_8047() {
installer()->install(['simple_sitemap']);
}