MailTemplatesEvent events
7 FeatherPanel plugin events on MailTemplatesEvent (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 MailTemplatesEvent 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\MailTemplatesEvent;
class MyPlugin implements AppPlugin
{
public static function processEvents(PluginEvents $event): void
{
$event->on(MailTemplatesEvent::onMailTemplateDeleted(), function ($template, $deletedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:deleted ' . json_encode(['template' => $template, 'deleted_by' => $deletedBy]));
});
}
public static function pluginInstall(): void
{
}
public static function pluginUninstall(): void
{
}
}MailTemplatesEvent::onMailTemplatesError()
Docblock: string error message, array context.
$event->on(MailTemplatesEvent::onMailTemplatesError(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:error ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
MailTemplatesEvent::onMailTemplatesRetrieved()
Docblock: array templates list.
$event->on(MailTemplatesEvent::onMailTemplatesRetrieved(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:retrieved ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
MailTemplatesEvent::onMailTemplateCreated()
Docblock: array template data. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | template_id | $templateId | not declared |
| 2 | template_data | $templateData | not declared |
| 3 | created_by | $createdBy | not declared |
When it fires (1 site)
$event->on(MailTemplatesEvent::onMailTemplateCreated(), function ($templateId, $templateData, $createdBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:created');
});MailTemplatesEvent::onMailTemplateDeleted()
Docblock: int template id, array template data.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | template | $template | intfrom docblock |
| 2 | deleted_by | $deletedBy | arrayfrom docblock |
When it fires (1 site)
$event->on(MailTemplatesEvent::onMailTemplateDeleted(), function ($template, $deletedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:deleted ' . json_encode(['template' => $template, 'deleted_by' => $deletedBy]));
});MailTemplatesEvent::onMailTemplateNotFound()
Docblock: int template id, string error message.
$event->on(MailTemplatesEvent::onMailTemplateNotFound(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:not:found ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
MailTemplatesEvent::onMailTemplateRetrieved()
Docblock: int template id, array template data.
$event->on(MailTemplatesEvent::onMailTemplateRetrieved(), function (...$args): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:retrieved ' . json_encode($args));
});No code emits this event yet, so the arguments are unknown. The listener accepts any.
MailTemplatesEvent::onMailTemplateUpdated()
Docblock: int template id, array old data, array new data.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | template | $template | intfrom docblock |
| 2 | updated_data | $updatedData | arrayfrom docblock |
| 3 | updated_by | $updatedBy | arrayfrom docblock |
When it fires (1 site)
$event->on(MailTemplatesEvent::onMailTemplateUpdated(), function ($template, $updatedData, $updatedBy): void {
App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:mail_templates:template:updated ' . json_encode(['template' => $template, 'updated_data' => $updatedData, 'updated_by' => $updatedBy]));
});