/** * Prepare the link for editing the comment. * * @param \Drupal\Core\Entity\EntityInterface $data * The comment entity. * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * * @return string * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { parent::renderLink($data, $values); // Ensure user has access to edit this comment. $comment = $this->getValue($values); if (!$comment->access('update')) { return; } $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit'); unset($this->options['alter']['fragment']); if (!empty($this->options['destination'])) { $this->options['alter']['query'] = drupal_get_destination(); } $this->options['alter']['path'] = "comment/" . $comment->id() . "/edit"; return $text; }
/** * Prepare the link for editing the comment. * * @param \Drupal\Core\Entity\EntityInterface $data * The comment entity. * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * * @return string * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { parent::renderLink($data, $values); // Ensure user has access to edit this comment. $comment = $this->getValue($values); if (!$comment->access('update')) { return; } $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit'); unset($this->options['alter']['fragment']); if (!empty($this->options['destination'])) { $this->options['alter']['query'] = $this->getDestinationArray(); } $this->options['alter']['url'] = $comment->urlInfo('edit-form'); return $text; }