AfterLinkResolvedByStringRepresentationEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Core\LinkHandling\Event\AfterLinkResolvedByStringRepresentationEvent is being dispatched after the \TYPO3\CMS\Core\LinkHandling\LinkService 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.

Example

EXT:my_extension/Classes/LinkHandling/EventListener/MyEventListener.php
<?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',
            ]);
        }
    }
}
Copied!

New in version 13.0

API

class AfterLinkResolvedByStringRepresentationEvent
Fully qualified name
\TYPO3\CMS\Core\LinkHandling\Event\AfterLinkResolvedByStringRepresentationEvent

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