View .md

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

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

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

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

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

Name: featherpanel:admin:mail_templates:template:createdemitted at 1 siteCancel or modify: nodefinition

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

#Payload keyListener parameterType
1template_id$templateIdnot declared
2template_data$templateDatanot declared
3created_by$createdBynot 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()

Name: featherpanel:admin:mail_templates:template:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int template id, array template data.

#Payload keyListener parameterType
1template$templateintfrom docblock
2deleted_by$deletedByarrayfrom 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()

Name: featherpanel:admin:mail_templates:template:not:foundnot emittedCancel or modify: nodefinition

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

Name: featherpanel:admin:mail_templates:template:retrievednot emittedCancel or modify: nodefinition

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

Name: featherpanel:admin:mail_templates:template:updatedemitted at 1 siteCancel or modify: nodefinition

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

#Payload keyListener parameterType
1template$templateintfrom docblock
2updated_data$updatedDataarrayfrom docblock
3updated_by$updatedByarrayfrom 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]));
});