/**
  * Build the default links (reply, edit, delete …) for a comment.
  *
  * @param \Drupal\comment\CommentInterface $entity
  *   The comment object.
  * @param \Drupal\Core\Entity\EntityInterface $commented_entity
  *   The entity to which the comment is attached.
  *
  * @return array
  *   An array that can be processed by drupal_pre_render_links().
  */
 protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity)
 {
     $links = array();
     $status = $commented_entity->get($entity->getFieldName())->status;
     if ($status == CommentItemInterface::OPEN) {
         if ($entity->access('delete')) {
             $links['comment-delete'] = array('title' => t('Delete'), 'url' => $entity->urlInfo('delete-form'));
         }
         if ($entity->access('update')) {
             $links['comment-edit'] = array('title' => t('Edit'), 'url' => $entity->urlInfo('edit-form'));
         }
         if ($entity->access('create')) {
             $links['comment-reply'] = array('title' => t('Reply'), 'url' => Url::fromRoute('comment.reply', ['entity_type' => $entity->getCommentedEntityTypeId(), 'entity' => $entity->getCommentedEntityId(), 'field_name' => $entity->getFieldName(), 'pid' => $entity->id()]));
         }
         if (!$entity->isPublished() && $entity->access('approve')) {
             $links['comment-approve'] = array('title' => t('Approve'), 'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]));
         }
         if (empty($links) && $this->currentUser->isAnonymous()) {
             $links['comment-forbidden']['title'] = $this->commentManager->forbiddenMessage($commented_entity, $entity->getFieldName());
         }
     }
     // Add translations link for translation-enabled comment bundles.
     if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
         $links['comment-translations'] = array('title' => t('Translate'), 'url' => $entity->urlInfo('drupal:content-translation-overview'));
     }
     return array('#theme' => 'links__comment__comment', '#links' => $links, '#attributes' => array('class' => array('links', 'inline')));
 }
 /**
  * Build the default links (reply, edit, delete …) for a comment.
  *
  * @param \Drupal\comment\CommentInterface $entity
  *   The comment object.
  * @param \Drupal\Core\Entity\EntityInterface $commented_entity
  *   The entity to which the comment is attached.
  *
  * @return array
  *   An array that can be processed by drupal_pre_render_links().
  */
 protected static function buildLinks(CommentInterface $entity, EntityInterface $commented_entity)
 {
     $links = array();
     $status = $commented_entity->get($entity->getFieldName())->status;
     $container = \Drupal::getContainer();
     if ($status == CommentItemInterface::OPEN) {
         if ($entity->access('delete')) {
             $links['comment-delete'] = array('title' => t('Delete'), 'href' => "comment/{$entity->id()}/delete", 'html' => TRUE);
         }
         if ($entity->access('update')) {
             $links['comment-edit'] = array('title' => t('Edit'), 'href' => "comment/{$entity->id()}/edit", 'html' => TRUE);
         }
         if ($entity->access('create')) {
             $links['comment-reply'] = array('title' => t('Reply'), 'href' => "comment/reply/{$entity->getCommentedEntityTypeId()}/{$entity->getCommentedEntityId()}/{$entity->getFieldName()}/{$entity->id()}", 'html' => TRUE);
         }
         if (!$entity->isPublished() && $entity->access('approve')) {
             $links['comment-approve'] = array('title' => t('Approve'), 'route_name' => 'comment.approve', 'route_parameters' => array('comment' => $entity->id()), 'html' => TRUE);
         }
         if (empty($links) && \Drupal::currentUser()->isAnonymous()) {
             $links['comment-forbidden']['title'] = \Drupal::service('comment.manager')->forbiddenMessage($commented_entity, $entity->getFieldName());
             $links['comment-forbidden']['html'] = TRUE;
         }
     }
     // Add translations link for translation-enabled comment bundles.
     if (\Drupal::moduleHandler()->moduleExists('content_translation') && content_translation_translate_access($entity)) {
         $links['comment-translations'] = array('title' => t('Translate'), 'href' => 'comment/' . $entity->id() . '/translations', 'html' => TRUE);
     }
     return array('#theme' => 'links__comment__comment', '#links' => $links, '#attributes' => array('class' => array('links', 'inline')));
 }