function CommentTestBase::createCommentType

Same name in this branch
  1. 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
Same name and namespace in other branches
  1. 11.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
  2. 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
  3. 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()

Creates a comment comment type (bundle).

Parameters

string $label: The comment type label.

Return value

\Drupal\comment\Entity\CommentType Created comment type.

File

core/modules/comment/src/Tests/CommentTestBase.php, line 407

Class

CommentTestBase
Provides setup and helper methods for comment tests.

Namespace

Drupal\comment\Tests

Code

protected function createCommentType($label) {
  $bundle = CommentType::create([
    'id' => $label,
    'label' => $label,
    'description' => '',
    'target_entity_type_id' => 'node',
  ]);
  $bundle->save();
  return $bundle;
}

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