Final Class Yiisoft\I18n\LocaleProvider
| Inheritance | Yiisoft\I18n\LocaleProvider |
|---|
LocaleProvider is a stateful service that stores current locale.
Other services may use it as a dependency.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\I18n\LocaleProvider | |
| get() | Yiisoft\I18n\LocaleProvider | |
| isDefaultLocale() | Yiisoft\I18n\LocaleProvider | |
| set() | Yiisoft\I18n\LocaleProvider |
Method Details
| public mixed __construct ( Yiisoft\I18n\Locale $defaultLocale ) | ||
| $defaultLocale | Yiisoft\I18n\Locale | |
public function __construct(
private Locale $defaultLocale
) {
}
| public Yiisoft\I18n\Locale get ( ) |
public function get(): Locale
{
return $this->locale ?? $this->defaultLocale;
}
| public boolean isDefaultLocale ( ) |
public function isDefaultLocale(): bool
{
return $this->locale === null || $this->locale->asString() === $this->defaultLocale->asString();
}
| public void set ( Yiisoft\I18n\Locale $locale ) | ||
| $locale | Yiisoft\I18n\Locale | |
public function set(Locale $locale): void
{
$this->locale = $locale;
}
Signup or Login in order to comment.