ServerAllocationEvent events
3 FeatherPanel plugin events on ServerAllocationEvent (2 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 ServerAllocationEvent 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\ServerAllocationEvent;
class MyPlugin implements AppPlugin
{
public static function processEvents(PluginEvents $event): void
{
$event->on(ServerAllocationEvent::onServerAllocationDeleted(), function ($userUuid, $serverUuid, $allocationId): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:allocation:deleted ' . json_encode(['allocation_id' => $allocationId]));
});
}
public static function pluginInstall(): void
{
}
public static function pluginUninstall(): void
{
}
}ServerAllocationEvent::onServerAllocationDeleted()
Docblock: string server uuid, int allocation id. (the emitter passes 3 values, see the table)
Same event name as ServerEvent::onServerAllocationDeleted(). A listener on either method receives the emits of both.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | user_uuid | $userUuid | not declared |
| 2 | server_uuid | $serverUuid | not declared |
| 3 | allocation_id | $allocationId | int |
When it fires (2 sites)
$event->on(ServerAllocationEvent::onServerAllocationDeleted(), function ($userUuid, $serverUuid, $allocationId): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:allocation:deleted ' . json_encode(['allocation_id' => $allocationId]));
});ServerAllocationEvent::onServerAllocationError()
Docblock: string error message, array context.
$event->on(ServerAllocationEvent::onServerAllocationError(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:allocation:error ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
ServerAllocationEvent::onServerAllocationSetPrimary()
Docblock: string server uuid, int allocation id, bool is_primary.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | user_uuid | $userUuid | stringfrom docblock |
| 2 | server_uuid | $serverUuid | intfrom docblock |
| 3 | allocation_id | $allocationId | int |
| Arguments passed | Emitted from |
|---|---|
user_uuid, server_uuid, allocation_id | ServerAllocationController::setPrimaryAllocation |
user_uuid, server_uuid, allocation_id, is_primary | SetPrimaryAllocationTool::execute |
When it fires (2 sites)
$event->on(ServerAllocationEvent::onServerAllocationSetPrimary(), function ($userUuid, $serverUuid, $allocationId, ...$rest): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:allocation:set_primary ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'allocation_id' => $allocationId]));
});