View .md

ServerFilesEvent events

7 FeatherPanel plugin events on ServerFilesEvent (6 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 ServerFilesEvent 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\ServerFilesEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(ServerFilesEvent::onServerFileSaved(), function ($userUuid, $serverUuid, $filePath): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:file:saved ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'file_path' => $filePath]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

ServerFilesEvent::onServerDirectoryCreated()

Name: featherpanel:user:server:directory:createdemitted at 2 sitesCancel or modify: nodefinition

Docblock: string server uuid, string directory path. (the emitter passes 3 values, see the table)

Same event name as ServerEvent::onServerDirectoryCreated(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3directory_path$directoryPathnot declared
When it fires (2 sites)
$event->on(ServerFilesEvent::onServerDirectoryCreated(), function ($userUuid, $serverUuid, $directoryPath): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:directory:created');
});

ServerFilesEvent::onServerFileRenamed()

Name: featherpanel:user:server:file:renamedemitted at 2 sites2 payload shapesCancel or modify: nodefinition

Docblock: string server uuid, string file path. (the emitter passes 4 values, see the table)

Same event name as ServerEvent::onServerFileRenamed(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3root$rootnot at every sitenot declared
4files$filesnot at every sitenot declared
Arguments passedEmitted from
user_uuid, server_uuid, root, files
ServerFilesController::renameFileOrFolder
user_uuid, server_uuid, file_path, new_path
RenameFileTool::execute
When it fires (2 sites)
$event->on(ServerFilesEvent::onServerFileRenamed(), function ($userUuid, $serverUuid, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:file:renamed');
});

ServerFilesEvent::onServerFileSaved()

Name: featherpanel:user:server:file:savedemitted at 2 sitesCancel or modify: nodefinition

Docblock: string server uuid, string file path, int size.

Same event name as ServerEvent::onServerFileWritten(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2server_uuid$serverUuidstringfrom docblock
3file_path$filePathintfrom docblock
When it fires (2 sites)
$event->on(ServerFilesEvent::onServerFileSaved(), function ($userUuid, $serverUuid, $filePath): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:file:saved ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid, 'file_path' => $filePath]));
});

ServerFilesEvent::onServerFileUploaded()

Name: featherpanel:user:server:file:uploadedemitted at 1 siteCancel or modify: nodefinition

Docblock: string server uuid, array file data. (the emitter passes 3 values, see the table)

Same event name as ServerEvent::onServerFileUploaded(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3file_path$filePathnot declared
When it fires (1 site)
$event->on(ServerFilesEvent::onServerFileUploaded(), function ($userUuid, $serverUuid, $filePath): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:file:uploaded');
});

ServerFilesEvent::onServerFilesDeleted()

Name: featherpanel:user:server:files:deletedemitted at 3 sites2 payload shapesCancel or modify: nodefinition

Docblock: string server uuid, array files deleted.

Same event name as ServerEvent::onServerFilesDeleted(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidstringfrom docblock
2server_uuid$serverUuidarrayfrom docblock
Arguments passedEmitted from
user_uuid, server_uuid
ServerFilesController::deleteFiles
ServerFilesController::wipeAllFiles
user_uuid, server_uuid, files
DeleteFilesTool::execute
When it fires (3 sites)
$event->on(ServerFilesEvent::onServerFilesDeleted(), function ($userUuid, $serverUuid, ...$rest): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:files:deleted ' . json_encode(['user_uuid' => $userUuid, 'server_uuid' => $serverUuid]));
});

ServerFilesEvent::onServerFilesError()

Name: featherpanel:user:server:files:errornot emittedCancel or modify: nodefinition

Docblock: string error message, array context.

$event->on(ServerFilesEvent::onServerFilesError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:files:error ' . json_encode($args));
});

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

ServerFilesEvent::onServerPullProcessDeleted()

Name: featherpanel:user:server:pull:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: string server uuid, string pull id. (the emitter passes 3 values, see the table)

Same event name as ServerEvent::onServerPullProcessDeleted(). A listener on either method receives the emits of both.

#Payload keyListener parameterType
1user_uuid$userUuidnot declared
2server_uuid$serverUuidnot declared
3pull_id$pullIdstring
When it fires (1 site)
$event->on(ServerFilesEvent::onServerPullProcessDeleted(), function ($userUuid, $serverUuid, $pullId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:server:pull:deleted ' . json_encode(['pull_id' => $pullId]));
});