You are here

function taxonomy_breadcrumb_uninstall in Taxonomy Breadcrumb 8

Same name and namespace in other branches
  1. 5 taxonomy_breadcrumb.install \taxonomy_breadcrumb_uninstall()
  2. 6 taxonomy_breadcrumb.install \taxonomy_breadcrumb_uninstall()
  3. 7 taxonomy_breadcrumb.install \taxonomy_breadcrumb_uninstall()

Implements hook_uninstall().

File

./taxonomy_breadcrumb.install, line 58
Install file for the taxonomy_breadcrumb module.

Code

function taxonomy_breadcrumb_uninstall() {

  // Remove variables.
  \Drupal::configFactory()
    ->getEditable('taxonomy_breadcrumb.settings')
    ->delete();

  // Delete taxonomy term field and its instances.
  $entity_type = 'taxonomy_term';
  $field_name = 'taxonomy_breadcrumb_path';
  $bundles = array_keys(\Drupal::entityTypeManager()
    ->getStorage('taxonomy_vocabulary')
    ->loadMultiple());
  foreach ($bundles as $bundle) {
    if (FieldConfig::loadByName($entity_type, $bundle, $field_name)) {
      try {
        FieldConfig::loadByName($entity_type, $bundle, $field_name)
          ->delete();
      } catch (FieldException $e) {
      }
    }
  }
  if (FieldStorageConfig::loadByName($entity_type, $field_name)) {
    try {
      FieldStorageConfig::loadByName($entity_type, $field_name)
        ->delete();
    } catch (FieldException $e) {
    }
  }
}