View .md

UserApiClientEvent events

4 FeatherPanel plugin events on UserApiClientEvent (3 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. 1 of these events are declared but no code emits them yet; they are marked not emitted.

Setup

Import UserApiClientEvent 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\UserApiClientEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(UserApiClientEvent::onUserApiClientDeleted(), function ($userUuid, $apiClient): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:deleted ' . json_encode(['user_uuid' => $userUuid, 'api_client' => $apiClient]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

UserApiClientEvent::onUserApiClientCreated()

Name: featherpanel:user:api_client:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: array api_client data. (the emitter passes 2 values, see the table)

Same event name as UserEvent::onUserApiKeyCreated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2api_client$apiClientnot declared
When it fires (1 site)
$event->on(UserApiClientEvent::onUserApiClientCreated(), function ($userUuid, $apiClient): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:created');
});

UserApiClientEvent::onUserApiClientDeleted()

Name: featherpanel:user:api_client:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int api_client id, array api_client data.

Same event name as UserEvent::onUserApiKeyDeleted(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidintfrom docblock
2api_client$apiClientarrayfrom docblock
When it fires (1 site)
$event->on(UserApiClientEvent::onUserApiClientDeleted(), function ($userUuid, $apiClient): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:deleted ' . json_encode(['user_uuid' => $userUuid, 'api_client' => $apiClient]));
});

UserApiClientEvent::onUserApiClientError()

Name: featherpanel:user:api_client:errornot emittedCancel or modify: nodefinition

Docblock: string error message, array context.

$event->on(UserApiClientEvent::onUserApiClientError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:error ' . json_encode($args));
});

No code emits this event yet, so the arguments are unknown. The listener accepts any.

UserApiClientEvent::onUserApiClientUpdated()

Name: featherpanel:user:api_client:updatedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: int api_client id, array updated data. (the emitter passes 3 values, see the table)

Same event name as UserEvent::onUserApiKeyUpdated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2api_client$apiClientnot declared
3updated_data$updatedDatanot at every sitenot declared
Arguments passedEmitted from
user_uuid, api_client, updated_data
ApiClientController::updateApiClient
user_uuid, api_client, action
ApiClientController::regenerateApiKeys
When it fires (2 sites)
$event->on(UserApiClientEvent::onUserApiClientUpdated(), function ($userUuid, $apiClient, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:api_client:updated');
});