Feature: #102806 - BeforePageIsRetrievedEvent in PageRepository

See forge#102806


A new PSR-14 event \TYPO3\CMS\Core\Domain\Event\BeforePageIsRetrievedEvent has been introduced, which serves as a more powerful replacement of the removed $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'] hook.

The new event therefore allows to modify the resolving of page records within \TYPO3\CMS\Core\Domain\PageRepository->getPage().


The event can be used to alter the incoming page ID or to even fetch a fully loaded page object before the default TYPO3 behaviour is executed, effectively bypassing the default page resolving.

To modify the incoming parameters, the following methods are available:

  • setPageId(): Allows to set the $uid of a page to resolve
  • setPage(): Allows to set a Page object which bypasses TYPO3 Core functionality


The event listener class, using the PHP attribute #[AsEventListener] for registration:

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Domain\Event\BeforePageIsRetrievedEvent;

final class CustomPageResolverEventListener
    public function __invoke(BeforePageIsRetrievedEvent $event): void
        if ($event->getPageId() === 13) {
        } elseif ($event->getContext()->getPropertyFromAspect('language', 'id') > 0) {
            $event->setPage(new \TYPO3\CMS\Core\Domain\Page(['uid' => 43]));


Using the new PSR-14 event, it's now possible to fully customize the page resolving in TYPO3's Core API class \TYPO3\CMS\Core\Domain\PageRepository.