diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 2149e6f..3668b52 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1888,46 +1888,3 @@ function comment_mark(CommentInterface $comment) { } return MARK_READ; } - -/** - * Utility method to add the default comment field to an entity. - * - * Attaches a comment field named 'comment' to the given entity type and bundle. - * Largely replicates the default behaviour in Drupal 7 and earlier. - * - * @param string $entity_type - * The entity type to attach the default comment field to. - * @param string $bundle - * The bundle to attach the default comment field instance to. - * @param string $field_name - * (optional) Field name to use for the comment field. Defaults to 'comment'. - * @param string $default_value - * (optional) Default value, one of COMMENT_HIDDEN, COMMENT_OPEN, - * COMMENT_CLOSED. Defaults to COMMENT_OPEN. - */ -function comment_add_default_comment_field($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN) { - return Drupal::service('comment.manager')->addDefaultField($entity_type, $bundle, $field_name, $default_value); -} - -/** - * Process callback to add submit handler for instance settings form. - * - * Attaches the required translation entity handlers for the instance which - * correlates one to one with the comment bundle. - */ -function _comment_field_instance_settings_form_process($element, $form_state) { - // Settings should not be stored as nested. - $parents = $element['#parents']; - array_pop($parents); - $element['#parents'] = $parents; - // Add translation entity handlers. - if (Drupal::moduleHandler()->moduleExists('content_translation')) { - $comment_form = $element; - $comment_form_state['content_translation']['key'] = 'language_configuration'; - $element += content_translation_enable_widget('comment', $element['#field_name'], $comment_form, $comment_form_state); - $element['content_translation']['#parents'] = $element['content_translation']['#array_parents'] = array( - 'content_translation' - ); - } - return $element; -} diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php index c7222c2..0a16569 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/field_type/CommentItem.php @@ -17,7 +17,6 @@ * * @FieldType( * id = "comment", - * module = "comment", * label = @Translation("Comments"), * description = @Translation("This field manages configuration and presentation of comments on an entity."), * instance_settings = { @@ -81,17 +80,18 @@ public static function schema(FieldInterface $field) { public function instanceSettingsForm(array $form, array &$form_state) { $element = array(); - $instance = $this->getFieldDefinition(); - $settings = $instance->settings; - $field = $instance->getField(); + $settings = $this->getFieldSettings(); + + $entity_type = $this->getParent()->getParent()->getType(); + $field_name = $this->getFieldDefinition()->getFieldName(); $element['comment'] = array( '#type' => 'details', '#title' => t('Comment form settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, - '#field_name' => $field->id(), - '#process' => array('_comment_field_instance_settings_form_process'), + '#bundle' => "{$entity_type}__{$field_name}", + '#process' => array(array(get_class($this), '_comment_field_instance_settings_form_process')), '#attributes' => array( 'class' => array('comment-instance-settings-form'), ), @@ -151,8 +151,6 @@ public function instanceSettingsForm(array $form, array &$form_state) { */ public function applyDefaultValue($notify = TRUE) { // Retrieve the configured default value for the instance. - //$defaults = $this->getInstance()->default_value; - //$this->setValue(reset($defaults), $notify); $this->setValue(array('status' => COMMENT_OPEN), $notify); return $this; } @@ -165,4 +163,27 @@ public function isEmpty() { return FALSE; } + /** + * Process callback to add submit handler for instance settings form. + * + * Attaches the required translation entity handlers for the instance which + * correlates one to one with the comment bundle. + */ + public static function _comment_field_instance_settings_form_process($element) { + // Settings should not be stored as nested. + $parents = $element['#parents']; + array_pop($parents); + $element['#parents'] = $parents; + // Add translation entity handlers. + if (\Drupal::moduleHandler()->moduleExists('content_translation')) { + $comment_form = $element; + $comment_form_state['content_translation']['key'] = 'language_configuration'; + $element += content_translation_enable_widget('comment', $element['#bundle'], $comment_form, $comment_form_state); + $element['content_translation']['#parents'] = $element['content_translation']['#array_parents'] = array( + 'content_translation' + ); + } + return $element; + } + } diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php b/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php index 6ac74dc..f22b004 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/field/widget/CommentWidget.php @@ -30,7 +30,7 @@ class CommentWidget extends WidgetBase { */ public function formElement(FieldInterface $items, $delta, array $element, $langcode, array &$form, array &$form_state) { $field = $this->fieldDefinition; - $entity = $element['#entity']; + $entity = $items->getParent(); $element['status'] = array( '#type' => 'radios', diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index 10a4602..a351410 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -34,7 +34,7 @@ function testCommentDefaultFields() { // Do not make assumptions on default node types created by the test // installation profile, and create our own. $this->drupalCreateContentType(array('type' => 'test_node_type')); - comment_add_default_comment_field('node', 'test_node_type'); + $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type'); // Check that the 'comment_body' field is present on the comment bundle. $instance = $this->container->get('field.info')->getInstance('comment', 'node__comment', 'comment_body'); @@ -49,7 +49,7 @@ function testCommentDefaultFields() { // Create a new content type. $type_name = 'test_node_type_2'; $this->drupalCreateContentType(array('type' => $type_name)); - comment_add_default_comment_field('node', $type_name); + $this->container->get('comment.manager')->addDefaultField('node', $type_name); // Check that the 'comment_body' field exists and has an instance on the // new comment bundle. @@ -101,7 +101,7 @@ function testCommentEnable() { $this->assertTrue($this->container->get('module_handler')->moduleExists('comment'), 'Comment module enabled.'); // Create nodes of each type. - comment_add_default_comment_field('node', 'book'); + $this->container->get('comment.manager')->addDefaultField('node', 'book'); $book_node = $this->drupalCreateNode(array('type' => 'book')); $this->drupalLogout(); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php index a3db807..0c7abfa 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentLanguageTest.php @@ -71,7 +71,7 @@ function setUp() { $this->drupalPost("user/" . $admin_user->id() . "/edit", $edit, t('Save')); // Create comment field on article. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); // Make comment body translatable. $field = field_info_field('comment', 'comment_body'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index 74a12c8..759a142 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -50,9 +50,9 @@ function setupBundle() { parent::setupBundle(); $this->drupalCreateContentType(array('type' => $this->nodeBundle, 'name' => $this->nodeBundle)); // Add a comment field to the article content type. - comment_add_default_comment_field('node', 'article', 'comment_article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment_article'); // Add another comment field with new bundle to page content type. - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Mark this bundle as translatable. content_translation_set_config('comment', 'node__comment_article', 'enabled', TRUE); // Refresh entity info. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php index c3fb6e7..1bed5df 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentUninstallTest.php @@ -35,7 +35,7 @@ protected function setUp() { // Create an article content type. $this->drupalCreateContentType(array('type' => 'article', 'name' => t('Article'))); // Create comment field on article so that adds 'comment_body' field. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); } /** diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php index 7dd1dcf..3dee6d0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/CommentTestBase.php @@ -40,7 +40,7 @@ function setUp() { $this->account2 = $this->drupalCreateUser(); $this->drupalLogin($this->account); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->node_user_posted = $this->drupalCreateNode(); $this->node_user_commented = $this->drupalCreateNode(array('uid' => $this->account2->id())); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php index 674b722..3f3759e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/DefaultViewRecentComments.php @@ -73,7 +73,7 @@ public function setUp() { 'type' => $content_type->type, ); - comment_add_default_comment_field('node', $content_type->type); + $this->container->get('comment.manager')->addDefaultField('node', $content_type->type); $this->node = $this->drupalCreateNode($node_data); // Force a flush of the in-memory storage. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php index de1487a..f030d71 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/Views/WizardTest.php @@ -36,6 +36,8 @@ public static function getInfo() { * Tests adding a view of comments. */ public function testCommentWizard() { + // Add comment field to page node type. + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $view = array(); $view['label'] = $this->randomName(16); $view['id'] = strtolower($this->randomName(16)); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 6d502de..6e5eb85 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -37,7 +37,7 @@ function setUp() { // bundles. $this->drupalCreateContentType(array('type' => 'article')); $this->drupalCreateContentType(array('type' => 'page')); - comment_add_default_comment_field('node', 'article', 'comment_article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment_article'); $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content translation', 'administer content types', 'administer comment fields')); $this->drupalLogin($admin_user); diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php index befce24..aba580c 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php @@ -399,7 +399,7 @@ public function testCommentHandler() { } // Create comment field on article. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); $comment_values = array( 'published_published' => array( diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index 6c90cdd..04199c2 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -253,7 +253,7 @@ function testPrivateFileComment() { user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('post comments', 'skip comment approval')); // Create a new field. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); $edit = array( 'fields[_add_new_field][label]' => $label = $this->randomName(), 'fields[_add_new_field][field_name]' => $name = strtolower($this->randomName()), diff --git a/core/modules/filter/lib/Drupal/filter/Tests/FilterHtmlImageSecureTest.php b/core/modules/filter/lib/Drupal/filter/Tests/FilterHtmlImageSecureTest.php index f4b65c9..f3f560e 100644 --- a/core/modules/filter/lib/Drupal/filter/Tests/FilterHtmlImageSecureTest.php +++ b/core/modules/filter/lib/Drupal/filter/Tests/FilterHtmlImageSecureTest.php @@ -68,7 +68,7 @@ function setUp() { // Setup a node to comment and test on. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); // Add a comment field. - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->node = $this->drupalCreateNode(); } diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index d1f6f07..16bc861 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -117,7 +117,7 @@ function forum_enable() { 'include_deleted' => FALSE, )); if (empty($fields)) { - comment_add_default_comment_field('node', 'forum', 'comment_forum', COMMENT_OPEN); + Drupal::service('comment.manager')->addDefaultField('node', 'forum', 'comment_forum', COMMENT_OPEN); } } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php index 13d6eb9..020ced2 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeAccessPagerTest.php @@ -34,7 +34,7 @@ public function setUp() { parent::setUp(); node_access_rebuild(); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->web_user = $this->drupalCreateUser(array('access content', 'access comments', 'node test view')); } diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php index 7fbb2dc..40015ec 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php @@ -34,7 +34,7 @@ function setUp() { $this->admin_user = $this->drupalCreateUser(array('administer nodes', 'create article content', 'create page content', 'post comments')); $this->drupalLogin($this->admin_user); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); } /** diff --git a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php index 6b32e57..e2b4f45 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Views/RowPluginTest.php @@ -56,7 +56,7 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'article')); // Create comment field on article. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); // Create two nodes, with 5 comments on all of them. for ($i = 0; $i < 2; $i++) { diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php index 32a2ff0..09a51b3 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/TrackerAttributesTest.php @@ -88,7 +88,7 @@ function setUp() { )); // Create comment field on article. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); // Sets base URI of the site used by the RDFa parser. $this->base_uri = url('', array('absolute' => TRUE)); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php index 3d130f4..3ea7d36 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentCountToggleTest.php @@ -49,7 +49,7 @@ function setUp() { $this->searching_user = $this->drupalCreateUser(array('search content', 'access content', 'access comments', 'skip comment approval')); // Add a comment field. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); // Create initial nodes. $node_params = array('type' => 'article', 'body' => array(array('value' => 'SearchCommentToggleTestCase'))); diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php index 528ae5e..b06ca0e 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchCommentTest.php @@ -50,7 +50,7 @@ function setUp() { $this->admin_user = $this->drupalCreateUser($permissions); $this->drupalLogin($this->admin_user); // Add a comment field. - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); } /** diff --git a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php index 47ae7e2..48d6255 100644 --- a/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php +++ b/core/modules/search/lib/Drupal/search/Tests/SearchRankingTest.php @@ -44,7 +44,7 @@ public function testRankings() { // Login with sufficient privileges. $this->drupalLogin($this->drupalCreateUser(array('post comments', 'skip comment approval', 'create page content'))); // Add a comment field. - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Build a list of the rankings to test. $node_ranks = array('sticky', 'promote', 'relevance', 'recent', 'comments', 'views'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php index 89508c7..4e91a84 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityBCDecoratorTest.php @@ -44,7 +44,7 @@ public function setUp() { public function testBCDecorator() { // Test using comment subject via the BC decorator. $this->createUser(); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $node = entity_create('node', array( 'type' => 'page', 'uid' => 1, diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php index 2b305d9..fc6ccdb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php @@ -133,7 +133,7 @@ public function testBlockHooks() { public function testCommentHooks() { $account = $this->createUser(); $this->enableModules(array('entity', 'filter')); - comment_add_default_comment_field('node', 'article', 'comment', COMMENT_OPEN); + $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment', COMMENT_OPEN); $node = entity_create('node', array( 'uid' => $account->id(), diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php index f225e51..e05a514 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/EntityFilteringThemeTest.php @@ -98,7 +98,7 @@ function setUp() { $this->term->save(); // Add a comment field. - comment_add_default_comment_field('node', 'article', 'comment', COMMENT_OPEN); + $this->container->get('comment.manager')->addDefaultField('node', 'article', 'comment', COMMENT_OPEN); // Create a test node tagged with the test term. $this->node = $this->drupalCreateNode(array( 'title' => $this->xss_label, diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php index b5377ad..57828bf 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerNodeAccessTest.php @@ -32,7 +32,7 @@ public static function getInfo() { public function setUp() { parent::setUp(); node_access_rebuild(); - comment_add_default_comment_field('node', 'page', 'comment', COMMENT_OPEN); + $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment', COMMENT_OPEN); \Drupal::state()->set('node_access_test.private', TRUE); } diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php index 37cc407..90d029a 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/TrackerTest.php @@ -52,7 +52,7 @@ function setUp() { $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval'); $this->user = $this->drupalCreateUser($permissions); $this->other_user = $this->drupalCreateUser($permissions); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); } /** diff --git a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php index 3b6e77d..00fb775 100644 --- a/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php +++ b/core/modules/tracker/lib/Drupal/tracker/Tests/Views/TrackerTestBase.php @@ -30,7 +30,7 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); // Add a comment field. - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $permissions = array('access comments', 'create page content', 'post comments', 'skip comment approval'); $account = $this->drupalCreateUser($permissions); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php index 3dc051a..441e483 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCancelTest.php @@ -278,7 +278,7 @@ function testUserDelete() { \Drupal::config('user.settings')->set('cancel_method', 'user_cancel_delete')->save(); module_enable(array('comment')); $this->resetAll(); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Create a user. $account = $this->drupalCreateUser(array('cancel account', 'post comments', 'skip comment approval')); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php index 31fd811..0df4cf2 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserPictureTest.php @@ -43,7 +43,7 @@ function setUp() { 'skip comment approval', )); $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); // @see standard.install module_load_install('user'); diff --git a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php index 334d74e..e7b5312 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserSignatureTest.php @@ -39,7 +39,7 @@ function setUp() { // Create Basic page node type. $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); // Add a comment field with commenting enabled by default. - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Prefetch and create text formats. $this->filtered_html_format = entity_create('filter_format', array( diff --git a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php index 22cce2d..1e61836 100644 --- a/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/DefaultViewsTest.php @@ -83,7 +83,7 @@ protected function setUp() { // Create a time in the past for the archive. $time = REQUEST_TIME - 3600; - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->container->get('views.views_data')->clear(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php b/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php index 1d915a1..310326c 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FieldEntityTest.php @@ -45,7 +45,7 @@ public function testGetEntity() { $account = entity_create('user', array('name' => $this->randomName(), 'bundle' => 'user')); $account->save(); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); // Force a flush of the in-memory storage. $this->container->get('views.views_data')->clear(); diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php index 668ee2e..05d9887 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerAllTest.php @@ -54,7 +54,7 @@ public static function getInfo() { * Tests most of the handlers. */ public function testHandlers() { - comment_add_default_comment_field('node', 'article'); + $this->container->get('comment.manager')->addDefaultField('node', 'article'); $object_types = array_keys(ViewExecutable::viewsHandlerTypes()); foreach ($this->container->get('views.views_data')->get() as $base_table => $info) { diff --git a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php index e8365c2..fdf35f0 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Handler/HandlerTest.php @@ -41,7 +41,7 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); $this->enableViewsTestModule(); } diff --git a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php index e289417..b3b2a76 100644 --- a/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/ViewExecutableTest.php @@ -86,7 +86,7 @@ protected function setUpFixtures() { $this->installSchema('node', array('node', 'node_field_data')); $this->installSchema('comment', array('comment', 'comment_entity_statistics')); $this->installConfig(array('field')); - comment_add_default_comment_field('node', 'page'); + $this->container->get('comment.manager')->addDefaultField('node', 'page'); parent::setUpFixtures(); $this->installConfig(array('filter')); diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install index 5cab4c6..10aa27f 100644 --- a/core/profiles/standard/standard.install +++ b/core/profiles/standard/standard.install @@ -25,7 +25,7 @@ function standard_install() { Drupal::config('system.site')->set('page.front', 'node')->save(); // Add comment field to article node type. - comment_add_default_comment_field('node', 'article', 'comment', COMMENT_OPEN); + Drupal::service('comment.manager')->addDefaultField('node', 'article', 'comment', COMMENT_OPEN); // Allow visitor account creation with administrative approval. $user_settings = Drupal::config('user.settings');