View .md

DatabaseManagementEvent events

3 FeatherPanel plugin events on DatabaseManagementEvent (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 DatabaseManagementEvent 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\DatabaseManagementEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(DatabaseManagementEvent::onMigrationsExecuted(), function ($executed, $skipped, $failed, $totalTime, $executedBy): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:database_management:migrations:executed ' . json_encode(['executed' => $executed, 'skipped' => $skipped, 'failed' => $failed]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

DatabaseManagementEvent::onDatabaseManagementError()

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

Docblock: string error message, array context.

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

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

DatabaseManagementEvent::onMigrationsExecuted()

Name: featherpanel:admin:database_management:migrations:executedemitted at 1 siteCancel or modify: nodefinition

Docblock: array migration results. (the emitter passes 5 values, see the table)

#Payload keyListener parameterType
1executed$executedint
2skipped$skippedint
3failed$failedint
4total_time$totalTimenot declared
5executed_by$executedBynot declared
When it fires (1 site)
$event->on(DatabaseManagementEvent::onMigrationsExecuted(), function ($executed, $skipped, $failed, $totalTime, $executedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:database_management:migrations:executed ' . json_encode(['executed' => $executed, 'skipped' => $skipped, 'failed' => $failed]));
});

DatabaseManagementEvent::onStatusRetrieved()

Name: featherpanel:admin:database_management:status:retrievednot emittedCancel or modify: nodefinition

Docblock: array status data.

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

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