BeforeDatabaseRecordLinkResolvedEvent 

New in version 14.0

The event BeforeDatabaseRecordLinkResolvedEvent has been introduced to retrieve records via custom code in \TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder .

The PSR-14 event \TYPO3\CMS\Frontend\Event\BeforeDatabaseRecordLinkResolvedEvent is dispatched immediately before database record lookup is done for a link by the DatabaseRecordLinkBuilder and therefore allows custom functionality to be attached to record retrieval. The event is stoppable, which means that as soon as a listener returns a record, no further listener gets called and the core does no further lookup.

The event is dispatched with $record set to null . If an event listener retrieves a record from the database, it should set the $record property to the record as an array. This will stop the event propagation and cause the default record retrieval logic in \TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder to be skipped.

Note that the custom code needs to take care - if relevant - of all aspects normally handled by \TYPO3\CMS\Frontend\Typolink\DatabaseRecordLinkBuilder , such as record visibility, language overlay or version overlay.

Example: Retrieve the record of a link yourself 

EXT:my_extension/Classes/Frontend/EventListener/MyEventListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Frontend\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\Event\BeforeDatabaseRecordLinkResolvedEvent;

final readonly class MyEventListener
{
  #[AsEventListener(
    identifier: 'my-extension/before-database-record-link-resolved',
  )]
  public function __invoke(BeforeDatabaseRecordLinkResolvedEvent $event): void
  {
    // Retrieve the record from the database as an array (just an example -
    // replace the code in the first line below with your code)
    $result = getADatabaseRecord();
    if ($result !== false) {
      // Setting the record stops event propagation and
      // skips the default record retrieval logic
      $event->record = $result;
    }
  }
}
Copied!

API 

final class BeforeDatabaseRecordLinkResolvedEvent
Fully qualified name
\TYPO3\CMS\Frontend\Event\BeforeDatabaseRecordLinkResolvedEvent

Event dispatched before the DatabaseRecordLinkBuilder resolves a database record.

This event is stoppable: If an event listener sets a record, the event propagation will be stopped and the default record retrieval logic will be skipped.

public readonly linkDetails
public readonly databaseTable
public readonly typoscriptConfiguration
public readonly tsConfig
public readonly request
public record
isPropagationStopped()
Returns
bool