class LocalizedResource extends BaseResource

A LocalizedResource can store information for multiple locales.

The methods in this base class allow switching between the locales.

Properties

protected Client $client from BaseResource
protected SystemProperties $sys from BaseResource
protected string[] $localeCodes List of codes for all the locales available in the space this resource belongs to.

Methods

__construct(array $data)

Resources in this SDK should not be built using $new Class().

asLink()

{@inheritdoc}

getId()

{@inheritdoc}

getType()

{@inheritdoc}

initLocales(array $locales)

No description

$this
setLocale(Locale|string $locale)

Set the locale for this instance.

string
getLocale()

The locale code for the currently set locale.

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

No description

string|null
walkFallbackChain(array $valueMap, string $localeCode, Environment $environment)

No description

Details

in BaseResource at line 36
protected __construct(array $data)

Resources in this SDK should not be built using $new Class().

This method is only useful in testing environments, where the resource needs to be subclasses and this method made public.

Parameters

array $data

in BaseResource at line 50
SystemProperties getSystemProperties()

{@inheritdoc}

Return Value

SystemProperties

{@inheritdoc}

in BaseResource at line 69
getId()

{@inheritdoc}

in BaseResource at line 77
getType()

{@inheritdoc}

at line 35
initLocales(array $locales)

Parameters

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

at line 58
$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

at line 70
string getLocale()

The locale code for the currently set locale.

Return Value

string

at line 82
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 121
protected string|null walkFallbackChain(array $valueMap, string $localeCode, Environment $environment)

Parameters

array $valueMap
string $localeCode
Environment $environment

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