You are here

protected function ContentLockBreak::renderLink in Content locking (anti-concurrent editing) 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/ContentLockBreak.php \Drupal\content_lock\Plugin\views\field\ContentLockBreak::renderLink()

Prepares link to the file.

Parameters

string $data: The XSS safe string for the link text.

\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.

Return value

string Returns a string for the link text.

1 call to ContentLockBreak::renderLink()
ContentLockBreak::render in src/Plugin/views/field/ContentLockBreak.php
Renders the field.

File

src/Plugin/views/field/ContentLockBreak.php, line 30

Class

ContentLockBreak
Field handler to present a link to an entity.

Namespace

Drupal\content_lock\Plugin\views\field

Code

protected function renderLink($data, ResultRow $values) {
  $entity = $this
    ->getEntity($values);
  $url = Url::fromRoute('content_lock.break_lock.' . $entity
    ->getEntityTypeId(), [
    'entity' => $entity
      ->id(),
    'langcode' => $entity
      ->language()
      ->getId(),
    'form_op' => isset($values->content_lock_form_op) ? $values->content_lock_form_op : '*',
  ]);
  $break_link = Link::fromTextAndUrl('Break lock', $url);
  return $break_link
    ->toString();
}