diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index 05bda60..ab2e93f 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -18,85 +18,24 @@ function forum_install() { $locked['forum'] = 'forum'; \Drupal::state()->set('node.type.locked', $locked); - // Create the 'taxonomy_forums' field if it doesn't already exist. If forum - // is being enabled at the same time as taxonomy after both modules have been - // enabled, the field might exist but still be marked inactive. - if (!field_read_field('node', 'taxonomy_forums', array('include_inactive' => TRUE))) { - entity_create('field_entity', array( - 'name' => 'taxonomy_forums', - 'entity_type' => 'node', - 'type' => 'taxonomy_term_reference', - 'settings' => array( - 'allowed_values' => array( - array( - 'vocabulary' => 'forums', - 'parent' => 0, - ), - ), - ), - ))->save(); - - // Create a default forum so forum posts can be created. - $term = entity_create('taxonomy_term', array( - 'name' => t('General discussion'), - 'langcode' => language_default()->id, - 'description' => '', - 'parent' => array(0), - 'vid' => 'forums', - 'forum_container' => 0, - )); - $term->save(); - - // Create the instance on the bundle. - entity_create('field_instance', array( - 'field_name' => 'taxonomy_forums', - 'entity_type' => 'node', - 'label' => 'Forums', - 'bundle' => 'forum', - 'required' => TRUE, - ))->save(); - - // Assign form display settings for the 'default' form mode. - entity_get_form_display('node', 'forum', 'default') - ->setComponent('taxonomy_forums', array( - 'type' => 'options_select', - )) - ->save(); - - // Assign display settings for the 'default' and 'teaser' view modes. - entity_get_display('node', 'forum', 'default') - ->setComponent('taxonomy_forums', array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - )) - ->save(); - entity_get_display('node', 'forum', 'teaser') - ->setComponent('taxonomy_forums', array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - )) - ->save(); - } - // Add the comment field to the forum node type. - $fields = entity_load_multiple_by_properties('field_entity', array( - 'type' => 'comment', - 'name' => 'comment_forum', - 'include_inactive' => TRUE, - 'include_deleted' => FALSE, + // Create a default forum so forum posts can be created. + $term = entity_create('taxonomy_term', array( + 'name' => t('General discussion'), + 'langcode' => language_default()->id, + 'description' => '', + 'parent' => array(0), + 'vid' => 'forums', + 'forum_container' => 0, )); - if (empty($fields)) { - Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum', COMMENT_OPEN); - } + $term->save(); } /** * Implements hook_module_preinstall(). */ function forum_module_preinstall($module) { - $list_boolean = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinition('list_boolean'); - if (empty($list_boolean) && $module == 'forum') { - // Make sure that the list_boolean field type is available before our - // default config is installed. + if ($module == 'forum') { + // Make sure to clear cache before our default config is installed. field_info_cache_clear(); } }