src/Sulu/Component/Content/Compat/LocalizationFinder.php
private function findAvailableChildLocalization(array $availableLocales, Localization $localization)
    {
        $childrenLocalizations = $localization->getChildren();

        if (!empty($childrenLocalizations)) {
            foreach ($childrenLocalizations as $childrenLocalization) {
                // return the localization if a translation exists in the child localization
                if (in_array($childrenLocalization->getLocale(), $availableLocales)) {
                    return $childrenLocalization;
                }

                // recursively call this function for checking children
                return $this->findAvailableChildLocalization($availableLocales, $childrenLocalization);
            }
        }

        // return null if nothing was found
        return;
    }
private function findAvailableChildLocalization(array $availableLocales, Localization $localization)
    {
        $childrenLocalizations = $localization->getChildren();

        if (!empty($childrenLocalizations)) {
            foreach ($childrenLocalizations as $childrenLocalization) {
                // return the localization if a translation exists in the child localization
                if (in_array($childrenLocalization->getLocale(), $availableLocales)) {
                    return $childrenLocalization;
                }

                // recursively call this function for checking children
                return $this->findAvailableChildLocalization($availableLocales, $childrenLocalization);
            }
        }

        // return null if nothing was found
        return;
    }
private function findAvailableChildLocalization ( array $ availableLocales , Localization $ localization ) { $ childrenLocalizations = $ localization -> getChildren ( ) ; if ( ! empty ( $ childrenLocalizations ) ) { foreach ( $ childrenLocalizations as $ childrenLocalization ) { // return the localization if a translation exists in the child localization if ( in_array ( $ childrenLocalization -> getLocale ( ) , $ availableLocales ) ) { return $ childrenLocalization ; } // recursively call this function for checking children return $ this -> findAvailableChildLocalization ( $ availableLocales , $ childrenLocalization ) ; } } // return null if nothing was found return ; }
Finds the next available child-localization in which the node has a translation.

@param string[] $availableLocales
@param Localization $localization The localization to start the search for

@return null|Localization
Finds the next available child - localization in which the node has a translation .