function pwa_update_7201 in Progressive Web App 7.2
Rename variables and initialize the new ones.
File
- ./
pwa.install, line 143
Code
function pwa_update_7201() {
$exclude = variable_get('pwa_sw_cache_exclude', FALSE);
_init_variables();
$mapping = [
'pwa_sw_cache_urls' => 'pwa_sw_precache_page',
'pwa_sw_cache_url_patterns' => 'pwa_sw_cache_patterns_page',
];
foreach ($mapping as $before => $after) {
$value = _pwa_config_value_split($before, '');
variable_del($before);
foreach ($value as $index => $path) {
if ($path == '/' || $path == '/offline') {
unset($value[$index]);
}
}
variable_set($after, implode("\n", array_filter($value)));
}
// Restore the existing value if neccessary.
if ($exclude) {
variable_set('pwa_sw_cache_exclude', $exclude);
}
// Clean up unused variable.
variable_del('pwa_filecache_manifest');
// Update default theme color to "Light blue".
if (variable_get('pwa_theme_color', '') == '#ffffff') {
variable_set('pwa_theme_color', '#53B0EB');
}
// Update default background color to "Pale Gray".
if (variable_get('pwa_background_color', '') == '#ffffff') {
variable_set('pwa_background_color', '#F6F6F2');
}
// Update the start url.
if (variable_get('pwa_start_url', '') == '/') {
variable_set('pwa_start_url', '/?source=pwa');
}
// Clean up unused manifest.json file.
file_unmanaged_delete('public://pwa/manifest.json');
file_unmanaged_delete('private://pwa/manifest.json');
return 'Variables renamed.';
}