function 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() {
  // 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 (!\Drupal::service('config.installer')->isSyncing()) {
    // Create a default forum so forum posts can be created.
    $term = Term::create(array(
      'name' => t('General discussion'),
      'description' => '',
      'parent' => array(0),
      'vid' => 'forums',
      'forum_container' => 0,
    ));
    $term->save();
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!forum!forum.install/function/forum_install/8.1.x