Overrides Drupal\Core\Entity\EntityRenderController::alterBuild().
Overrides EntityRenderController::alterBuild
protected function alterBuild(array &$build, EntityInterface $comment, $view_mode, $langcode = NULL) {
parent::alterBuild($build, $comment, $view_mode, $langcode);
if (empty($comment->in_preview)) {
$prefix = '';
$is_threaded = isset($comment->divs) && variable_get('comment_default_mode_' . $comment
->bundle(), COMMENT_MODE_THREADED) == COMMENT_MODE_THREADED;
// Add 'new' anchor if needed.
if (!empty($comment->first_new)) {
$prefix .= "<a id=\"new\"></a>\n";
}
// Add indentation div or close open divs as needed.
if ($is_threaded) {
$prefix .= $comment->divs <= 0 ? str_repeat('</div>', abs($comment->divs)) : "\n" . '<div class="indented">';
}
// Add anchor for each comment.
$prefix .= "<a id=\"comment-{$comment->cid}\"></a>\n";
$build['#prefix'] = $prefix;
// Close all open divs.
if ($is_threaded && !empty($comment->divs_final)) {
$build['#suffix'] = str_repeat('</div>', $comment->divs_final);
}
}
}