View .md

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

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

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

Name: featherpanel:admin:locations:location:createdemitted at 1 siteCancel or modify: nodefinition

Docblock: array location data. (the emitter passes 2 values, see the table)

#Payload keyListener parameterType
1location$locationnot declared
2created_by$createdBynot 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()

Name: featherpanel:admin:locations:location:deletedemitted at 1 siteCancel or modify: nodefinition

Docblock: int location id, array location data.

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

Name: featherpanel:admin:locations:location:not:foundnot emittedCancel or modify: nodefinition

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

Name: featherpanel:admin:locations:location:retrievednot emittedCancel or modify: nodefinition

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

Name: featherpanel:admin:locations:location:updatedemitted at 1 siteCancel or modify: nodefinition

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

#Payload keyListener parameterType
1location$locationintfrom docblock
2updated_data$updatedDataarrayfrom docblock
3updated_by$updatedByarrayfrom 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()

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

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.