You are here

function taxonomy_display_enable in Taxonomy display 7

Implements hook_enable().

Perform cleanup from while taxonomy_display was disabled.

File

./taxonomy_display.install, line 13
Install, update and uninstall functions for the taxonomy display module.

Code

function taxonomy_display_enable() {
  watchdog('taxonomy_display', 'Taxonomy display is performing cleanup in response to being enabled, any changes made will be subsequently logged.', array(), WATCHDOG_INFO);

  // Retrieve all the existing vocabularies.
  $vocabularies = taxonomy_vocabulary_get_names();

  // Select taxonomy displays we have in the DB.
  $taxonomy_displays = db_select('taxonomy_display', 'td')
    ->fields('td', array(
    'machine_name',
  ))
    ->execute();

  // Loop through each display
  foreach ($taxonomy_displays as $taxonomy_display) {

    // If the vocabulary does not exist delete the taxonomy_display as it is now
    // an orphan.
    if (!isset($vocabularies[$taxonomy_display->machine_name])) {
      taxonomy_display_delete_taxonomy_display($taxonomy_display->machine_name);
    }
  }
}