From 860762ba502b2c326ced3a7e39111783b6d6c165 Mon Sep 17 00:00:00 2001 From: YesCT Date: Thu, 23 Feb 2017 15:31:45 +0000 Subject: [PATCH] Issue #2854212: Add update for Drupal 7 to Backdrop upgrades. Did not work with a test site. Needs work. --- audiofield.install | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/audiofield.install b/audiofield.install index 9ff81aa..ec7669f 100644 --- a/audiofield.install +++ b/audiofield.install @@ -1,13 +1,39 @@ condition('name', 'audiofield_%%', 'LIKE') - ->execute(); + +/** + * Move settings from variables to config. + */ +function audiofield_update_1000() { + // These are hardcoded here. But if another module added more types, this + // should be more dynamic, using a loop. + // @see audiofield_admin_settings_form() + + // Migrate variables to config. + $config = config('audiofield.settings'); + $config->set('audioplayer', update_variable_get('audiofield_audioplayer', 'html5')); + $config->set('audioplayer_wav', update_variable_get('audiofield_audioplayer_wav', 'html5')); + $config->set('audioplayer_ogg', update_variable_get('audiofield_audioplayer_ogg', 'html5')); + $config->set('players_dir', update_variable_get('audiofield_players_dir', 'sites/all/libraries/player')); + $config->save(); + + // Delete variables. + update_variable_del('audiofield_audioplayer'); + update_variable_del('audiofield_audioplayer_wav'); + update_variable_del('audiofield_audioplayer_ogg'); + update_variable_del('audiofield_players_dir'); } + +/** + * @} End of "defgroup updates-7.x-to-1.x" + * The next series of updates should start at 2000. + */