# CloudPluginsEvent events

> 2 FeatherPanel plugin events on CloudPluginsEvent (1 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/cloud-plugins/

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

## Setup

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

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(CloudPluginsEvent::onPluginInstalled(), function ($identifier, $pluginData, $userUuid): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:cloud:plugin:installed ' . json_encode(['identifier' => $identifier, 'plugin_data' => $pluginData, 'user_uuid' => $userUuid]));
        });
    }

    public static function pluginInstall(): void
    {
    }

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

## `CloudPluginsEvent::onPluginInstalled()`

- Name: `featherpanel:cloud:plugin:installed`
- emitted at 2 sites
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/CloudPluginsEvent.php#L27)

Docblock: string identifier, array plugin data, string user uuid.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `identifier` | `$identifier` | `string`from docblock |
| 2 | `plugin_data` | `$pluginData` | `array`from docblock |
| 3 | `user_uuid` | `$userUuid` | `string`from docblock |

When it fires (2 sites)

-   [`CloudPluginsController::install`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/CloudPluginsController.php#L966)[`POST /api/admin/plugins/online/install`](https://featherpanel.com/docs/api/reference/admin/cloud-plugins/#post-admin-plugins-online-install)
-   [`CloudPluginsController::install`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Controllers/Admin/CloudPluginsController.php#L966)[`POST /api/admin/plugins/online/install`](https://featherpanel.com/docs/api/reference/admin/cloud-plugins/#post-admin-plugins-online-install)

```php
$event->on(CloudPluginsEvent::onPluginInstalled(), function ($identifier, $pluginData, $userUuid): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:cloud:plugin:installed ' . json_encode(['identifier' => $identifier, 'plugin_data' => $pluginData, 'user_uuid' => $userUuid]));
});
```

## `CloudPluginsEvent::onPluginUninstalled()`

- Name: `featherpanel:cloud:plugin:uninstalled`
- not emitted
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/CloudPluginsEvent.php#L35)

Docblock: string identifier, string user uuid.

```php
$event->on(CloudPluginsEvent::onPluginUninstalled(), function (...$args): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:cloud:plugin:uninstalled ' . json_encode($args));
});
```

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