# RedirectLinksEvent events

> 7 FeatherPanel plugin events on RedirectLinksEvent (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/redirect-links/

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

class MyPlugin implements AppPlugin
{
    public static function processEvents(PluginEvents $event): void
    {
        $event->on(RedirectLinksEvent::onRedirectLinksError(), function ($error, $context): void {
            App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:error ' . json_encode(['error' => $error, 'context' => $context]));
        });
    }

    public static function pluginInstall(): void
    {
    }

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

## `RedirectLinksEvent::onRedirectLinksError()`

- Name: `featherpanel:admin:redirect_links:error`
- emitted at 3 sites
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/RedirectLinksEvent.php#L69)

Docblock: string error message, array context.

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

When it fires (3 sites)

-   [`RedirectLink::create`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L139)
-   [`RedirectLink::update`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L169)
-   [`RedirectLink::delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L196)

```php
$event->on(RedirectLinksEvent::onRedirectLinksError(), function ($error, $context): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:error ' . json_encode(['error' => $error, 'context' => $context]));
});
```

## `RedirectLinksEvent::onRedirectLinkCreated()`

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

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

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `link_id` | `$linkId` | `int` |
| 2 | `link` | `$link` | `array` |

When it fires (1 site)

-   [`RedirectLink::create`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L131)

```php
$event->on(RedirectLinksEvent::onRedirectLinkCreated(), function ($linkId, $link): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:link:created ' . json_encode(['link_id' => $linkId, 'link' => $link]));
});
```

## `RedirectLinksEvent::onRedirectLinkDeleted()`

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

Docblock: int link id, array link data.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `link_id` | `$linkId` | `int` |
| 2 | `link` | `$link` | `array`from docblock |

When it fires (1 site)

-   [`RedirectLink::delete`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L191)

```php
$event->on(RedirectLinksEvent::onRedirectLinkDeleted(), function ($linkId, $link): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:link:deleted ' . json_encode(['link_id' => $linkId, 'link' => $link]));
});
```

## `RedirectLinksEvent::onRedirectLinkNotFound()`

- Name: `featherpanel:admin:redirect_links:link:not:found`
- emitted at 1 site
- Cancel or modify: no
- [definition](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Plugins/Events/Events/RedirectLinksEvent.php#L77)

Docblock: int link id, string error message.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `link_id` | `$linkId` | `int` |
| 2 | `error` | `$error` | `string` |

When it fires (1 site)

-   [`RedirectLink::getById`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L66)

```php
$event->on(RedirectLinksEvent::onRedirectLinkNotFound(), function ($linkId, $error): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:link:not:found ' . json_encode(['link_id' => $linkId, 'error' => $error]));
});
```

## `RedirectLinksEvent::onRedirectLinkRetrieved()`

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

Docblock: int link id, array link data.

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `link_id` | `$linkId` | `int` |
| 2 | `link` | `$link` | `array`from docblock |

When it fires (1 site)

-   [`RedirectLink::getById`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L58)

```php
$event->on(RedirectLinksEvent::onRedirectLinkRetrieved(), function ($linkId, $link): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:link:retrieved ' . json_encode(['link_id' => $linkId, 'link' => $link]));
});
```

## `RedirectLinksEvent::onRedirectLinkUpdated()`

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

Docblock: int link id, array old data, array new data. (the emitter passes 2 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `link_id` | `$linkId` | `int` |
| 2 | `link` | `$link` | `array` |

When it fires (1 site)

-   [`RedirectLink::update`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L164)

```php
$event->on(RedirectLinksEvent::onRedirectLinkUpdated(), function ($linkId, $link): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:link:updated ' . json_encode(['link_id' => $linkId, 'link' => $link]));
});
```

## `RedirectLinksEvent::onRedirectLinksRetrieved()`

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

Docblock: array links list. (the emitter passes 3 values, see the table)

| # | Payload key | Listener parameter | Type |
| --- | --- | --- | --- |
| 1 | `links` | `$links` | not declared |
| 2 | `page` | `$page` | `int` |
| 3 | `limit` | `$limit` | `int` |

When it fires (1 site)

-   [`RedirectLink::getAll`](https://github.com/MythicalLTD/FeatherPanel/blob/15b94e9fc9df233123706b47c42728b81e48cb3d/backend/app/Chat/RedirectLink.php#L40)

```php
$event->on(RedirectLinksEvent::onRedirectLinksRetrieved(), function ($links, $page, $limit): void {
    App::getInstance(true)->getLogger()->info('[myplugin] featherpanel:admin:redirect_links:retrieved ' . json_encode(['page' => $page, 'limit' => $limit]));
});
```
