ContentLockBreak.php in Content locking (anti-concurrent editing) 8
File
src/Plugin/views/field/ContentLockBreak.php
View source
<?php
namespace Drupal\content_lock\Plugin\views\field;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
class ContentLockBreak extends FieldPluginBase {
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();
}
public function render(ResultRow $values) {
$value = $this
->getValue($values);
return $this
->renderLink($this
->sanitizeValue($value), $values);
}
}