CoolCMS API

LocaleResolver
in package

Table of Contents

Properties

$initialized  : bool
$localeManager  : LocalizationManager
$localeToLanguageIdCache  : array<string, int>

Methods

__construct()  : mixed
clearCache()  : void
Clears the cache.
getLanguageIdByLocale()  : int|null
Converts a locale code to a language id.
warmupCache()  : void
Loads all locales with a single query.
warmupFromMap()  : void
Fills the cache from the precomputed map of {@see \App\Core\Routers\RouteTableSnapshot} and marks the resolver initialized (disables the lazy DB warmup and enables the negative lookup above).

Properties

$initialized

private bool $initialized = false

whether all locales have been loaded

$localeToLanguageIdCache

private array<string, int> $localeToLanguageIdCache = []

cache locale->languageId

Methods

getLanguageIdByLocale()

Converts a locale code to a language id.

public getLanguageIdByLocale(string $localeCode) : int|null
Parameters
$localeCode : string

locale code (cs, en, de, en-US, en-GB...)

Return values
int|null —

language id, or null when the locale does not exist

warmupCache()

Loads all locales with a single query.

public warmupCache() : void

warmupFromMap()

Fills the cache from the precomputed map of {@see \App\Core\Routers\RouteTableSnapshot} and marks the resolver initialized (disables the lazy DB warmup and enables the negative lookup above).

public warmupFromMap(array<string, int> $localeToLanguageId) : void
Parameters
$localeToLanguageId : array<string, int>

[locale] = languageId

On this page

Search results