View .md

RateLimiterEvent events

4 FeatherPanel plugin events on RateLimiterEvent (4 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Last synced from FeatherPanel 15b94e9 on .

On this page

Part of the plugin events reference. Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

Setup

Import RateLimiterEvent in your entry class and register listeners in processEvents():

<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\RateLimiterEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(RateLimiterEvent::onRateLimiterBulkUpdated(), function ($userUuid, $updatedRoutes, $errors): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:rate-limiter:bulk:update ' . json_encode(['user_uuid' => $userUuid, 'updated_routes' => $updatedRoutes, 'errors' => $errors]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

RateLimiterEvent::onRateLimiterBulkUpdated()

Name: featherpanel:rate-limiter:bulk:updateemitted at 1 siteCancel or modify: nodefinition

Docblock: string|null user uuid, array updated routes, array errors.

#Payload keyListener parameterType
1user_uuid$userUuidstring|nullfrom docblock
2updated_routes$updatedRoutesarray
3errors$errorsarray
When it fires (1 site)
$event->on(RateLimiterEvent::onRateLimiterBulkUpdated(), function ($userUuid, $updatedRoutes, $errors): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:rate-limiter:bulk:update ' . json_encode(['user_uuid' => $userUuid, 'updated_routes' => $updatedRoutes, 'errors' => $errors]));
});

RateLimiterEvent::onRateLimiterDeleted()

Name: featherpanel:rate-limiter:deleteemitted at 1 siteCancel or modify: nodefinition

Docblock: string|null user uuid, string route name.

#Payload keyListener parameterType
1user_uuid$userUuidstring|nullfrom docblock
2route_name$routeNamestring
When it fires (1 site)
$event->on(RateLimiterEvent::onRateLimiterDeleted(), function ($userUuid, $routeName): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:rate-limiter:delete ' . json_encode(['user_uuid' => $userUuid, 'route_name' => $routeName]));
});

RateLimiterEvent::onRateLimiterGlobalUpdated()

Name: featherpanel:rate-limiter:global:updateemitted at 1 siteCancel or modify: nodefinition

Docblock: string|null user uuid, bool enabled.

#Payload keyListener parameterType
1user_uuid$userUuidstring|nullfrom docblock
2enabled$enabledbool
When it fires (1 site)
$event->on(RateLimiterEvent::onRateLimiterGlobalUpdated(), function ($userUuid, $enabled): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:rate-limiter:global:update ' . json_encode(['user_uuid' => $userUuid, 'enabled' => $enabled]));
});

RateLimiterEvent::onRateLimiterUpdated()

Name: featherpanel:rate-limiter:updateemitted at 1 siteCancel or modify: nodefinition

Docblock: string|null user uuid, string route name, array config.

#Payload keyListener parameterType
1user_uuid$userUuidstring|nullfrom docblock
2route_name$routeNamestring
3config$configarrayfrom docblock
When it fires (1 site)
$event->on(RateLimiterEvent::onRateLimiterUpdated(), function ($userUuid, $routeName, $config): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:rate-limiter:update ' . json_encode(['user_uuid' => $userUuid, 'route_name' => $routeName, 'config' => $config]));
});