forked from Islandora/openseadragon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenseadragon.post_update.php
More file actions
87 lines (85 loc) · 2.19 KB
/
Copy pathopenseadragon.post_update.php
File metadata and controls
87 lines (85 loc) · 2.19 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
<?php
/**
* @file
* Contains post_update hooks for openseadragon.
*/
/**
* Update configuration to match the new schema structure.
*
* {@inheritdoc}
*/
function openseadragon_post_update_expand_config_data(&$sandbox) {
$config = \Drupal::configFactory()->getEditable('openseadragon.settings');
// Remove deprecated setting.
$config->clear('navigatorAutoResize');
$boolean_keys = [
'fit_to_aspect_ratio',
'debugMode',
'alwaysBlend',
'autoHideControls',
'immediateRender',
'homeFillsViewer',
'panHorizontal',
'panVertical',
'constrainDuringPan',
'wrapHorizontal',
'wrapVertical',
'autoResize',
'preserveImageSizeOnResize',
'mouseNavEnabled',
'showNavigationControl',
'showZoomControl',
'showHomeControl',
'showFullPageControl',
'showRotationControl',
'showNavigator',
'navigatorMaintainSizeRatio',
'navigatorAutoFade',
'navigatorRotate',
'showSequenceControl',
'navPrevNextWrap',
'sequenceMode',
'preserveViewport',
'preserveOverlays',
'showReferenceStrip',
'collectionMode',
'ajaxWithCredentials',
'useCanvas',
];
$gesture_boolean_keys = [
'scrollToZoom',
'clickToZoom',
'dblClickToZoom',
'pinchToZoom',
'flickEnabled',
'pinchRotate',
];
foreach (['default_options', 'viewer_options'] as $root_key) {
$options = $config->get($root_key);
if (!is_array($options)) {
continue;
}
foreach ($boolean_keys as $key) {
if (array_key_exists($key, $options)) {
$options[$key] = (bool) $options[$key];
}
}
foreach ([
'gestureSettingsMouse',
'gestureSettingsTouch',
'gestureSettingsPen',
'gestureSettingsUnknown',
] as $gesture_key) {
if (!empty($options[$gesture_key]) && is_array($options[$gesture_key])) {
foreach ($gesture_boolean_keys as $key) {
if (array_key_exists($key, $options[$gesture_key])) {
$options[$gesture_key][$key] = (bool) $options[$gesture_key][$key];
}
}
}
}
$config->set($root_key, $options);
}
$config->save(TRUE);
return t('Normalized OpenSeadragon settings to match the expanded config schema.');
}