View .md

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

Name: featherpanel:admin:file_manager:directory:browsednot emittedCancel or modify: nodefinition

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

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

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

Name: featherpanel:admin:file_manager:file:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: string path, bool is_directory. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1path$pathnot declared
2is_directory$isDirectorynot declared
3created_by$createdBynot 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()

Name: featherpanel:admin:file_manager:file:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: string path, bool was_directory. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1path$pathnot declared
2was_directory$wasDirectorybool
3deleted_by$deletedBynot 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()

Name: featherpanel:admin:file_manager:file:readnot emittedCancel or modify: nodefinition

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

Name: featherpanel:admin:file_manager:file:savedemitted at 1 siteCancel or modify: nodefinition

Docblock: string path, int size. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1path$pathnot declared
2size$sizenot declared
3saved_by$savedBynot 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');
});