function LinkApprove::render_link

Overrides Link::render_link

File

drupal/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkApprove.php, line 26
Definition of Drupal\comment\Plugin\views\field\LinkApprove.

Class

LinkApprove
Provides a comment approve link.

Namespace

Drupal\comment\Plugin\views\field

Code

function render_link($data, $values) {
  $status = $this
    ->getValue($values, 'status');

  // Don't show an approve link on published nodes.
  if ($status == COMMENT_PUBLISHED) {
    return;
  }
  $text = !empty($this->options['text']) ? $this->options['text'] : t('approve');
  $cid = $this
    ->getValue($values, 'cid');
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = "comment/" . $cid . "/approve";
  $this->options['alter']['query'] = drupal_get_destination() + array(
    'token' => drupal_get_token("comment/{$cid}/approve"),
  );
  return $text;
}