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