View .md

ServerTaskEvent events

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

Setup

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

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(ServerTaskEvent::onServerTaskSequenceUpdated(), function ($userUuid, $serverUuid, $scheduleId, $taskId): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:task:sequence:updated ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'schedule_id' => $scheduleId, 'task_id' => $taskId]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

ServerTaskEvent::onServerTaskCreated()

Name: featherpanel:user:server:task:createdemitted at 2 sitesCancel or modify: nodefinition

Docblock: string server uuid, int schedule id, array task data. (the emitter passes 4 values, see the table)

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

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3schedule_id$scheduleIdint
4task_id$taskIdnot declared
When it fires (2 sites)
$event->on(ServerTaskEvent::onServerTaskCreated(), function ($userUuid, $serverUuid, $scheduleId, $taskId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:task:created ' . json_encode(['schedule_id' => $scheduleId]));
});

ServerTaskEvent::onServerTaskDeleted()

Name: featherpanel:user:server:task:deletedemitted at 2 sitesCancel or modify: nodefinition

Docblock: string server uuid, int schedule id, int task id. (the emitter passes 4 values, see the table)

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

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3schedule_id$scheduleIdint
4task_id$taskIdint
When it fires (2 sites)
$event->on(ServerTaskEvent::onServerTaskDeleted(), function ($userUuid, $serverUuid, $scheduleId, $taskId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:task:deleted ' . json_encode(['schedule_id' => $scheduleId, 'task_id' => $taskId]));
});

ServerTaskEvent::onServerTaskError()

Name: featherpanel:user:server:task:errornot emittedCancel or modify: nodefinition

Docblock: string error message, array context.

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

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

ServerTaskEvent::onServerTaskSequenceUpdated()

Name: featherpanel:user:server:task:sequence:updatedemitted at 1 siteCancel or modify: nodefinition

Docblock: string server uuid, int schedule id, int task id, array new sequence.

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

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2server_uuid$serverUuidintfrom docblock
3schedule_id$scheduleIdint
4task_id$taskIdint
When it fires (1 site)
$event->on(ServerTaskEvent::onServerTaskSequenceUpdated(), function ($userUuid, $serverUuid, $scheduleId, $taskId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:task:sequence:updated ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'schedule_id' => $scheduleId, 'task_id' => $taskId]));
});

ServerTaskEvent::onServerTaskUpdated()

Name: featherpanel:user:server:task:updatedemitted at 2 sitesCancel or modify: nodefinition

Docblock: string server uuid, int schedule id, int task id, array updated data.

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

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2server_uuid$serverUuidintfrom docblock
3schedule_id$scheduleIdint
4task_id$taskIdint
When it fires (2 sites)
$event->on(ServerTaskEvent::onServerTaskUpdated(), function ($userUuid, $serverUuid, $scheduleId, $taskId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:task:updated ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'schedule_id' => $scheduleId, 'task_id' => $taskId]));
});