src/Sulu/Component/Content/Document/Subscriber/FallbackLocalizationSubscriber.php
public function getAvailableLocalization(StructureBehavior $document, $locale)
    {
        $availableLocales = $this->inspector->getLocales($document);

        if (in_array($locale, $availableLocales)) {
            return $locale;
        }

        $fallbackLocale = null;

        if ($document instanceof WebspaceBehavior) {
            $fallbackLocale = $this->localizationFinder->findAvailableLocale(
                $this->inspector->getWebspace($document),
                $availableLocales,
                $locale
            );
        }

        if (!$fallbackLocale) {
            $fallbackLocale = reset($availableLocales);
        }

        if (!$fallbackLocale) {
            $fallbackLocale = $this->documentRegistry->getDefaultLocale();
        }

        return $fallbackLocale;
    }
public function getAvailableLocalization(StructureBehavior $document, $locale)
    {
        $availableLocales = $this->inspector->getLocales($document);

        if (in_array($locale, $availableLocales)) {
            return $locale;
        }

        $fallbackLocale = null;

        if ($document instanceof WebspaceBehavior) {
            $fallbackLocale = $this->localizationFinder->findAvailableLocale(
                $this->inspector->getWebspace($document),
                $availableLocales,
                $locale
            );
        }

        if (!$fallbackLocale) {
            $fallbackLocale = reset($availableLocales);
        }

        if (!$fallbackLocale) {
            $fallbackLocale = $this->documentRegistry->getDefaultLocale();
        }

        return $fallbackLocale;
    }
public function getAvailableLocalization ( StructureBehavior $ document , $ locale ) { $ availableLocales = $ this -> inspector -> getLocales ( $ document ) ; if ( in_array ( $ locale , $ availableLocales ) ) { return $ locale ; } $ fallbackLocale = null ; if ( $ document instanceof WebspaceBehavior ) { $ fallbackLocale = $ this -> localizationFinder -> findAvailableLocale ( $ this -> inspector -> getWebspace ( $ document ) , $ availableLocales , $ locale ) ; } if ( ! $ fallbackLocale ) { $ fallbackLocale = reset ( $ availableLocales ) ; } if ( ! $ fallbackLocale ) { $ fallbackLocale = $ this -> documentRegistry -> getDefaultLocale ( ) ; } return $ fallbackLocale ; }
Return available localizations.

@param StructureBehavior $document
@param string $locale

@return string
Return available localizations .