public function Builtin::buildLink in Freelinking 4.0.x
Same name and namespace in other branches
- 8.3 src/Plugin/freelinking/Builtin.php \Drupal\freelinking\Plugin\freelinking\Builtin::buildLink()
Build a link with the plugin.
Parameters
array $target: The target array with including the following keys:
- text: The text to display in the URL.
- indicator: The indicator string.
- dest: The destination string for the plugin to turn into a URI.
- tooltip: An optional tooltip.
- language: A language object.
Return value
array Link array.
Overrides FreelinkingPluginInterface::buildLink
File
- src/
Plugin/ freelinking/ Builtin.php, line 65
Class
- Builtin
- Freelinking builtin plugin.
Namespace
Drupal\freelinking\Plugin\freelinkingCode
public function buildLink(array $target) {
$text = '';
if ('showtext' === $target['indicator']) {
$text = $target['text'] ? $target['text'] : $target['dest'];
}
elseif ('nowiki' === $target['indicator']) {
$text .= '[[';
$text .= $target['text'] ? $target['text'] : $target['dest'];
$text .= ']]';
}
elseif ('redact' === $target['indicator']) {
if ($this->account
->isAuthenticated()) {
$text = $target['dest'];
}
else {
$text = $target['text'] ? $target['text'] : '******';
}
}
return [
'#markup' => $text,
];
}