CommentLazyBuilders::renderLinks

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

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;
}
doc_Drupal
2016-10-29 08:50:49
Comments
Leave a Comment

Please login to continue.