You are here

function bean_uninstall in Bean (for Drupal 7) 7

Implements hook_uninstall().

File

./bean.install, line 210
Bean installation routines

Code

function bean_uninstall() {

  // Bypass entity_load() as we cannot use it here.
  foreach (field_info_bundles('bean') as $bean_type => $bean_info) {
    field_attach_delete_bundle('bean', $bean_type);
  }

  //Remove shortcut links
  if (module_exists('shortcut')) {
    $shortcut_set = shortcut_default_set();
    foreach ($shortcut_set->links as $shortcut_key => $shortcut) {
      if ($shortcut['link_path'] == 'block/add' || $shortcut['link_path'] == 'admin/content/blocks') {
        unset($shortcut_set->link[$shortcut_key]);
        shortcut_set_save($shortcut_set);
        menu_link_delete(NULL, $shortcut['link_path']);
      }
    }
  }

  // Remove all variables used by the module.
  variable_del('bean_ctools_separate');
  variable_del('bean_ctools_prefix');
  variable_del('bean_usage_results_per_page');

  // Remove all variables for field bundle settings.
  db_delete('variable')
    ->condition('name', 'field_bundle_settings_bean%', 'LIKE')
    ->execute();

  // Remove all variables for blacklisting modules.
  // Note: it is not possible to list them here because the variable names are
  // generated dynamically and are not defined upfront.
  db_delete('variable')
    ->condition('name', 'bean_all_blacklist%', 'LIKE')
    ->execute();
}