BeforeTypoLinkEncodedEvent

New in version 13.0

The PSR-14 event \TYPO3\CMS\Core\LinkHandling\Event\BeforeTypoLinkEncodedEvent allows developers to fully manipulate the encoding 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\BeforeTypoLinkEncodedEvent;

#[AsEventListener(
    identifier: 'my-extension/before-typolink-encoded',
)]
final readonly class MyEventListener
{
    public function __invoke(BeforeTypoLinkEncodedEvent $event): void
    {
        $typoLinkParameters = $event->getParameters();

        if (str_contains($typoLinkParameters['class'] ?? '', 'foo')) {
            $typoLinkParameters['class'] .= ' bar';
            $event->setParameters($typoLinkParameters);
        }
    }
}
Copied!

New in version 13.0

API

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

Listeners are able to modify the to be encoded TypoLink parameters

getParameters ( )
Returns
array
setParameters ( array $parameters)
param $parameters

the parameters

getTypoLinkParts ( )
Returns
array
getDelimiter ( )
Returns
string
getEmptyValueSymbol ( )
Returns
string