public function ContentLink::render in GatherContent 8.3
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides Path::render
File
- src/
Plugin/ views/ field/ ContentLink.php, line 22
Class
- ContentLink
- A handler to provide a field that is completely custom by the administrator.
Namespace
Drupal\gathercontent\Plugin\views\fieldCode
public function render(ResultRow $values) {
$nid = $this
->getValue($values, 'nid');
if (is_numeric($nid)) {
$url = Url::fromRoute('entity.node.canonical', [
'node' => $nid,
], [
'absolute' => $this->options['absolute'],
]);
return Link::fromTextAndUrl($this
->t('Open'), $url)
->toRenderable();
}
else {
return $this
->t('Not available');
}
}