public function ContentLink::render in GatherContent 8.4
Same name and namespace in other branches
- 8.5 gathercontent_ui/src/Plugin/views/field/ContentLink.php \Drupal\gathercontent_ui\Plugin\views\field\ContentLink::render()
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
- gathercontent_ui/
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_ui\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');
}
}