You are here

public function HtmlFormatterTrait::getLinkedValue in HTML Formatter 8

If the field formatter is set to link to content, add a link.

Parameters

array $settings: Settings array.

string $value: The value that will be printed.

string $url: The url to the content.

Return value

string $value The value that will be printed.

3 calls to HtmlFormatterTrait::getLinkedValue()
HtmlFieldFormatter::viewElements in src/Plugin/Field/FieldFormatter/HtmlFieldFormatter.php
Builds a renderable array for a field value.
HtmlFieldFormatterDateTime::viewElements in src/Plugin/Field/FieldFormatter/HtmlFieldFormatterDateTime.php
Builds a renderable array for a field value.
HtmlFieldFormatterTimestamp::viewElements in src/Plugin/Field/FieldFormatter/HtmlFieldFormatterTimestamp.php
Builds a renderable array for a field value.

File

src/Plugin/HtmlFormatterTrait.php, line 113

Class

HtmlFormatterTrait

Namespace

Drupal\html_formatter\Plugin

Code

public function getLinkedValue($settings, $value, $url = '') {
  if ($settings['link'] && $url) {
    $value = [
      '#theme' => 'link_formatter_link_separate',
      '#url_title' => $value,
      '#url' => $url,
    ];
  }
  return $value;
}