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

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

Public Member Functions

 __construct (array $chain)
 
 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, $languageCode, $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\LanguageFallbackChain::__construct ( array  $chain)
Parameters
LanguageWithConversion[]$chain

Member Function Documentation

◆ extractPreferredValue()

Wikibase\Lib\LanguageFallbackChain::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\LanguageFallbackChain::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\LanguageFallbackChain::getFallbackChain ( )

Get raw fallback chain as an array.

Semi-private for testing.

Returns
LanguageWithConversion[]

◆ getFetchLanguageCodes()

Wikibase\Lib\LanguageFallbackChain::getFetchLanguageCodes ( )

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

See also
LanguageWithConversion::getFetchLanguageCode
Returns
string[]

◆ getValueArray()

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

Member Data Documentation

◆ $chain

Wikibase\Lib\LanguageFallbackChain::$chain
private

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