public function CommentTestBase::setCommentSubject in Drupal 10
Same name and namespace in other branches
- 8 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentSubject()
- 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentSubject()
Sets the value governing whether the subject field should be enabled.
Parameters
bool $enabled: Boolean specifying whether the subject field should be enabled.
File
- core/
modules/ comment/ tests/ src/ Functional/ CommentTestBase.php, line 241
Class
- CommentTestBase
- Provides setup and helper methods for comment tests.
Namespace
Drupal\Tests\comment\FunctionalCode
public function setCommentSubject($enabled) {
$form_display = $this->container
->get('entity_display.repository')
->getFormDisplay('comment', 'comment');
if ($enabled) {
$form_display
->setComponent('subject', [
'type' => 'string_textfield',
]);
}
else {
$form_display
->removeComponent('subject');
}
$form_display
->save();
}