function LinkDelete::render_link

Same name in this branch
  1. 8.x drupal/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php \Drupal\node\Plugin\views\field\LinkDelete::render_link()
  2. 8.x drupal/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkDelete.php \Drupal\comment\Plugin\views\field\LinkDelete::render_link()

Renders the link.

Overrides Link::render_link

File

drupal/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php, line 25
Definition of Drupal\node\Plugin\views\field\LinkDelete.

Class

LinkDelete
Field handler to present a link to delete a node.

Namespace

Drupal\node\Plugin\views\field

Code

function render_link($node, $values) {

  // Ensure user has access to delete this node.
  if (!node_access('delete', $node)) {
    return;
  }
  $this->options['alter']['make_link'] = TRUE;
  $this->options['alter']['path'] = "node/{$node->nid}/delete";
  $this->options['alter']['query'] = drupal_get_destination();
  $text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
  return $text;
}