View .md

PluginManagerEvent events

5 FeatherPanel plugin events on PluginManagerEvent (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 PluginManagerEvent 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\PluginManagerEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(PluginManagerEvent::onPluginFileCreated(), function ($identifier, $fileType, $fileData, $createdBy): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:plugin_manager:file:created ' . json_encode(['identifier' => $identifier, 'file_type' => $fileType, 'file_data' => $fileData]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

PluginManagerEvent::onPluginManagerError()

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

Docblock: string error message, array context.

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

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

PluginManagerEvent::onPluginFileCreated()

Name: featherpanel:admin:plugin_manager:file:createdemitted at 3 sitesCancel or modify: nodefinition

Docblock: string identifier, string file type, array file data. (the emitter passes 4 values, see the table)

#Payload keyListener parameterType
1identifier$identifierstring
2file_type$fileTypestring
3file_data$fileDataarray
4created_by$createdBynot declared
When it fires (3 sites)
$event->on(PluginManagerEvent::onPluginFileCreated(), function ($identifier, $fileType, $fileData, $createdBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:plugin_manager:file:created ' . json_encode(['identifier' => $identifier, 'file_type' => $fileType, 'file_data' => $fileData]));
});

PluginManagerEvent::onPluginCreated()

Name: featherpanel:admin:plugin_manager:plugin:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: string identifier, array plugin data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1identifier$identifiernot declared
2plugin_data$pluginDatanot declared
3created_by$createdBynot declared
When it fires (1 site)
$event->on(PluginManagerEvent::onPluginCreated(), function ($identifier, $pluginData, $createdBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:plugin_manager:plugin:created');
});

PluginManagerEvent::onPluginUpdated()

Name: featherpanel:admin:plugin_manager:plugin:updatedemitted at 1 siteCancel or modify: nodefinition

Docblock: string identifier, array updated data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1identifier$identifiernot declared
2updated_data$updatedDatanot declared
3updated_by$updatedBynot declared
When it fires (1 site)
$event->on(PluginManagerEvent::onPluginUpdated(), function ($identifier, $updatedData, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:plugin_manager:plugin:updated');
});

PluginManagerEvent::onPluginSettingsUpdated()

Name: featherpanel:admin:plugin_manager:settings:updatedemitted at 1 siteCancel or modify: nodefinition

Docblock: string identifier, array settings data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1identifier$identifiernot declared
2settings$settingsnot declared
3updated_by$updatedBynot declared
When it fires (1 site)
$event->on(PluginManagerEvent::onPluginSettingsUpdated(), function ($identifier, $settings, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:plugin_manager:settings:updated');
});