class LocalizedResource

A LocalizedResource can store information for multiple locales. The methods in this base class allow switching between the locales.

Properties

protected string[] $availableLocales List of codes for all the locales available in the space this resource belongs to.

Methods

__construct(array $availableLocales)

LocalizedResource constructor.

$this
setLocale(Locale|string $locale)

Set the locale for this instance. All future calls to a getter will return the information for this locale.

string
getLocale()

The locale code for the currently set locale.

string
getLocaleFromInput(Locale|string|null $input = null)

No description

string|null
loopThroughFallbackChain(array $valueMap, string $localeCode, Space $space)

No description

Details

at line 36
__construct(array $availableLocales)

LocalizedResource constructor.

Parameters

array $availableLocales the locales available in the space this resource belongs to

at line 55
$this setLocale(Locale|string $locale)

Set the locale for this instance. All future calls to a getter will return the information for this locale.

Parameters

Locale|string $locale the locale code as string or an instance of Locale

Return Value

$this

Exceptions

InvalidArgumentException when $locale is not one of the locales supported by the space

at line 75
string getLocale()

The locale code for the currently set locale.

Return Value

string

at line 87
protected string getLocaleFromInput(Locale|string|null $input = null)

Parameters

Locale|string|null $input

Return Value

string

Exceptions

InvalidArgumentException when $locale is not one of the locales supported by the space

at line 113
protected string|null loopThroughFallbackChain(array $valueMap, string $localeCode, Space $space)

Parameters

array $valueMap
string $localeCode
Space $space

Return Value

string|null The locale code for which a value can be found. null if the end of the chain has been reached.

Exceptions

RuntimeException If we detect an endless loop