public function GathercontentContentLink::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/ GathercontentContentLink.php, line 33
Class
- GathercontentContentLink
- A handler to provide a field that is completely custom by the administrator.
Namespace
Drupal\gathercontent\Plugin\views\fieldCode
public function render(ResultRow $values) {
$gc_id = $this
->getValue($values, 'gc_id');
if (is_numeric($gc_id)) {
$base_url = 'https://' . \Drupal::config('gathercontent.settings')
->get('gathercontent_urlkey') . '.gathercontent.com/item/';
$url = Url::fromUri($base_url . $gc_id);
return Link::fromTextAndUrl($this
->t('Open'), $url)
->toRenderable();
}
else {
return $this
->t('Not available');
}
}