# WebPlatesEvent events

> 3 FeatherPanel plugin events on WebPlatesEvent (3 emitted by the core): the event names, the arguments each listener gets, where they fire and a PHP listener for each.

Source: https://featherpanel.com/docs/plugins/events/web-plates/

Part of the [plugin events reference](https://featherpanel.com/docs/plugins/events/). Listeners get the payload values as positional arguments in the order shown, cannot cancel the action, and must catch their own exceptions.

## Setup

Import `WebPlatesEvent` in your entry class and register listeners in `processEvents()`:

```php
<?php

namespace App\Addons\myplugin;

use App\App;
use App\Plugins\AppPlugin;
use App\Plugins\PluginEvents;
use App\Plugins\Events\Events\WebPlatesEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(WebPlatesEvent::onWebPlateUpdated(), function ($webplateId, $webplate): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:web_plates:plate:updated ' . json_encode(['webplate_id' => $webplateId, 'webplate' => $webplate]));
        });
    }

    public static function pluginInstall(): void
    {
    }

    public static function pluginUninstall(): void
    {
    }
}
```

## `WebPlatesEvent::onWebPlateCreated()`

- Name: `featherpanel:admin:web_plates:plate:created`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/WebPlatesEvent.php#L27)

Docblock: array plate data.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `webplate` | `$webplate` | `array`from docblock |

When it fires (1 site)

-   [`create`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/WebPlatesController.php#L130) via `emitPluginEvent()`

```php
$event->on(WebPlatesEvent::onWebPlateCreated(), function ($webplate): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:web_plates:plate:created ' . json_encode(['webplate' => $webplate]));
});
```

## `WebPlatesEvent::onWebPlateDeleted()`

- Name: `featherpanel:admin:web_plates:plate:deleted`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/WebPlatesEvent.php#L43)

Docblock: int plate id, array plate data. (the emitter passes 1 value, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `webplate_id` | `$webplateId` | `int` |

When it fires (1 site)

-   [`delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/WebPlatesController.php#L229) via `emitPluginEvent()`

```php
$event->on(WebPlatesEvent::onWebPlateDeleted(), function ($webplateId): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:web_plates:plate:deleted ' . json_encode(['webplate_id' => $webplateId]));
});
```

## `WebPlatesEvent::onWebPlateUpdated()`

- Name: `featherpanel:admin:web_plates:plate:updated`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/WebPlatesEvent.php#L35)

Docblock: int plate id, array plate data.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `webplate_id` | `$webplateId` | `int` |
| 2 | `webplate` | `$webplate` | `array`from docblock |

When it fires (1 site)

-   [`update`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/WebPlatesController.php#L198) via `emitPluginEvent()`

```php
$event->on(WebPlatesEvent::onWebPlateUpdated(), function ($webplateId, $webplate): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:web_plates:plate:updated ' . json_encode(['webplate_id' => $webplateId, 'webplate' => $webplate]));
});
```
