Skip to content

Instantly share code, notes, and snippets.

@batigolix
Created March 13, 2015 09:59
Show Gist options
  • Save batigolix/2ddd7f647835e48f887a to your computer and use it in GitHub Desktop.
Save batigolix/2ddd7f647835e48f887a to your computer and use it in GitHub Desktop.
/**
* Implements hook_uninstall().
*
* Deletes the NUTS regions variables.
* Deletes the NUTS regions vocabulary (fields and data).
*/
function nuts_regions_uninstall() {
$t = get_t();
variable_del('clients');
drupal_set_message($t('NUTS regions: NUTS regions was uninstalled from your site.'));
// Deletes the taxonomy term.
$vocabulary = taxonomy_vocabulary_machine_name_load('nuts_regions');
if ($vocabulary) {
$vid = $vocabulary->vid;
taxonomy_vocabulary_delete($vid);
}
// Deletes the custom fields.
$fields = array(
'nuts_level',
'nuts_id',
'nuts_code',
'nuts_country',
'nuts_description',
'nuts_remark',
);
foreach ($fields as $field) {
field_delete_field($field);
if ($instance = field_info_instance('taxonomy_term', $field, 'nuts_regions')) {
field_delete_instance($instance);
}
}
field_purge_batch(count($fields));
drupal_set_message($t('NUTS regions: NUTS regions vocabulary has been deleted from your site.'));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment