Wikibase
MediaWiki Wikibase extension
Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup Class Reference

This TermLookup allows exposes language based lookups for getLabel and getDescription and is backed by the shared TermFallbackCache which stores TermFallback objects. More...

+ Inheritance diagram for Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup:
+ Collaboration diagram for Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup:

Public Member Functions

 __construct (TermFallbackCacheFacade $termFallbackCacheFacade, RedirectResolvingLatestRevisionLookup $redirectResolvingLatestRevisionLookup, LanguageFallbackChainFactory $languageFallbackChainFactory, TermLookup $termLookup, LanguageFactory $languageFactory, ContentLanguages $contentLanguages)
 
 getLabel (EntityId $entityId, $languageCode)
 Gets the label of an Entity with the specified EntityId and language code. More...
 
 getDescription (EntityId $entityId, $languageCode)
 Gets the description of an Entity with the specified EntityId and language code. More...
 
 getLabels (EntityId $entityId, array $languageCodes)
 Gets all labels of an Entity with the specified EntityId. More...
 
 getDescriptions (EntityId $entityId, array $languageCodes)
 Gets all descriptions of an Entity with the specified EntityId. More...
 

Private Member Functions

 getTerm (EntityId $entityId, string $languageCode, string $termType)
 
 getLookup (Language $language)
 
 lookupWithoutCache (EntityId $entityId, Language $language, $termType)
 

Private Attributes

 $termFallbackCache
 
 $redirectResolvingLatestRevisionLookup
 
 $languageFallbackChainFactory
 
 $termLookup
 
 $languageFactory
 
 $contentLanguages
 
 $lookups
 

Detailed Description

This TermLookup allows exposes language based lookups for getLabel and getDescription and is backed by the shared TermFallbackCache which stores TermFallback objects.

The lookup tries to find the term in the cache and if not present builds a LanguageFallbackLabelDescriptionLookup based on the TermFallbackChain generated by the requested Language.

If the requested language does not match the actual language of the TermFallback this value will still be written to the cache but not returned.

If the TermFallback returns null this value will also be written to the cache as this means no term is available in the requested language.

See also
TermFallbackCacheFacade

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::__construct ( TermFallbackCacheFacade  $termFallbackCacheFacade,
RedirectResolvingLatestRevisionLookup  $redirectResolvingLatestRevisionLookup,
LanguageFallbackChainFactory  $languageFallbackChainFactory,
TermLookup  $termLookup,
LanguageFactory  $languageFactory,
ContentLanguages  $contentLanguages 
)

Member Function Documentation

◆ getDescription()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getDescription ( EntityId  $entityId,
  $languageCode 
)

Gets the description of an Entity with the specified EntityId and language code.

Since
2.0
Parameters
EntityId$entityId
string$languageCode
Exceptions
TermLookupExceptionfor entity not found
Returns
string|null

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getDescriptions()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getDescriptions ( EntityId  $entityId,
array  $languageCodes 
)

Gets all descriptions of an Entity with the specified EntityId.

If $languages is given, the result will contain the entries for the requested languages, if they exist.

Since
2.0
Parameters
EntityId$entityId
string[]$languageCodesThe list of languages to fetch
Exceptions
TermLookupExceptionif the entity was not found (not guaranteed).
Returns
string[] descriptions, keyed by language.

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getLabel()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getLabel ( EntityId  $entityId,
  $languageCode 
)

Gets the label of an Entity with the specified EntityId and language code.

Since
2.0
Parameters
EntityId$entityId
string$languageCode
Exceptions
TermLookupExceptionfor entity not found
Returns
string|null

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getLabels()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getLabels ( EntityId  $entityId,
array  $languageCodes 
)

Gets all labels of an Entity with the specified EntityId.

The result will contain the entries for the requested languages, if they exist.

Since
2.0
Parameters
EntityId$entityId
string[]$languageCodesThe list of languages to fetch
Exceptions
TermLookupExceptionif the entity was not found (not guaranteed).
Returns
string[] labels, keyed by language.

Implements Wikibase\DataModel\Services\Lookup\TermLookup.

◆ getLookup()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getLookup ( Language  $language)
private

◆ getTerm()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::getTerm ( EntityId  $entityId,
string  $languageCode,
string  $termType 
)
private

◆ lookupWithoutCache()

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::lookupWithoutCache ( EntityId  $entityId,
Language  $language,
  $termType 
)
private
Parameters
EntityId$entityId
Language$language
$termType
Returns
TermFallback|null

Member Data Documentation

◆ $contentLanguages

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$contentLanguages
private

◆ $languageFactory

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$languageFactory
private

◆ $languageFallbackChainFactory

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$languageFallbackChainFactory
private

◆ $lookups

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$lookups
private

◆ $redirectResolvingLatestRevisionLookup

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$redirectResolvingLatestRevisionLookup
private

◆ $termFallbackCache

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$termFallbackCache
private

◆ $termLookup

Wikibase\Client\DataAccess\Scribunto\CachingFallbackBasedTermLookup::$termLookup
private

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