protected CommentViewBuilder::alterBuild(array &$build, EntityInterface $comment, EntityViewDisplayInterface $display, $view_mode)
Specific per-entity building.
Parameters
array $build: The render array that is being created.
\Drupal\Core\Entity\EntityInterface $entity: The entity to be prepared.
\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display: The entity view display holding the display options configured for the entity components.
string $view_mode: The view mode that should be used to prepare the entity.
Overrides EntityViewBuilder::alterBuild
File
- core/modules/comment/src/CommentViewBuilder.php, line 162
Class
- CommentViewBuilder
- View builder handler for comments.
Namespace
Drupal\comment
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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">' ; } // Add anchor for each comment. $prefix .= "<a id=\"comment-{$comment->id()}\"></a>\n" ; $build [ '#prefix' ] = $prefix ; // Close all open divs. if (! empty ( $build [ '#comment_indent_final' ])) { $build [ '#suffix' ] = str_repeat ( '</div>' , $build [ '#comment_indent_final' ]); } } } |
Please login to continue.