class LinkThemeHooks
Theme hooks for link.
Hierarchy
- class \Drupal\link\Hook\LinkThemeHooks
Expanded class hierarchy of LinkThemeHooks
1 file declares its use of LinkThemeHooks
- link.module in core/
modules/ link/ link.module
File
-
core/
modules/ link/ src/ Hook/ LinkThemeHooks.php, line 11
Namespace
Drupal\link\HookView source
class LinkThemeHooks {
/**
* Implements hook_theme().
*/
public function theme() : array {
return [
'link_formatter_link_separate' => [
'variables' => [
'title' => NULL,
'url_title' => NULL,
'url' => NULL,
],
'initial preprocess' => static::class . ':preprocessLinkFormatterLinkSeparate',
],
];
}
/**
* Prepares variables for separated link field templates.
*
* This template outputs a separate title and link.
*
* Default template: link-formatter-link-separate.html.twig.
*
* @param array $variables
* An associative array containing:
* - title: (optional) A descriptive or alternate title for the link, which
* may be different than the actual link text.
* - url_title: The anchor text for the link.
* - url: A \Drupal\Core\Url object.
*/
public function preprocessLinkFormatterLinkSeparate(array &$variables) : void {
$variables['link'] = Link::fromTextAndUrl($variables['url_title'], $variables['url'])->toString();
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
LinkThemeHooks::preprocessLinkFormatterLinkSeparate | public | function | Prepares variables for separated link field templates. |
LinkThemeHooks::theme | public | function | Implements hook_theme(). |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.