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);
    }