function CommentTestBase::setCommentSubject
Same name in this branch
- 8.9.x core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentSubject()
Same name in other branches
- 9 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentSubject()
- 10 core/modules/comment/tests/src/Functional/CommentTestBase.php \Drupal\Tests\comment\Functional\CommentTestBase::setCommentSubject()
- 11.x 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/ src/ Tests/ CommentTestBase.php, line 244
Class
- CommentTestBase
- Provides setup and helper methods for comment tests.
Namespace
Drupal\comment\TestsCode
public function setCommentSubject($enabled) {
$form_display = \Drupal::service('entity_display.repository')->getFormDisplay('comment', 'comment');
if ($enabled) {
$form_display->setComponent('subject', [
'type' => 'string_textfield',
]);
}
else {
$form_display->removeComponent('subject');
}
$form_display->save();
// Display status message.
$this->pass('Comment subject ' . ($enabled ? 'enabled' : 'disabled') . '.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.