-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoe_multilingual.post_update.php
77 lines (72 loc) · 1.63 KB
/
oe_multilingual.post_update.php
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
<?php
/**
* @file
* Post update functions for OpenEuropa Multilingual module.
*/
declare(strict_types=1);
/**
* Invalidate service containers.
*
* Invalidate service containers for applying changes of
* oe_multilingual.local_translations_batcher service.
*/
function oe_multilingual_post_update_00001_invalidate_containers_cache(): void {
\Drupal::service('kernel')->invalidateContainer();
}
/**
* Apply EU category to EU languages.
*/
function oe_multilingual_post_update_00002(): void {
$eu_languages = [
'en',
'sv',
'lv',
'pl',
'lt',
'da',
'fr',
'hr',
'sl',
'ro',
'es',
'cs',
'nl',
'ga',
'mt',
'pt-pt',
'it',
'fi',
'el',
'hu',
'et',
'de',
'bg',
'sk',
];
$languages = \Drupal::entityTypeManager()->getStorage('configurable_language')->loadMultiple($eu_languages);
foreach ($languages as $language) {
/** @var \Drupal\language\Entity\ConfigurableLanguage $language */
$language->setThirdPartySetting('oe_multilingual', 'category', 'eu');
$language->save();
}
}
/**
* Change the order of languages.
*/
function oe_multilingual_post_update_00003(): void {
$language_weight_mapping = [
'cs' => 2,
'da' => 3,
'de' => 4,
'el' => 6,
'es' => 1,
'et' => 5,
'en' => 7,
];
$languages = \Drupal::entityTypeManager()->getStorage('configurable_language')->loadMultiple(array_keys($language_weight_mapping));
foreach ($languages as $language) {
/** @var \Drupal\language\Entity\ConfigurableLanguage $language */
$language->setWeight($language_weight_mapping[$language->id()]);
$language->save();
}
}