TranslationFallback
in package
FinalYes
Picks an entity translation with a fallback to the default language.
The rule of page sections (PageSection::resolveTranslation()), extracted for other content blocks (adverts). Order:
- the page language translation, if it exists and has
activeTranslation = 1, - otherwise the default (localization) language translation, if it exists and is active,
- otherwise
null, and the caller renders nothing (no foreign language fills in).
getTranslation() on the entity does not filter the activeTranslation flag, so it is
checked here. The entity needs getTranslation(int) (TranslationCollectionTrait), the
translation needs isActiveTranslation() (TranslationLanguageTrait).
Table of Contents
Methods
- resolve() : object|null
- isActive() : bool
- toInt() : int|null
Methods
resolve()
public
static resolve(object $entity, int|string|null $langId, int|string|null $defaultLangId) : object|null
Parameters
- $entity : object
- $langId : int|string|null
- $defaultLangId : int|string|null
Return values
object|nullisActive()
private
static isActive(object $translation) : bool
Parameters
- $translation : object
Return values
booltoInt()
private
static toInt(int|string|null $value) : int|null
Parameters
- $value : int|string|null