-
Notifications
You must be signed in to change notification settings - Fork 26
/
islandora_defaults.post_update.php
63 lines (58 loc) · 2.46 KB
/
islandora_defaults.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 hooks.
*/
/**
* Remove "enforced" dependency on this module from installed config.
*/
function islandora_defaults_post_update_remove_enforced_dependency() {
// XXX: Notably absent from this list is the migration defined by the
// migrate_plus.migration.islandora_defaults_tags config entity; however,
// given this migration depends on content that is explicitly part of this
// module (the CSV from which it takes its data), it would leave it in an
// inconsistent state if we were to leave the entity intact.
$targets = [
'context.context.binary',
'context.context.collection',
'context.context.repository_content',
'context.context.taxonomy_terms',
'core.entity_form_display.node.islandora_object.default',
'core.entity_view_display.media.file.open_seadragon',
'core.entity_view_display.media.image.open_seadragon',
'core.entity_view_display.node.islandora_object.binary',
'core.entity_view_display.node.islandora_object.default',
'core.entity_view_display.node.islandora_object.open_seadragon',
'core.entity_view_display.node.islandora_object.pdfjs',
'core.entity_view_display.node.islandora_object.teaser',
'core.entity_view_mode.media.open_seadragon',
'core.entity_view_mode.node.binary',
'core.entity_view_mode.node.open_seadragon',
'field.field.node.islandora_object.field_description',
'field.field.node.islandora_object.field_display_hints',
'field.field.node.islandora_object.field_member_of',
'field.field.node.islandora_object.field_model',
'node.type.islandora_object',
'rdf.mapping.node.islandora_object',
'views.view.openseadragon_media_evas',
'views.view.pdfjs_media_evas',
];
$diff_set = ['islandora_defaults'];
/** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */
$config_factory = \Drupal::service('config.factory');
foreach ($targets as $target) {
$editable_target = $config_factory->getEditable($target);
if ($editable_target->isNew()) {
// We do not want to _create_ any of the configs, just change them if they
// exist, so if it turns out that we would be creating the config, skip
// it.
continue;
}
$current_set = $editable_target->get('dependencies.enforced.module');
$post_diff = array_diff($current_set, $diff_set);
if ($post_diff !== $current_set) {
$editable_target->set('dependencies.enforced.module', $post_diff);
$editable_target->save();
}
}
}