PageContextInitialization implements MiddlewareInterface
Read onlyYes
Initializes PageContext for backend modules that work with pages.
Creates a PageContext with resolved language information and stores it in the request attribute 'pageContext' for use by controllers.
This middleware only runs for modules that use the page tree navigation component ('@typo3/backend/tree/page-tree-element'). This includes modules like web_layout, records, and others under the 'content' parent, as well as standalone modules that explicitly set the navigation component.
The middleware:
- Checks if the module or any of its parents use the page tree component
- Extracts the page ID from request (query or body parameter 'id')
- Defaults to page ID 0 (NullSite/root level) if not found
- Creates PageContext with language resolution
If PageContext creation fails (e.g. no site found, no page access), the middleware logs a warning but continues without breaking the request, allowing controllers to handle the missing context or create it manually.
Table of Contents
Interfaces
- MiddlewareInterface
Properties
- $logger : LoggerInterface
- $pageContextFactory : PageContextFactory
Methods
- __construct() : mixed
- process() : ResponseInterface
Properties
$logger
protected
LoggerInterface
$logger
$pageContextFactory
protected
PageContextFactory
$pageContextFactory
Methods
__construct()
public
__construct(PageContextFactory $pageContextFactory, LoggerInterface $logger) : mixed
Parameters
- $pageContextFactory : PageContextFactory
- $logger : LoggerInterface
process()
public
process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
Parameters
- $request : ServerRequestInterface
- $handler : RequestHandlerInterface