You are here

function forum_install in Drupal 9

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

Implements hook_install().

File

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

Code

function forum_install($is_syncing) {

  // Set the weight of the forum.module to 1 so it is loaded after the taxonomy.module.
  module_set_weight('forum', 1);

  // Do not allow to delete the forum's node type machine name.
  $locked = \Drupal::state()
    ->get('node.type.locked');
  $locked['forum'] = 'forum';
  \Drupal::state()
    ->set('node.type.locked', $locked);
  if (!$is_syncing) {

    // Create a default forum so forum posts can be created.
    $term = Term::create([
      'name' => t('General discussion'),
      'description' => '',
      'parent' => [
        0,
      ],
      'vid' => 'forums',
      'forum_container' => 0,
    ]);
    $term
      ->save();
  }
}