AfterPagePreviewUriGeneratedEvent¶
New in version 12.0
This PSR-14 event replaces the
$GLOBALS
postProcess hook.
The \TYPO3\
is executed in \TYPO3\
, after the preview
URI has been built - or set by an event listener to
BeforePagePreviewUriGeneratedEvent. It allows to overwrite the built
preview URI. However, this event does not feature the possibility to modify the
parameters, since this will not have any effect, as the preview URI is directly
returned after event dispatching and no further action is done by the
\TYPO3\
.
Example¶
Registration of the event listener in the extension's Services.
:
services:
# Place here the default dependency injection configuration
MyVendor\MyExtension\Backend\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/backend/modify-preview-uri'
Read how to configure dependency injection in extensions.
The corresponding event listener class:
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\Backend\EventListener;
use TYPO3\CMS\Backend\Routing\Event\AfterPagePreviewUriGeneratedEvent;
final class MyEventListener
{
public function __invoke(AfterPagePreviewUriGeneratedEvent $event): void
{
// Add custom fragment to built preview URI
$uri = $event->getPreviewUri();
$uri = $uri->withFragment('#customFragment');
$event->setPreviewUri($uri);
}
}
API¶
- class AfterPagePreviewUriGeneratedEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Backend\ Routing\ Event\ After Page Preview Uri Generated Event
Listeners to this event will be able to modify the page preview URI, which had been generated for a page in the frontend.
- setPreviewUri ( \Psr\Http\Message\UriInterface $previewUri) ¶
-
- param $previewUri
-
the previewUri
- getPreviewUri ( ) ¶
-
- Returns
-
\Psr\
Http\ Message\ Uri Interface
- getPageId ( ) ¶
-
- Returns
-
int
- getLanguageId ( ) ¶
-
- Returns
-
int
- getRootline ( ) ¶
-
- Returns
-
array
- getSection ( ) ¶
-
- Returns
-
string
- getAdditionalQueryParameters ( ) ¶
-
- Returns
-
array
- getContext ( ) ¶
-
- Returns
-
\TYPO3\
CMS\ Core\ Context\ Context
- getOptions ( ) ¶
-
- Returns
-
array