ConsoleEvent events
3 FeatherPanel plugin events on ConsoleEvent (1 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. 2 of these events are declared but no code emits them yet; they are marked not emitted.
Setup
Import ConsoleEvent 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\ConsoleEvent;
class MyPlugin implements AppPlugin
{
public static function processEvents(PluginEvents $event): void
{
$event->on(ConsoleEvent::onCommandExecuted(), function ($command, $workingDirectory, $returnCode, $executionTime, $executedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:console:command:executed ' . json_encode(['command' => $command]));
});
}
public static function pluginInstall(): void
{
}
public static function pluginUninstall(): void
{
}
}ConsoleEvent::onCommandExecuted()
Docblock: string command, array execution data. (the emitter passes 5 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | command | $command | string |
| 2 | working_directory | $workingDirectory | not declared |
| 3 | return_code | $returnCode | not declared |
| 4 | execution_time | $executionTime | not declared |
| 5 | executed_by | $executedBy | not declared |
When it fires (1 site)
$event->on(ConsoleEvent::onCommandExecuted(), function ($command, $workingDirectory, $returnCode, $executionTime, $executedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:console:command:executed ' . json_encode(['command' => $command]));
});ConsoleEvent::onConsoleError()
Docblock: string error message, array context.
$event->on(ConsoleEvent::onConsoleError(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:console:error ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
ConsoleEvent::onSystemInfoRetrieved()
Docblock: array system info.
$event->on(ConsoleEvent::onSystemInfoRetrieved(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:console:system_info:retrieved ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.