View .md

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()

Name: featherpanel:admin:allocations:allocation:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: array allocation data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1allocations$allocationsarray
2created_count$createdCountint
3created_by$createdBynot 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()

Name: featherpanel:admin:allocations:allocation:deletedemitted at 3 sites3 payload shapesCancel or modify: nodefinition

Docblock: int allocation id, array allocation data.

#Payload keyListener parameterType
1allocation$allocationnot at every siteintfrom docblock
2deleted_by$deletedBynot at every sitearrayfrom docblock
Arguments passedEmitted 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()

Name: featherpanel:admin:allocations:allocation:not:foundnot emittedCancel or modify: nodefinition

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()

Name: featherpanel:admin:allocations:allocation:retrievednot emittedCancel or modify: nodefinition

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()

Name: featherpanel:admin:allocations:allocation:updatedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: int allocation id, array old data, array new data.

#Payload keyListener parameterType
1allocation$allocationnot at every siteintfrom docblock
2updated_data$updatedDatanot at every sitearrayfrom docblock
3updated_by$updatedBynot at every sitearrayfrom docblock
Arguments passedEmitted 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()

Name: featherpanel:admin:allocations:errornot emittedCancel or modify: nodefinition

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()

Name: featherpanel:admin:allocations:retrievednot emittedCancel or modify: nodefinition

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.