PageContext
Generic page context for all backend modules working with pages ("id" parameter and page-tree navigation component).
This context is added to the backend request by the PSR-15 "PageContextInitialization" middleware. Replaces the module-specific duplication of language handling, page information, and site context.
Contains shared data needed across Page Module, List Module, etc. Does NOT contain module-specific rendering configuration.
This is a DOMAIN object and should NOT contain HTTP infrastructure concerns like ServerRequestInterface.
Access Handling: If the user has no access to the requested page, pageId and pageRecord will be null. Controllers should check $pageContext->isAccessible() before processing.
Usage: $pageContext = $request->getAttribute('pageContext'); if (!$pageContext->isAccessible()) { // Show no access page return $view->renderResponse('NoAccess'); } $selectedLanguages = $pageContext->selectedLanguageIds; $languageInfo = $pageContext->languageInformation; $rootLine = $pageContext->rootLine; $pageTsConfig = $pageContext->pageTsConfig; $moduleTsConfig = $pageContext->getModuleTsConfig('web_layout');
Table of Contents
Properties
- $languageInformation : PageLanguageInformation
- $pageId : int|null
- $pagePermissions : Permission
- $pageRecord : array<string|int, mixed>|null
- $pageTsConfig : array<string|int, mixed>
- $rootLine : array<string|int, mixed>
- $selectedLanguageIds : array<string|int, mixed>
- $site : SiteInterface
Methods
- __construct() : mixed
- getModuleTsConfig() : array<string|int, mixed>
- This is a convenience method to easily access mod.{module}.* configuration.
- getPageTitle() : string
- Get page title (localized if translation exists).
- getPrimaryLanguageId() : int
- Get primary (first) selected language.
- hasMultipleLanguagesSelected() : bool
- Check if multiple languages are currently selected.
- isAccessible() : bool
- Check if user has access to the page.
- isDefaultLanguageSelected() : bool
- isLanguageSelected() : bool
Properties
$languageInformation
public
PageLanguageInformation
$languageInformation
$pageId
public
int|null
$pageId
$pagePermissions
public
Permission
$pagePermissions
$pageRecord
public
array<string|int, mixed>|null
$pageRecord
$pageTsConfig
public
array<string|int, mixed>
$pageTsConfig
$rootLine
public
array<string|int, mixed>
$rootLine
$selectedLanguageIds
public
array<string|int, mixed>
$selectedLanguageIds
$site
public
SiteInterface
$site
Methods
__construct()
public
__construct(int|null $pageId, array<string|int, mixed>|null $pageRecord, SiteInterface $site, array<string|int, mixed> $rootLine, array<string|int, mixed> $pageTsConfig, array<string|int, int> $selectedLanguageIds, PageLanguageInformation $languageInformation, Permission $pagePermissions) : mixed
Parameters
- $pageId : int|null
-
Page ID (null if user has no access to requested page)
- $pageRecord : array<string|int, mixed>|null
-
Page record from readPageAccess (null if no access)
- $site : SiteInterface
- $rootLine : array<string|int, mixed>
-
Page rootline including the page itself (empty array if no access)
- $pageTsConfig : array<string|int, mixed>
-
PageTSconfig array (dots removed, overlaid by user permissions, falls back to page 0 if no access)
- $selectedLanguageIds : array<string|int, int>
-
Selected language IDs (resolved and validated)
- $languageInformation : PageLanguageInformation
-
Complete language information for this page
- $pagePermissions : Permission
-
User's permissions for this page (calculated from backendUser->calcPerms)
getModuleTsConfig()
This is a convenience method to easily access mod.{module}.* configuration.
public
getModuleTsConfig(string $module) : array<string|int, mixed>
Parameters
- $module : string
Return values
array<string|int, mixed>getPageTitle()
Get page title (localized if translation exists).
public
getPageTitle([int|null $languageId = null ]) : string
Parameters
- $languageId : int|null = null
-
Language ID (null = primary selected language)
Return values
stringgetPrimaryLanguageId()
Get primary (first) selected language.
public
getPrimaryLanguageId() : int
This is useful for operations that need a single language, like "View webpage" button or editing the page title.
Return values
int —Primary language ID (first in selection)
hasMultipleLanguagesSelected()
Check if multiple languages are currently selected.
public
hasMultipleLanguagesSelected() : bool
This is useful for determining if comparison/multi-column view should be shown.
Return values
boolisAccessible()
Check if user has access to the page.
public
isAccessible() : bool
Returns false if user has no access to the requested page. Controllers should check this before processing page-specific operations.
Return values
boolisDefaultLanguageSelected()
public
isDefaultLanguageSelected() : bool
Return values
boolisLanguageSelected()
public
isLanguageSelected(int $languageId) : bool
Parameters
- $languageId : int