Version 1
[yaffs-website] / web / core / modules / comment / src / Plugin / views / field / LinkApprove.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  * Provides a comment approve link.
11  *
12  * @ingroup views_field_handlers
13  *
14  * @ViewsField("comment_link_approve")
15  */
16 class LinkApprove extends LinkBase {
17
18   /**
19    * {@inheritdoc}
20    */
21   protected function getUrlInfo(ResultRow $row) {
22     return Url::fromRoute('comment.approve', ['comment' => $this->getEntity($row)->id()]);
23   }
24
25   /**
26    * {@inheritdoc}
27    */
28   protected function renderLink(ResultRow $row) {
29     $this->options['alter']['query'] = $this->getDestinationArray();
30     return parent::renderLink($row);
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function getDefaultLabel() {
37     return $this->t('Approve');
38   }
39
40 }