# PluginUiEvent events

> 7 FeatherPanel plugin events on PluginUiEvent (7 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/plugin-ui/

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 `PluginUiEvent` 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\PluginUiEvent;

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(PluginUiEvent::onUiError(), function ($source, $message, $context): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:error ' . json_encode(['source' => $source, 'message' => $message, 'context' => $context]));
        });
    }

    public static function pluginInstall(): void
    {
    }

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

## `PluginUiEvent::onUiError()`

- Name: `featherpanel:system:plugins:ui:error`
- emitted at 4 sites
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L51)

Docblock: string source, string message, array context metadata.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `source` | `$source` | `string` |
| 2 | `message` | `$message` | `string`from docblock |
| 3 | `context` | `$context` | `array` |

When it fires (4 sites)

-   [`PluginPublicPagesController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginPublicPagesController.php#L116)[`GET /api/system/plugin-public-pages`](https://featherpanel.com/docs/api/reference/system/plugin-public-pages/#get-system-plugin-public-pages)
-   [`PluginSidebarController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginSidebarController.php#L170)[`GET /api/system/plugin-sidebar`](https://featherpanel.com/docs/api/reference/system/plugin-sidebar/#get-system-plugin-sidebar)
-   [`PluginSidebarController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginSidebarController.php#L244)[`GET /api/system/plugin-sidebar`](https://featherpanel.com/docs/api/reference/system/plugin-sidebar/#get-system-plugin-sidebar)
-   [`PluginWidgetController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginWidgetController.php#L275)[`GET /api/system/plugin-widgets`](https://featherpanel.com/docs/api/reference/system/plugin-widgets/#get-system-plugin-widgets)

```php
$event->on(PluginUiEvent::onUiError(), function ($source, $message, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:error ' . json_encode(['source' => $source, 'message' => $message, 'context' => $context]));
});
```

## `PluginUiEvent::onOverridesRetrieved()`

- Name: `featherpanel:system:plugins:ui:overrides:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L67)

Docblock: array overrides from Frontend/overrides.json aggregations. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `hide` | `$hide` | `array` |
| 2 | `replace` | `$replace` | `array` |
| 3 | `actions` | `$actions` | `array` |

When it fires (1 site)

-   [`PluginOverridesController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginOverridesController.php#L106)[`GET /api/system/plugin-overrides`](https://featherpanel.com/docs/api/reference/system/plugin-overrides/#get-system-plugin-overrides)

```php
$event->on(PluginUiEvent::onOverridesRetrieved(), function ($hide, $replace, $actions): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:overrides:retrieved ' . json_encode(['hide' => $hide, 'replace' => $replace, 'actions' => $actions]));
});
```

## `PluginUiEvent::onUiPacksRetrieved()`

- Name: `featherpanel:system:plugins:ui:packs:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L75)

Docblock: array UI packs from Frontend/ui.json aggregations.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `packs` | `$packs` | `array` |

When it fires (1 site)

-   [`PluginUiPacksController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginUiPacksController.php#L70)[`GET /api/system/plugin-ui-packs`](https://featherpanel.com/docs/api/reference/system/plugin-ui-packs/#get-system-plugin-ui-packs)

```php
$event->on(PluginUiEvent::onUiPacksRetrieved(), function ($packs): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:packs:retrieved ' . json_encode(['packs' => $packs]));
});
```

## `PluginUiEvent::onPublicPagesRetrieved()`

- Name: `featherpanel:system:plugins:ui:public-pages:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L43)

Docblock: array public pages from Frontend/public.json aggregations.

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

When it fires (1 site)

-   [`PluginPublicPagesController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginPublicPagesController.php#L141)[`GET /api/system/plugin-public-pages`](https://featherpanel.com/docs/api/reference/system/plugin-public-pages/#get-system-plugin-public-pages)

```php
$event->on(PluginUiEvent::onPublicPagesRetrieved(), function ($pages): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:public-pages:retrieved ' . json_encode(['pages' => $pages]));
});
```

## `PluginUiEvent::onSidebarRetrieved()`

- Name: `featherpanel:system:plugins:ui:sidebar:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L27)

Docblock: array sidebar sections, array context metadata.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `sidebar` | `$sidebar` | `array` |
| 2 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`PluginSidebarController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginSidebarController.php#L260)[`GET /api/system/plugin-sidebar`](https://featherpanel.com/docs/api/reference/system/plugin-sidebar/#get-system-plugin-sidebar)

```php
$event->on(PluginUiEvent::onSidebarRetrieved(), function ($sidebar, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:sidebar:retrieved ' . json_encode(['sidebar' => $sidebar, 'context' => $context]));
});
```

## `PluginUiEvent::onThemesRetrieved()`

- Name: `featherpanel:system:plugins:ui:themes:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L59)

Docblock: array themes from Frontend/theme.json aggregations.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `themes` | `$themes` | `array` |

When it fires (1 site)

-   [`PluginThemesController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginThemesController.php#L113)[`GET /api/system/plugin-themes`](https://featherpanel.com/docs/api/reference/system/plugin-themes/#get-system-plugin-themes)

```php
$event->on(PluginUiEvent::onThemesRetrieved(), function ($themes): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:themes:retrieved ' . json_encode(['themes' => $themes]));
});
```

## `PluginUiEvent::onWidgetsRetrieved()`

- Name: `featherpanel:system:plugins:ui:widgets:retrieved`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/PluginUiEvent.php#L35)

Docblock: array widgets by page/location, array context metadata.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `widgets` | `$widgets` | `array`from docblock |
| 2 | `context` | `$context` | `array` |

When it fires (1 site)

-   [`PluginWidgetController::index`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/System/PluginWidgetController.php#L300)[`GET /api/system/plugin-widgets`](https://featherpanel.com/docs/api/reference/system/plugin-widgets/#get-system-plugin-widgets)

```php
$event->on(PluginUiEvent::onWidgetsRetrieved(), function ($widgets, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:system:plugins:ui:widgets:retrieved ' . json_encode(['widgets' => $widgets, 'context' => $context]));
});
```
