You are here

public function GathercontentContentLink::render in GatherContent 8.4

Same name and namespace in other branches
  1. 8.5 gathercontent_ui/src/Plugin/views/field/GathercontentContentLink.php \Drupal\gathercontent_ui\Plugin\views\field\GathercontentContentLink::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/GathercontentContentLink.php, line 33

Class

GathercontentContentLink
A handler to provide a field that is completely custom by the administrator.

Namespace

Drupal\gathercontent_ui\Plugin\views\field

Code

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');
  }
}