FileManagerEvent events
6 FeatherPanel plugin events on FileManagerEvent (3 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. 3 of these events are declared but no code emits them yet; they are marked not emitted.
Setup
Import FileManagerEvent 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\FileManagerEvent;
class MyPlugin implements AppPlugin
{
public static function processEvents(PluginEvents $event): void
{
$event->on(FileManagerEvent::onFileCreated(), function ($path, $isDirectory, $createdBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:file:created');
});
}
public static function pluginInstall(): void
{
}
public static function pluginUninstall(): void
{
}
}FileManagerEvent::onDirectoryBrowsed()
Docblock: string path, array items.
$event->on(FileManagerEvent::onDirectoryBrowsed(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:directory:browsed ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
FileManagerEvent::onFileManagerError()
Docblock: string error message, array context.
$event->on(FileManagerEvent::onFileManagerError(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:error ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
FileManagerEvent::onFileCreated()
Docblock: string path, bool is_directory. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | path | $path | not declared |
| 2 | is_directory | $isDirectory | not declared |
| 3 | created_by | $createdBy | not declared |
When it fires (1 site)
$event->on(FileManagerEvent::onFileCreated(), function ($path, $isDirectory, $createdBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:file:created');
});FileManagerEvent::onFileDeleted()
Docblock: string path, bool was_directory. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | path | $path | not declared |
| 2 | was_directory | $wasDirectory | bool |
| 3 | deleted_by | $deletedBy | not declared |
When it fires (1 site)
$event->on(FileManagerEvent::onFileDeleted(), function ($path, $wasDirectory, $deletedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:file:deleted ' . json_encode(['was_directory' => $wasDirectory]));
});FileManagerEvent::onFileRead()
Docblock: string path, array file data.
$event->on(FileManagerEvent::onFileRead(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:file:read ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
FileManagerEvent::onFileSaved()
Docblock: string path, int size. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | path | $path | not declared |
| 2 | size | $size | not declared |
| 3 | saved_by | $savedBy | not declared |
When it fires (1 site)
$event->on(FileManagerEvent::onFileSaved(), function ($path, $size, $savedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:file_manager:file:saved');
});