function CommentTestBase::createCommentType
Same name in this branch
- 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
- 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::createCommentType()
- 11.x 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\TestsCode
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.