View .md

NodesEvent events

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

Setup

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

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(NodesEvent::onNodeDeleted(), function ($node, $deletedBy): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:deleted ' . json_encode(['node' => $node, 'deleted_by' => $deletedBy]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

NodesEvent::onNodesError()

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

Docblock: string error message, array context.

$event->on(NodesEvent::onNodesError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:error ' . json_encode($args));
});

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

NodesEvent::onNodeConnectionError()

Name: featherpanel:admin:nodes:node:connection:errornot emittedCancel or modify: nodefinition

Docblock: int node id, string error message.

$event->on(NodesEvent::onNodeConnectionError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:connection:error ' . json_encode($args));
});

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

NodesEvent::onNodeCreated()

Name: featherpanel:admin:nodes:node:createdemitted at 2 sitesCancel or modify: nodefinition

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

#Payload keyListener parameterType
1node$nodenot declared
2created_by$createdBynot declared
When it fires (2 sites)
$event->on(NodesEvent::onNodeCreated(), function ($node, $createdBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:created');
});

NodesEvent::onNodeDeleted()

Name: featherpanel:admin:nodes:node:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int node id, array node data.

#Payload keyListener parameterType
1node$nodeintfrom docblock
2deleted_by$deletedByarrayfrom docblock
When it fires (1 site)
$event->on(NodesEvent::onNodeDeleted(), function ($node, $deletedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:deleted ' . json_encode(['node' => $node, 'deleted_by' => $deletedBy]));
});

NodesEvent::onNodeKeyReset()

Name: featherpanel:admin:nodes:node:key:resetnot emittedCancel or modify: nodefinition

Docblock: int node id, string new key.

$event->on(NodesEvent::onNodeKeyReset(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:key:reset ' . json_encode($args));
});

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

NodesEvent::onNodeNotFound()

Name: featherpanel:admin:nodes:node:not:foundnot emittedCancel or modify: nodefinition

Docblock: int node id, string error message.

$event->on(NodesEvent::onNodeNotFound(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:not:found ' . json_encode($args));
});

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

NodesEvent::onNodeRetrieved()

Name: featherpanel:admin:nodes:node:retrievednot emittedCancel or modify: nodefinition

Docblock: int node id, array node data.

$event->on(NodesEvent::onNodeRetrieved(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:retrieved ' . json_encode($args));
});

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

NodesEvent::onNodeUpdated()

Name: featherpanel:admin:nodes:node:updatedemitted at 1 siteCancel or modify: nodefinition

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

#Payload keyListener parameterType
1node$nodeintfrom docblock
2updated_data$updatedDataarrayfrom docblock
3updated_by$updatedByarrayfrom docblock
When it fires (1 site)
$event->on(NodesEvent::onNodeUpdated(), function ($node, $updatedData, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:node:updated ' . json_encode(['node' => $node, 'updated_data' => $updatedData, 'updated_by' => $updatedBy]));
});

NodesEvent::onNodesRetrieved()

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

Docblock: array nodes list.

$event->on(NodesEvent::onNodesRetrieved(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:nodes:retrieved ' . json_encode($args));
});

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