CoolCMS API

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:

  1. the page language translation, if it exists and has activeTranslation = 1,
  2. otherwise the default (localization) language translation, if it exists and is active,
  3. 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|null

isActive()

private static isActive(object $translation) : bool
Parameters
$translation : object
Return values
bool

toInt()

private static toInt(int|string|null $value) : int|null
Parameters
$value : int|string|null
Return values
int|null
On this page

Search results