protected function MoreInfoTrait::moreInfo in Markdown 8.2
Appends existing content with a "More Info" link.
Parameters
mixed $existing: The existing content to append to.
string|\Drupal\Core\Url $url: The URL to use.
string $label: Optional. The "More Info" label to use for the link.
Return value
\Drupal\Component\Render\MarkupInterface The new joined content.
7 calls to MoreInfoTrait::moreInfo()
- BaseParser::renderStrategyDisabledSetting in src/
Plugin/ Markdown/ BaseParser.php - A description explaining why a setting is disabled due to render strategy.
- FilterMarkdown::processSubform in src/
Plugin/ Filter/ FilterMarkdown.php - Process callback for constructing markdown settings for this filter.
- FilterMarkdown::tips in src/
Plugin/ Filter/ FilterMarkdown.php - Generates a filter's tip.
- FootnoteExtension::buildConfigurationForm in src/
Plugin/ Markdown/ CommonMark/ Extension/ FootnoteExtension.php - Form constructor.
- FootnoteExtension::validateConfigurationForm in src/
Plugin/ Markdown/ CommonMark/ Extension/ FootnoteExtension.php - Form validation handler.
File
- src/
Traits/ MoreInfoTrait.php, line 32
Class
- MoreInfoTrait
- Trait for appending content with "[More Info]" links.
Namespace
Drupal\markdown\TraitsCode
protected function moreInfo($existing, $url, $label = 'More Info') {
if (!$url) {
return $existing;
}
if (!$url instanceof Url) {
$url = UrlHelper::isExternal($url) ? Url::fromUri($url)
->setOption('attributes', [
'target' => '_blank',
]) : Url::fromUserInput($url);
}
if (!$label instanceof MarkupInterface) {
$label = $this
->t($label);
// phpcs:ignore
}
$build = [
'#type' => 'link',
'#title' => new FormattableMarkup('[@label]', [
'@label' => $label,
]),
'#url' => $url,
'#options' => [
'attributes' => [
'class' => [
'installable-more-info',
],
'title' => $label,
],
],
'#prefix' => ' ',
];
$moreInfo = $this
->renderer()
->renderPlain($build);
if (empty($existing) || empty(trim($existing))) {
return $moreInfo;
}
return new FormattableMarkup('@existing @moreInfo', [
'@existing' => $existing,
'@moreInfo' => $moreInfo,
]);
}