View .md

ImagesEvent events

7 FeatherPanel plugin events on ImagesEvent (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. 4 of these events are declared but no code emits them yet; they are marked not emitted.

Setup

Import ImagesEvent 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\ImagesEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(ImagesEvent::onImageDeleted(), function ($image, $deletedBy): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:deleted ' . json_encode(['image' => $image, 'deleted_by' => $deletedBy]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

ImagesEvent::onImagesError()

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

Docblock: string error message, array context.

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

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

ImagesEvent::onImageCreated()

Name: featherpanel:admin:images:image:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: array image data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1image_id$imageIdnot declared
2image_data$imageDatanot declared
3created_by$createdBynot declared
When it fires (1 site)
$event->on(ImagesEvent::onImageCreated(), function ($imageId, $imageData, $createdBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:created');
});

ImagesEvent::onImageDeleted()

Name: featherpanel:admin:images:image:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int image id, array image data.

#Payload keyListener parameterType
1image$imageintfrom docblock
2deleted_by$deletedByarrayfrom docblock
When it fires (1 site)
$event->on(ImagesEvent::onImageDeleted(), function ($image, $deletedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:deleted ' . json_encode(['image' => $image, 'deleted_by' => $deletedBy]));
});

ImagesEvent::onImageNotFound()

Name: featherpanel:admin:images:image:not:foundnot emittedCancel or modify: nodefinition

Docblock: int image id, string error message.

$event->on(ImagesEvent::onImageNotFound(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:not:found ' . json_encode($args));
});

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

ImagesEvent::onImageRetrieved()

Name: featherpanel:admin:images:image:retrievednot emittedCancel or modify: nodefinition

Docblock: int image id, array image data.

$event->on(ImagesEvent::onImageRetrieved(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:retrieved ' . json_encode($args));
});

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

ImagesEvent::onImageUpdated()

Name: featherpanel:admin:images:image:updatedemitted at 1 siteCancel or modify: nodefinition

Docblock: int image id, array old data, array new data.

#Payload keyListener parameterType
1image$imageintfrom docblock
2updated_data$updatedDataarrayfrom docblock
3updated_by$updatedByarrayfrom docblock
When it fires (1 site)
$event->on(ImagesEvent::onImageUpdated(), function ($image, $updatedData, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:images:image:updated ' . json_encode(['image' => $image, 'updated_data' => $updatedData, 'updated_by' => $updatedBy]));
});

ImagesEvent::onImagesRetrieved()

Name: featherpanel:admin:images:retrievednot emittedCancel or modify: nodefinition

Docblock: array images list.

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

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