Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter Class Reference

Utility class to format entity links with labels for usage in hooks. More...

+ Inheritance diagram for Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter:
+ Collaboration diagram for Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter:

Public Member Functions

 __construct (Language $pageLanguage, EntityTitleTextLookup $entityTitleTextLookup, LanguageFactory $languageFactory)
 
 getFragment (EntityId $entityId, $fragment)
 Optionally update the fragment of the link.
 
- Public Member Functions inherited from Wikibase\Repo\Hooks\Formatters\EntityLinkFormatter
 getHtml (EntityId $entityId, ?array $labelData=null)
 Produce link HTML from Entity ID and label data.
 
 getTitleAttribute (EntityId $entityId, ?array $labelData=null, ?array $descriptionData=null)
 Get "title" attribute for Wikidata entity link.
 

Private Member Functions

 extractTextAndLanguage (?array $termData)
 

Private Attributes

 $pageLanguage
 
 $entityTitleTextLookup
 
 $languageFactory
 

Detailed Description

Utility class to format entity links with labels for usage in hooks.

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::__construct ( Language $pageLanguage,
EntityTitleTextLookup $entityTitleTextLookup,
LanguageFactory $languageFactory )

Member Function Documentation

◆ extractTextAndLanguage()

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::extractTextAndLanguage ( ?array $termData)
private
Parameters
string[] | null$termDataA term record as returned by TermLanguageFallbackChain::extractPreferredValueOrAny(), containing the 'value' and 'language' fields, or null or an empty array.
See also
TermLanguageFallbackChain::extractPreferredValueOrAny
Returns
array list( string $text, Language $language )

◆ getFragment()

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::getFragment ( EntityId $entityId,
$fragment )

Optionally update the fragment of the link.

This is necessary for subentities, where the link points to a section of the parent entity’s page; if the anchor of that section changes (e.g. from including the parent entity ID to not including it), we want to update the fragment in old links to that entity accordingly. See T208423 for an example of this.

Parameters
EntityId$entityId
string$fragmentThe current fragment of the link, not including an initial '#'.
Returns
string The new fragment (or the same as $fragment), not including an initial '#'.

Implements Wikibase\Repo\Hooks\Formatters\EntityLinkFormatter.

Member Data Documentation

◆ $entityTitleTextLookup

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::$entityTitleTextLookup
private

◆ $languageFactory

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::$languageFactory
private

◆ $pageLanguage

Wikibase\Repo\Hooks\Formatters\DefaultEntityLinkFormatter::$pageLanguage
private

The documentation for this class was generated from the following file: