AfterTypoLinkDecodedEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Core\LinkHandling\Event\AfterTypoLinkDecodedEvent allows developers to fully manipulate the decoding of TypoLinks.

A common use case for extensions is to extend the TypoLink parts to allow editors adding additional information, for example, custom attributes can be inserted to the link markup.

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\AfterTypoLinkDecodedEvent;

#[AsEventListener(
    identifier: 'my-extension/after-typolink-decoded',
)]
final readonly class MyEventListener
{
    public function __invoke(AfterTypoLinkDecodedEvent $event): void
    {
        $typoLink = $event->getTypoLink();
        $typoLinkParts = $event->getTypoLinkParts();

        if (str_contains($typoLink, 'foo')) {
            $typoLinkParts['foo'] = 'bar';
            $event->setTypoLinkParts($typoLinkParts);
        }
    }
}
Copied!

New in version 13.0

API

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

Listeners are able to modify the decoded link parts of a TypoLink

getTypoLinkParts ( )
Returns
array
setTypoLinkParts ( array $typoLinkParts)
param $typoLinkParts

the typoLinkParts

Returns
string
getDelimiter ( )
Returns
string
getEmptyValueSymbol ( )
Returns
string