public CommentLazyBuilders::renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_preview)
#lazy_builder callback; builds a comment's links.
Parameters
string $comment_entity_id: The comment entity ID.
string $view_mode: The view mode in which the comment entity is being viewed.
string $langcode: The language in which the comment entity is being viewed.
bool $is_in_preview: Whether the comment is currently being previewed.
Return value
array A renderable array representing the comment links.
File
- core/modules/comment/src/CommentLazyBuilders.php, line 128
Class
- CommentLazyBuilders
- Defines a service for comment #lazy_builder callbacks.
Namespace
Drupal\comment
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | public function renderLinks( $comment_entity_id , $view_mode , $langcode , $is_in_preview ) { $links = array ( '#theme' => 'links__comment' , '#pre_render' => array ( 'drupal_pre_render_links' ), '#attributes' => array ( 'class' => array ( 'links' , 'inline' )), ); if (! $is_in_preview ) { /** @var \Drupal\comment\CommentInterface $entity */ $entity = $this ->entityManager->getStorage( 'comment' )->load( $comment_entity_id ); $commented_entity = $entity ->getCommentedEntity(); $links [ 'comment' ] = $this ->buildLinks( $entity , $commented_entity ); // Allow other modules to alter the comment links. $hook_context = array ( 'view_mode' => $view_mode , 'langcode' => $langcode , 'commented_entity' => $commented_entity , ); $this ->moduleHandler->alter( 'comment_links' , $links , $entity , $hook_context ); } return $links ; } |
Please login to continue.