Sends the missing PageUriGenerated PSR-14 event from the PageRouter
The core TYPO3
PageRouter doesn't offer the possibility to modify generated URLs. This extension replaces the
PageRouter->generateUri method and
dispatches a PSR-14 event to react to or modify generated URLs.
An issue for the TYPO3 core has been created on forge: #92780. This extension is meant as an intermediate solution and becomes obsolete as soon as the core PageRouter offers such an event.
composer req smic/page-router-event dev-master
Register an event listener in the
services: Vendor\MyExt\EventListener\ReactToGeneratedUri: tags: - name: event.listener identifier: 'MyExtReactToGeneratedUri' event: Smic\PageRouterEvent\Event\PageUriGenerated
Your event listener receives a
Smic\PageRouterEvent\Event\PageUriGenerated event that offers:
- getters for input data that were used to generate the URL
- a getter for the generated URI
- the PageRouter itself
- and a setter to replace the generated URI
If you're not familiar with PSR-14 event handling in TYPO3 have a look at: https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ApiOverview/Hooks/EventDispatcher/Index.html