Skip to content

Commit

Permalink
Issue #2854212: Add update for Drupal 7 to Backdrop upgrades.
Browse files Browse the repository at this point in the history
Did not work with a test site. Needs work.
  • Loading branch information
YesCT committed Feb 23, 2017
1 parent 681620b commit 860762b
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions audiofield.install
Original file line number Diff line number Diff line change
@@ -1,13 +1,39 @@
<?php
/**
* Implementation of hook_install().
* @file
* Install, update and uninstall functions for the Audiofield module.
*/

/**
* Implementation of hook_uninstall().
* @defgroup updates-7.x-to-1.x Updates from 7.x to 1.x
* @{
* Update functions from Drupal 7.x to Backdrop CMS 1.x.
*/
function audiofield_uninstall() {
db_delete('variable')
->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.
*/

0 comments on commit 860762b

Please sign in to comment.