You are here

protected function LinkDelete::renderLink in Profile 2 8

Prepares the link to delete a profile.

Parameters

\Drupal\Core\Entity\EntityInterface $profile: The profile entity this field belongs to.

\Drupal\views\ResultRow $values: The values retrieved from the view's result set.

Return value

string Returns a string for the link text.

Overrides Link::renderLink

File

src/Plugin/views/field/LinkDelete.php, line 33
Definition of Drupal\profile\Plugin\views\field\LinkDelete.

Class

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

Namespace

Drupal\profile\Plugin\views\field

Code

protected function renderLink($profile, ResultRow $values) {

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