AllocationsEvent events
7 FeatherPanel plugin events on AllocationsEvent (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. 4 of these events are declared but no code emits them yet; they are marked not emitted.
Setup
Import AllocationsEvent 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\AllocationsEvent;
class MyPlugin implements AppPlugin
{
public static function processEvents(PluginEvents $event): void
{
$event->on(AllocationsEvent::onAllocationCreated(), function ($allocations, $createdCount, $createdBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:created ' . json_encode(['allocations' => $allocations, 'created_count' => $createdCount]));
});
}
public static function pluginInstall(): void
{
}
public static function pluginUninstall(): void
{
}
}AllocationsEvent::onAllocationCreated()
Docblock: array allocation data. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | allocations | $allocations | array |
| 2 | created_count | $createdCount | int |
| 3 | created_by | $createdBy | not declared |
When it fires (1 site)
$event->on(AllocationsEvent::onAllocationCreated(), function ($allocations, $createdCount, $createdBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:created ' . json_encode(['allocations' => $allocations, 'created_count' => $createdCount]));
});AllocationsEvent::onAllocationDeleted()
Docblock: int allocation id, array allocation data.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | allocation | $allocationnot at every site | intfrom docblock |
| 2 | deleted_by | $deletedBynot at every site | arrayfrom docblock |
| Arguments passed | Emitted from |
|---|---|
allocation, deleted_by | AllocationsController::delete |
deleted_count, skipped_count, ids, deleted_by | AllocationsController::bulkDelete |
deleted_count, node_id, ip, deleted_by | AllocationsController::deleteUnused |
When it fires (3 sites)
$event->on(AllocationsEvent::onAllocationDeleted(), function (...$rest): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:deleted');
});AllocationsEvent::onAllocationNotFound()
Docblock: int allocation id, string error message.
$event->on(AllocationsEvent::onAllocationNotFound(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:not:found ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
AllocationsEvent::onAllocationRetrieved()
Docblock: int allocation id, array allocation data.
$event->on(AllocationsEvent::onAllocationRetrieved(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:retrieved ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
AllocationsEvent::onAllocationUpdated()
Docblock: int allocation id, array old data, array new data.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | allocation | $allocationnot at every site | intfrom docblock |
| 2 | updated_data | $updatedDatanot at every site | arrayfrom docblock |
| 3 | updated_by | $updatedBynot at every site | arrayfrom docblock |
| Arguments passed | Emitted from |
|---|---|
allocation, updated_data, updated_by | AllocationsController::update |
node_id, from_ip, to_ip, ip_alias, matched_count, updated_count, deleted_target_conflicts, deleted_source_conflicts, updated_by | AllocationsController::bulkUpdateAddress |
When it fires (2 sites)
$event->on(AllocationsEvent::onAllocationUpdated(), function (...$rest): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:allocation:updated');
});AllocationsEvent::onAllocationsError()
Docblock: string error message, array context.
$event->on(AllocationsEvent::onAllocationsError(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:error ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
AllocationsEvent::onAllocationsRetrieved()
Docblock: array allocations list.
$event->on(AllocationsEvent::onAllocationsRetrieved(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:allocations:retrieved ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.