‪TYPO3CMS  ‪main
TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent Class Reference

Public Member Functions

 __construct (private readonly ServerRequestInterface $request)
 
 getHrefLangs ()
 
 getRequest ()
 
 setHrefLangs (array $hrefLangs)
 
 addHrefLang (string $languageCode, string $url)
 

Private Attributes

array $hrefLangs = []
 

Detailed Description

Listeners to this event will be able to modify the hreflang tags that will be generated. You can use this when you have an edge case language scenario and need to alter the default hreflang tags.

Definition at line 26 of file ModifyHrefLangTagsEvent.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::__construct ( private readonly ServerRequestInterface  $request)

Definition at line 30 of file ModifyHrefLangTagsEvent.php.

Member Function Documentation

◆ addHrefLang()

TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::addHrefLang ( string  $languageCode,
string  $url 
)

Add a hreflang tag to the current list of hreflang tags

Parameters
string$languageCode‪The language of the hreflang tag you would like to add. For example: nl-NL
string$url‪The URL of the translation. For example: https://example.com/nl

Definition at line 65 of file ModifyHrefLangTagsEvent.php.

References TYPO3\CMS\Webhooks\Message\$url.

◆ getHrefLangs()

TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::getHrefLangs ( )

◆ getRequest()

TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::getRequest ( )

◆ setHrefLangs()

TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::setHrefLangs ( array  $hrefLangs)

Set the hreflangs. This should be an array in format:

[
'en-US' => 'https://example.com',
'nl-NL' => 'https://example.com/nl'
]
Parameters
array$hrefLangs

Definition at line 54 of file ModifyHrefLangTagsEvent.php.

References TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent\$hrefLangs.

Referenced by TYPO3\CMS\Seo\HrefLang\HrefLangGenerator\__invoke().

Member Data Documentation

◆ $hrefLangs

array TYPO3\CMS\Frontend\Event\ModifyHrefLangTagsEvent::$hrefLangs = []
private