function forum_install

Same name in other branches
  1. 7.x modules/forum/forum.install \forum_install()
  2. 8.9.x core/modules/forum/forum.install \forum_install()
  3. 10 core/modules/forum/forum.install \forum_install()
  4. 11.x core/modules/forum/forum.install \forum_install()

Implements hook_install().

File

core/modules/forum/forum.install, line 14

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();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.