# FeatherZeroTrustEvent events

> 7 FeatherPanel plugin events on FeatherZeroTrustEvent (4 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/feather-zero-trust/

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. 3 of these events are declared but no code emits them yet; they are marked not emitted.

## Setup

Import `FeatherZeroTrustEvent` 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\FeatherZeroTrustEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(FeatherZeroTrustEvent::onFeatherZeroTrustConfigRetrieved(), function ($config): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:config:retrieved ' . json_encode(['config' => $config]));
        });
    }

    public static function pluginInstall(): void
    {
    }

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

## `FeatherZeroTrustEvent::onFeatherZeroTrustConfigRetrieved()`

- Name: `featherpanel:admin:featherzerotrust:config:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L28)

Docblock: array config data.

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

When it fires (1 site)

-   [`FeatherZeroTrustController::getConfig`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/FeatherZeroTrustController.php#L63)[`GET /api/admin/featherzerotrust/config`](https://featherpanel.com/docs/api/reference/admin/featherzerotrust/#get-admin-featherzerotrust-config)

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustConfigRetrieved(), function ($config): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:config:retrieved ' . json_encode(['config' => $config]));
});
```

## `FeatherZeroTrustEvent::onFeatherZeroTrustConfigUpdated()`

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

Docblock: array old config, array new config. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `old_config` | `$oldConfig` | not declared |
| 2 | `new_config` | `$newConfig` | not declared |
| 3 | `updated_by` | `$updatedBy` | not declared |

When it fires (1 site)

-   [`FeatherZeroTrustController::updateConfig`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/FeatherZeroTrustController.php#L111)[`PUT /api/admin/featherzerotrust/config`](https://featherpanel.com/docs/api/reference/admin/featherzerotrust/#put-admin-featherzerotrust-config)

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustConfigUpdated(), function ($oldConfig, $newConfig, $updatedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:config:updated');
});
```

## `FeatherZeroTrustEvent::onFeatherZeroTrustError()`

- Name: `featherpanel:admin:featherzerotrust:error`
- not emitted
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L70)

Docblock: string error message, array context.

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:error ' . json_encode($args));
});
```

No code emits this event yet, so the arguments are unknown. The listener accepts any.

## `FeatherZeroTrustEvent::onFeatherZeroTrustLogsRetrieved()`

- Name: `featherpanel:admin:featherzerotrust:logs:retrieved`
- not emitted
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L61)

Docblock: array logs data.

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustLogsRetrieved(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:logs:retrieved ' . json_encode($args));
});
```

No code emits this event yet, so the arguments are unknown. The listener accepts any.

## `FeatherZeroTrustEvent::onFeatherZeroTrustScanCompleted()`

- Name: `featherpanel:admin:featherzerotrust:scan:completed`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L53)

Docblock: string server uuid, array scan results. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `server_uuid` | `$serverUuid` | not declared |
| 2 | `scan_results` | `$scanResults` | not declared |
| 3 | `detections_count` | `$detectionsCount` | not declared |

When it fires (1 site)

-   [`FeatherZeroTrustController::scanServer`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/FeatherZeroTrustController.php#L231)[`POST /api/admin/featherzerotrust/scan`](https://featherpanel.com/docs/api/reference/admin/featherzerotrust/#post-admin-featherzerotrust-scan)

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustScanCompleted(), function ($serverUuid, $scanResults, $detectionsCount): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:scan:completed');
});
```

## `FeatherZeroTrustEvent::onFeatherZeroTrustScanError()`

- Name: `featherpanel:admin:featherzerotrust:scan:error`
- not emitted
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L78)

Docblock: string server uuid, string error message.

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustScanError(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:scan:error ' . json_encode($args));
});
```

No code emits this event yet, so the arguments are unknown. The listener accepts any.

## `FeatherZeroTrustEvent::onFeatherZeroTrustScanStarted()`

- Name: `featherpanel:admin:featherzerotrust:scan:started`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/FeatherZeroTrustEvent.php#L45)

Docblock: string server uuid, array scan data. (the emitter passes 4 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `server_uuid` | `$serverUuid` | not declared |
| 2 | `directory` | `$directory` | not declared |
| 3 | `max_depth` | `$maxDepth` | not declared |
| 4 | `started_by` | `$startedBy` | not declared |

When it fires (1 site)

-   [`FeatherZeroTrustController::scanServer`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/FeatherZeroTrustController.php#L191)[`POST /api/admin/featherzerotrust/scan`](https://featherpanel.com/docs/api/reference/admin/featherzerotrust/#post-admin-featherzerotrust-scan)

```php
$event->on(FeatherZeroTrustEvent::onFeatherZeroTrustScanStarted(), function ($serverUuid, $directory, $maxDepth, $startedBy): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:featherzerotrust:scan:started');
});
```
