-
Notifications
You must be signed in to change notification settings - Fork 41
/
govcms.post_update.php
63 lines (56 loc) · 2.09 KB
/
govcms.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
<?php
/**
* @file
* Post update functions for GovCMS.
*/
/**
* Updates the visibility condition for the node type in the block module.
*/
function govcms_post_update_replace_block_node_type_condition() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory->listAll('block.block.') as $block_config_name) {
$block = $config_factory->getEditable($block_config_name);
if ($block->get('visibility.node_type')) {
$configuration = $block->get('visibility.node_type');
$configuration['id'] = 'entity_bundle:node';
$block->set('visibility.entity_bundle:node', $configuration);
$block->clear('visibility.node_type');
$block->save(TRUE);
}
}
}
/**
* Updates the visibility condition for the node type in the context module.
*/
function govcms_post_update_replace_context_node_type_condition() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory->listAll('context.context.') as $context_config_name) {
$context = $config_factory->getEditable($context_config_name);
if ($context->get('conditions.node_type')) {
$configuration = $context->get('conditions.node_type');
$configuration['id'] = 'entity_bundle:node';
$context->set('conditions.entity_bundle:node', $configuration);
$context->clear('conditions.node_type');
$context->save(TRUE);
}
}
}
/**
* Updates the condition for the node type in the pathauto module.
*/
function govcms_post_update_replace_pathauto_node_type_condition() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory->listAll('pathauto.pattern.') as $pattern_config_name) {
$pattern_config = $config_factory->getEditable($pattern_config_name);
if ($pattern_config->get('type') === 'canonical_entities:node') {
$selection_criteria = $pattern_config->get('selection_criteria');
foreach ($selection_criteria as $uuid => $condition) {
if ($condition['id'] === 'node_type') {
$pattern_config->set("selection_criteria.$uuid.id", 'entity_bundle:node');
$pattern_config->save();
break;
}
}
}
}
}