MetaModels\Attribute\Base::getLangValue PHP Method

getLangValue() protected method

If the language is not contained within the value array, the fallback language from the parenting {@link IMetaModel} instance is tried as well.
protected getLangValue ( array $arrValues, string $strLangCode = null ) : mixed | null
$arrValues array The array holding all language values in the form array('langcode' => $varValue).
$strLangCode string The language code of the language to fetch. Optional, if not given, $GLOBALS['TL_LANGUAGE'] is used.
return mixed | null the value for the given language or the fallback language, NULL if neither is present.
    protected function getLangValue($arrValues, $strLangCode = null)
    {
        if (!($this->getMetaModel()->isTranslated() && is_array($arrValues))) {
            return $arrValues;
        }
        if ($strLangCode === null) {
            return $this->getLangValue($arrValues, $this->getMetaModel()->getActiveLanguage());
        }
        if (array_key_exists($strLangCode, $arrValues)) {
            return $arrValues[$strLangCode];
        }
        // Language code not set, use fallback.
        return $arrValues[$this->getMetaModel()->getFallbackLanguage()];
    }