PageLanguageInformationService
final readonly class \
Central service for gathering page language information.
This service provides the SINGLE source of truth for:
- Which languages exist (have translations)
- Which languages can be created (permissions + missing)
- Which languages are unavailable (no permission)
- Translation records with workspace overlay
- UI properties (labels, flags, icons)
Note: Languages marked as "Unavailable" are included in the result for potential future use (e.g., showing "No Access" indicators), but controllers currently filter them out before displaying the UI.
Internal
Table of Contents
Methods
- __construct() : mixed
- getLanguageInformationForPage() : PageLanguageInformation
- Get complete language information for a page.
- getOrphanedLanguageIds() : int[]
- Get the languages of records on the page which cannot be selected in the language menu, because the page has no translation into them or the site does not configure them. Languages the user has no access to are left out. The root level has no page translations and is therefore not checked.
- getOrphanedLanguageMessage() : string
- Describe orphaned languages for editors: the titles of site languages the page has not been translated into, and a general note for languages the site does not configure, whose IDs carry no meaning for editors.
Methods
__construct()
public
__construct(TcaSchemaFactory $tcaSchemaFactory, ConnectionPool $connectionPool, FrontendInterface $runtimeCache) : mixed
Parameters
- $tcaSchemaFactory : TcaSchemaFactory
- $connectionPool : ConnectionPool
- $runtimeCache : FrontendInterface
getLanguageInformationForPage()
Get complete language information for a page.
public
getLanguageInformationForPage(int $pageId, SiteInterface $site, BackendUserAuthentication $backendUser) : PageLanguageInformation
This method fetches and analyzes all language-related data for a page, including existing translations, permissions, and available languages.
Parameters
- $pageId : int
- $site : SiteInterface
- $backendUser : BackendUserAuthentication
Return values
PageLanguageInformationgetOrphanedLanguageIds()
Get the languages of records on the page which cannot be selected in the language menu, because the page has no translation into them or the site does not configure them. Languages the user has no access to are left out. The root level has no page translations and is therefore not checked.
public
getOrphanedLanguageIds(PageLanguageInformation $languageInformation, BackendUserAuthentication $backendUser) : int[]
Not part of getLanguageInformationForPage(), since it queries every language-aware table and only the modules listing these records need it.
Parameters
- $languageInformation : PageLanguageInformation
- $backendUser : BackendUserAuthentication
Return values
int[] —Sorted language IDs
getOrphanedLanguageMessage()
Describe orphaned languages for editors: the titles of site languages the page has not been translated into, and a general note for languages the site does not configure, whose IDs carry no meaning for editors.
public
getOrphanedLanguageMessage(PageLanguageInformation $languageInformation, int[] $orphanedLanguageIds, LanguageService $languageService) : string
Parameters
- $languageInformation : PageLanguageInformation
- $orphanedLanguageIds : int[]
- $languageService : LanguageService