View .md

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

Name: featherpanel:admin:console:command:executedemitted at 1 siteCancel or modify: nodefinition

Docblock: string command, array execution data. (the emitter passes 5 values, see the table)

#Payload keyListener parameterType
1command$commandstring
2working_directory$workingDirectorynot declared
3return_code$returnCodenot declared
4execution_time$executionTimenot declared
5executed_by$executedBynot 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()

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

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

Name: featherpanel:admin:console:system_info:retrievednot emittedCancel or modify: nodefinition

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.