View .md

NotificationsEvent events

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

Setup

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

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(NotificationsEvent::onNotificationNotFound(), function ($notificationId, $errorMessage): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:not:found ' . json_encode(['notification_id' => $notificationId, 'error_message' => $errorMessage]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}

NotificationsEvent::onNotificationsError()

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

Docblock: string error message, array context.

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

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

NotificationsEvent::onNotificationCreated()

Name: featherpanel:admin:notifications:notification:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: array notification data. (the emitter passes 4 values, see the table)

#Payload keyListener parameterType
1notification_id$notificationIdnot declared
2notification_data$notificationDatanot declared
3created_by$createdBynot declared
4emailed$emailednot declared
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationCreated(), function ($notificationId, $notificationData, $createdBy, $emailed): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:created');
});

NotificationsEvent::onNotificationDeleted()

Name: featherpanel:admin:notifications:notification:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int notification id, array notification data. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1notification_id$notificationIdint
2notification_data$notificationDatanot declared
3deleted_by$deletedBynot declared
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationDeleted(), function ($notificationId, $notificationData, $deletedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:deleted ' . json_encode(['notification_id' => $notificationId]));
});

NotificationsEvent::onNotificationNotFound()

Name: featherpanel:admin:notifications:notification:not:foundemitted at 1 siteCancel or modify: nodefinition

Docblock: int notification id, string error message.

#Payload keyListener parameterType
1notification_id$notificationIdint
2error_message$errorMessagestring
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationNotFound(), function ($notificationId, $errorMessage): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:not:found ' . json_encode(['notification_id' => $notificationId, 'error_message' => $errorMessage]));
});

NotificationsEvent::onNotificationRetrieved()

Name: featherpanel:admin:notifications:notification:retrievedemitted at 1 siteCancel or modify: nodefinition

Docblock: int notification id, array notification data.

#Payload keyListener parameterType
1notification_id$notificationIdint
2notification_data$notificationDataarrayfrom docblock
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationRetrieved(), function ($notificationId, $notificationData): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:retrieved ' . json_encode(['notification_id' => $notificationId, 'notification_data' => $notificationData]));
});

NotificationsEvent::onNotificationUpdated()

Name: featherpanel:admin:notifications:notification:updatedemitted at 1 siteCancel or modify: nodefinition

Docblock: int notification id, array old data, array new data. (the emitter passes 4 values, see the table)

#Payload keyListener parameterType
1notification_id$notificationIdint
2old_data$oldDatanot declared
3new_data$newDatanot declared
4updated_by$updatedBynot declared
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationUpdated(), function ($notificationId, $oldData, $newData, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:notification:updated ' . json_encode(['notification_id' => $notificationId]));
});

NotificationsEvent::onNotificationsRetrieved()

Name: featherpanel:admin:notifications:retrievedemitted at 1 siteCancel or modify: nodefinition

Docblock: array notifications list. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1notifications$notificationsnot declared
2pagination$paginationarray
3filters$filtersarray
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationsRetrieved(), function ($notifications, $pagination, $filters): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:notifications:retrieved ' . json_encode(['pagination' => $pagination, 'filters' => $filters]));
});

NotificationsEvent::onNotificationDismissed()

Name: featherpanel:user:notifications:notification:dismissedemitted at 1 siteCancel or modify: nodefinition

Docblock: int notification id, int user id. (the emitter passes 3 values, see the table)

#Payload keyListener parameterType
1notification_id$notificationIdint
2user_id$userIdint
3user$usernot declared
When it fires (1 site)
$event->on(NotificationsEvent::onNotificationDismissed(), function ($notificationId, $userId, $user): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:user:notifications:notification:dismissed ' . json_encode(['notification_id' => $notificationId, 'user_id' => $userId]));
});