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