private function getLanguage($language, $defaultLanguage = null)
    {
        $languageEntity = null;
        if ($language !== null && $language !== '') {
            if ($language instanceof \Newscoop\Entity\Language) {
                $languageEntity = $language;
            } elseif (strpos($language, '-') !== false && count($language) === 2) {
                $languageEntity = $this
                    ->em->getRepository('\Newscoop\Entity\Language')
                    ->findByCode($language);
            } else {
                try {
                    $languageEntity = $this
                        ->em->getRepository('\Newscoop\Entity\Language')
                        ->findByRFC3066bis($language);
                } catch(Exception $e) {
                    $languageEntity = null;
                    $this->logger->info(__METHOD__ . ': Language for entry could not be found. Reverting to default language.');
                }
            }
        }

        // Use default language if no language is set or if the found
        // languages are not allowed in our selected languages
        if (!in_array($languageEntity, $this->allowedLanguages)) {
            $languageEntity = $defaultLanguage;
        }

        return $languageEntity;
    }
private function getLanguage($language, $defaultLanguage = null)
    {
        $languageEntity = null;
        if ($language !== null && $language !== '') {
            if ($language instanceof \Newscoop\Entity\Language) {
                $languageEntity = $language;
            } elseif (strpos($language, '-') !== false && count($language) === 2) {
                $languageEntity = $this
                    ->em->getRepository('\Newscoop\Entity\Language')
                    ->findByCode($language);
            } else {
                try {
                    $languageEntity = $this
                        ->em->getRepository('\Newscoop\Entity\Language')
                        ->findByRFC3066bis($language);
                } catch(Exception $e) {
                    $languageEntity = null;
                    $this->logger->info(__METHOD__ . ': Language for entry could not be found. Reverting to default language.');
                }
            }
        }

        // Use default language if no language is set or if the found
        // languages are not allowed in our selected languages
        if (!in_array($languageEntity, $this->allowedLanguages)) {
            $languageEntity = $defaultLanguage;
        }

        return $languageEntity;
    }
private function getLanguage ( $ language , $ defaultLanguage = null ) { $ languageEntity = null ; if ( $ language !== null && $ language !== '' ) { if ( $ language instanceof \ Newscoop \ Entity \ Language ) { $ languageEntity = $ language ; } elseif ( strpos ( $ language , '-' ) !== false && count ( $ language ) === 2 ) { $ languageEntity = $ this -> em -> getRepository ( '\Newscoop\Entity\Language' ) -> findByCode ( $ language ) ; } else { try { $ languageEntity = $ this -> em -> getRepository ( '\Newscoop\Entity\Language' ) -> findByRFC3066bis ( $ language ) ; } catch ( Exception $ e ) { $ languageEntity = null ; $ this -> logger -> info ( __METHOD__ . ': Language for entry could not be found. Reverting to default language.' ) ; } } } // Use default language if no language is set or if the found // languages are not allowed in our selected languages if ( ! in_array ( $ languageEntity , $ this -> allowedLanguages ) ) { $ languageEntity = $ defaultLanguage ; } return $ languageEntity ; }
Gets a language based on the language parameter. Accepts multiple

@param \Newscoop\Entity\Language|string $language        Language which needs to be found
@param \Newscoop\Entity\Language|null   $defaultLanguage Fallback language

@return \Newscoop\Entity\Language|null                    Returns language entity or null if not found
Gets a language based on the language parameter . Accepts multiple