Created
April 20, 2016 14:35
-
-
Save slivorezka/d78f03ef2f5984431c3df813234e1487 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @file | |
* Install | |
*/ | |
/** | |
* Implements hook_uninstall(). | |
*/ | |
function MODULE_uninstall() { | |
// Remove all variables. | |
$variables = db_select('variable', 'v') | |
->fields('v', array('name')) | |
->condition('v.name', db_like('MODULE') . '%', 'LIKE') | |
->execute() | |
->fetchAllAssoc('name'); | |
if (!empty($variables)) { | |
global $conf; | |
$variables = array_keys($variables); | |
// Delete. | |
foreach ($variables as $variable_name) { | |
db_delete('variable')->condition('name', $variable_name)->execute(); | |
unset($conf[$variable_name]); | |
} | |
// Cache clear. | |
cache_clear_all('variables', 'cache_bootstrap'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment