You are here

function forum_uninstall in Drupal 8

Same name and namespace in other branches
  1. 5 modules/forum/forum.install \forum_uninstall()
  2. 6 modules/forum/forum.install \forum_uninstall()
  3. 7 modules/forum/forum.install \forum_uninstall()
  4. 9 core/modules/forum/forum.install \forum_uninstall()
  5. 10 core/modules/forum/forum.install \forum_uninstall()

Implements hook_uninstall().

File

core/modules/forum/forum.install, line 38
Install, update, and uninstall functions for the Forum module.

Code

function forum_uninstall() {
  if ($field_storage = FieldStorageConfig::loadByName('node', 'taxonomy_forums')) {
    $field_storage
      ->delete();
  }
  if ($field_storage = FieldStorageConfig::loadByName('node', 'comment_forum')) {
    $field_storage
      ->delete();
  }
  if ($field_storage = FieldStorageConfig::loadByName('taxonomy_term', 'forum_container')) {
    $field_storage
      ->delete();
  }

  // Purge field data now to allow taxonomy and options module to be uninstalled
  // if this is the only field remaining.
  field_purge_batch(10);

  // Allow to delete a forum's node type.
  $locked = \Drupal::state()
    ->get('node.type.locked');
  unset($locked['forum']);
  \Drupal::state()
    ->set('node.type.locked', $locked);
}