protected function getLanguagesPriority(array $languagesMap): array
    {
        $priority = [];
        $fallback = [];
        $siteAccesses = $this->configResolver->getParameter('list', 'ezpublish', 'siteaccess');

        foreach ($siteAccesses as $siteAccess) {
            $siteAccessLanguages = $this->configResolver->getParameter('languages', null, $siteAccess);
            $priority[] = array_shift($siteAccessLanguages);
            $fallback = array_merge($fallback, $siteAccessLanguages);
        }

        // Append fallback languages at the end of priority language list
        $languageCodes = array_unique(array_merge($priority, $fallback));

        $languages = array_filter(array_values($languageCodes), function ($languageCode) use ($languagesMap) {
            // Get only Languages defined and enabled in Admin
            return isset($languagesMap[$languageCode]) && $languagesMap[$languageCode]['enabled'];
        });

        // Languages that are not configured in any of SiteAccess but user is still able to create content
        $unused = array_diff(array_keys($languagesMap), $languages);

        return array_merge($languages, $unused);
    }
protected function getLanguagesPriority(array $languagesMap): array
    {
        $priority = [];
        $fallback = [];
        $siteAccesses = $this->configResolver->getParameter('list', 'ezpublish', 'siteaccess');

        foreach ($siteAccesses as $siteAccess) {
            $siteAccessLanguages = $this->configResolver->getParameter('languages', null, $siteAccess);
            $priority[] = array_shift($siteAccessLanguages);
            $fallback = array_merge($fallback, $siteAccessLanguages);
        }

        // Append fallback languages at the end of priority language list
        $languageCodes = array_unique(array_merge($priority, $fallback));

        $languages = array_filter(array_values($languageCodes), function ($languageCode) use ($languagesMap) {
            // Get only Languages defined and enabled in Admin
            return isset($languagesMap[$languageCode]) && $languagesMap[$languageCode]['enabled'];
        });

        // Languages that are not configured in any of SiteAccess but user is still able to create content
        $unused = array_diff(array_keys($languagesMap), $languages);

        return array_merge($languages, $unused);
    }
protected function getLanguagesPriority ( array $ languagesMap ) : array { $ priority = [ ] ; $ fallback = [ ] ; $ siteAccesses = $ this -> configResolver -> getParameter ( 'list' , 'ezpublish' , 'siteaccess' ) ; foreach ( $ siteAccesses as $ siteAccess ) { $ siteAccessLanguages = $ this -> configResolver -> getParameter ( 'languages' , null , $ siteAccess ) ; $ priority [ ] = array_shift ( $ siteAccessLanguages ) ; $ fallback = array_merge ( $ fallback , $ siteAccessLanguages ) ; } // Append fallback languages at the end of priority language list $ languageCodes = array_unique ( array_merge ( $ priority , $ fallback ) ) ; $ languages = array_filter ( array_values ( $ languageCodes ) , function ( $ languageCode ) use ( $ languagesMap ) { // Get only Languages defined and enabled in Admin return isset ( $ languagesMap [ $ languageCode ] ) && $ languagesMap [ $ languageCode ] [ 'enabled' ] ; } ) ; // Languages that are not configured in any of SiteAccess but user is still able to create content $ unused = array_diff ( array_keys ( $ languagesMap ) , $ languages ) ; return array_merge ( $ languages , $ unused ) ; }
Returns list of languages in a prioritized form.

First: languages that are main of siteaccesses are displayed first.
Next: fallback languages of siteaccesses.
Last: languages defined but not used in siteaccesses.

@param array $languagesMap data from call to getLanguagesMap()

@return array
Returns list of languages in a prioritized form .