Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\TermLanguageFallbackChain Class Reference

FIXME: this class is not a language fallback chain. More...

Public Member Functions

 __construct (array $chain, ContentLanguages $termLanguages)
 
 getFallbackChain ()
 Get raw fallback chain as an array.
 
 getFetchLanguageCodes ()
 Return language codes to use when fetching entries from the database.
 
 extractPreferredValue (array $data)
 Try to fetch the best value in a multilingual data array.
 
 extractPreferredValueOrAny (array $data)
 Try to fetch the best value in a multilingual data array first.
 

Private Member Functions

 getValueArray ( $value, string $languageCode, ?string $sourceLanguageCode=null)
 

Private Attributes

 $chain
 

Detailed Description

FIXME: this class is not a language fallback chain.

It takes and uses a fallback chain. The name thus needs to be updated to not be misleading.

Author
Liangent < liang.nosp@m.ent@.nosp@m.gmail.nosp@m..com >
Thiemo Kreuz

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\TermLanguageFallbackChain::__construct ( array $chain,
ContentLanguages $termLanguages )
Parameters
LanguageWithConversion[]$chain
ContentLanguages | null$termLanguagesPhanTypeMismatchDeclaredParam

Member Function Documentation

◆ extractPreferredValue()

Wikibase\Lib\TermLanguageFallbackChain::extractPreferredValue ( array $data)

Try to fetch the best value in a multilingual data array.

Parameters
string[] | array[]$dataMultilingual data with language codes as keys
Exceptions
InvalidArgumentException
Returns
string[]|null of three items: array( 'value' => finally fetched and translated value 'language' => language code of the language which final value is in 'source' => language code of the language where the value is translated from ), or null when no "acceptable" data can be found.

◆ extractPreferredValueOrAny()

Wikibase\Lib\TermLanguageFallbackChain::extractPreferredValueOrAny ( array $data)

Try to fetch the best value in a multilingual data array first.

If no "acceptable" value exists, return any value known.

Parameters
string[] | array[]$dataMultilingual data with language codes as keys
Returns
string[]|null of three items: array( 'value' => finally fetched and translated value 'language' => language code of the language which final value is in 'source' => language code of the language where the value is translated from ), or null when no data with a valid language code can be found.

◆ getFallbackChain()

Wikibase\Lib\TermLanguageFallbackChain::getFallbackChain ( )

Get raw fallback chain as an array.

Semi-private for testing.

Returns
LanguageWithConversion[]

◆ getFetchLanguageCodes()

Wikibase\Lib\TermLanguageFallbackChain::getFetchLanguageCodes ( )

Return language codes to use when fetching entries from the database.

See also
LanguageWithConversion::getFetchLanguageCode
Returns
string[]

◆ getValueArray()

Wikibase\Lib\TermLanguageFallbackChain::getValueArray ( $value,
string $languageCode,
?string $sourceLanguageCode = null )
private
Parameters
string | string[]$value
string$languageCode
string | null$sourceLanguageCode
Returns
string[]

Member Data Documentation

◆ $chain

Wikibase\Lib\TermLanguageFallbackChain::$chain
private

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