function CommentViewBuilder::alterBuild
Same name in other branches
- 9 core/modules/comment/src/CommentViewBuilder.php \Drupal\comment\CommentViewBuilder::alterBuild()
- 8.9.x core/modules/comment/src/CommentViewBuilder.php \Drupal\comment\CommentViewBuilder::alterBuild()
- 11.x core/modules/comment/src/CommentViewBuilder.php \Drupal\comment\CommentViewBuilder::alterBuild()
Overrides EntityViewBuilder::alterBuild
File
-
core/
modules/ comment/ src/ CommentViewBuilder.php, line 190
Class
- CommentViewBuilder
- View builder handler for comments.
Namespace
Drupal\commentCode
protected function alterBuild(array &$build, EntityInterface $comment, EntityViewDisplayInterface $display, $view_mode) {
parent::alterBuild($build, $comment, $display, $view_mode);
if (empty($comment->in_preview)) {
$prefix = '';
// Add indentation div or close open divs as needed.
if ($build['#comment_threaded']) {
$prefix .= $build['#comment_indent'] <= 0 ? str_repeat('</div>', abs($build['#comment_indent'])) : "\n" . '<div class="indented">';
}
$build['#prefix'] = $prefix;
// Close all open divs.
if (!empty($build['#comment_indent_final'])) {
$build['#suffix'] = str_repeat('</div>', $build['#comment_indent_final']);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.