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()
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()
Docblock: array notification data. (the emitter passes 4 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | not declared |
| 2 | notification_data | $notificationData | not declared |
| 3 | created_by | $createdBy | not declared |
| 4 | emailed | $emailed | not 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()
Docblock: int notification id, array notification data. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | int |
| 2 | notification_data | $notificationData | not declared |
| 3 | deleted_by | $deletedBy | not 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()
Docblock: int notification id, string error message.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | int |
| 2 | error_message | $errorMessage | string |
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()
Docblock: int notification id, array notification data.
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | int |
| 2 | notification_data | $notificationData | arrayfrom 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()
Docblock: int notification id, array old data, array new data. (the emitter passes 4 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | int |
| 2 | old_data | $oldData | not declared |
| 3 | new_data | $newData | not declared |
| 4 | updated_by | $updatedBy | not 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()
Docblock: array notifications list. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notifications | $notifications | not declared |
| 2 | pagination | $pagination | array |
| 3 | filters | $filters | array |
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()
Docblock: int notification id, int user id. (the emitter passes 3 values, see the table)
| # | Payload key | Listener parameter | Type |
|---|---|---|---|
| 1 | notification_id | $notificationId | int |
| 2 | user_id | $userId | int |
| 3 | user | $user | not 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]));
});