Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / comment / src / Plugin / views / field / LinkReply.php
1 <?php
2
3 namespace Drupal\comment\Plugin\views\field;
4
5 use Drupal\Core\Url;
6 use Drupal\views\Plugin\views\field\LinkBase;
7 use Drupal\views\ResultRow;
8
9 /**
10  * Field handler to present a link to reply to a comment.
11  *
12  * @ingroup views_field_handlers
13  *
14  * @ViewsField("comment_link_reply")
15  */
16 class LinkReply extends LinkBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   protected function getUrlInfo(ResultRow $row) {
22     /** @var \Drupal\comment\CommentInterface $comment */
23     $comment = $this->getEntity($row);
24     return Url::fromRoute('comment.reply', [
25       'entity_type' => $comment->getCommentedEntityTypeId(),
26       'entity' => $comment->getCommentedEntityId(),
27       'field_name' => $comment->getFieldName(),
28       'pid' => $comment->id(),
29     ]);
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   protected function getDefaultLabel() {
36     return $this->t('Reply');
37   }
38
39 }