BeforeActionRateLimitResponseEvent 

The PSR-14 event \TYPO3\CMS\Extbase\Event\Mvc\BeforeActionRateLimitResponseEvent is dispatched when an Extbase action annotated with #[RateLimit] has reached its limit, before the response leaves the controller. A listener can replace that response or act on the event, for example to write a log entry.

Without a listener, Extbase answers with HTTP 429 Too many requests.

Example: let the site error handler answer instead 

The following listener passes the request to the error handler of the site. A visitor who reaches the limit then sees the error page of the site, and not a bare 429 response:

EXT:my_extension/Classes/EventListener/RateLimitErrorPageListener.php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\EventListener;

use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Http\PropagateResponseException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Event\Mvc\BeforeActionRateLimitResponseEvent;
use TYPO3\CMS\Frontend\Controller\ErrorController;

final readonly class RateLimitErrorPageListener
{
  #[AsEventListener('my_extension/rate-limit-error-page')]
  public function __invoke(BeforeActionRateLimitResponseEvent $event): void
  {
    $response = GeneralUtility::makeInstance(ErrorController::class)
        ->accessDeniedAction(
          $event->getRequest(),
          $event->getRateLimit()->message,
        );
    throw new PropagateResponseException($response, 1771077885);
  }
}
Copied!

Calling setResponse() instead returns a response of your own and keeps the request in Extbase.

API 

final class BeforeActionRateLimitResponseEvent
Fully qualified name
\TYPO3\CMS\Extbase\Event\Mvc\BeforeActionRateLimitResponseEvent

Event that is triggered, when an extbase action is rate limitied and before the rate limit response is sent.

Extension developers can use this event to provide an alternative response or to implement a custom logic.

getRequest()
Returns
\Psr\Http\Message\ServerRequestInterface
getControllerClassName()
Returns
string
getActionMethodName()
Returns
string
getRateLimit()
Returns
\TYPO3\CMS\Extbase\Attribute\RateLimit
getResponse()
Returns
\Psr\Http\Message\ResponseInterface
setResponse(\Psr\Http\Message\ResponseInterface $response)
param $response

the response