AfterLinkResolvedByStringRepresentationEvent¶
New in version 13.0
This event has been introduced as a more powerful replacement for the
removed hook
$GLOBALS
.
The PSR-14 event \TYPO3\
is being dispatched after the \TYPO3\
has tried to resolve a given t3://
URN using
defined link handlers.
The event can not only be used to resolve custom link types, but also to modify
the link result data of existing link handlers. Additionally, it can be used to
resolve situations where no handler could be found for a t3://
URN.
Note
The event is always dispatched, even if a handler successfully resolved
the URN and also even in cases, TYPO3 would have thrown the
\TYPO3\
exception.
Example¶
<?php
declare(strict_types=1);
namespace MyVendor\MyExtension\LinkHandling\EventListener;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\LinkHandling\Event\AfterLinkResolvedByStringRepresentationEvent;
#[AsEventListener(
identifier: 'my-extension/after-link-resolved-by-string-representation',
)]
final readonly class MyEventListener
{
public function __invoke(AfterLinkResolvedByStringRepresentationEvent $event): void
{
if (str_contains($event->getUrn(), 'myhandler://123')) {
$event->setResult([
'type' => 'my-type',
]);
}
}
}
New in version 13.0
The PHP attribute \TYPO3\
has been
introduced to tag a PHP class as an event listener. Alternatively, you can also
register an event listener via the Configuration/
file. Have
a look into the section Implementing an event listener in your extension.
API¶
- class AfterLinkResolvedByStringRepresentationEvent ¶
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Link Handling\ Event\ After Link Resolved By String Representation Event
Listeners are able to modify the resolved link result data
- getResult ( ) ¶
-
- Returns
-
array
- setResult ( array $result) ¶
-
- param $result
-
the result
- getUrn ( ) ¶
-
- Returns
-
string
- getResolveException ( ) ¶
-
- Returns
-
?\
TYPO3\ CMS\ Core\ Exception