Documentation

EventHandler
in package

Handles registering and triggering events.

Tags
author

Samerton

author

Aberdeener

version
2.3.0
license

MIT

Table of Contents

Properties

$_events  : array<string|int, mixed>
$_webhooks  : array<string|int, mixed>

Methods

executeEvent()  : T
Execute an event.
getEvent()  : array<string|int, mixed>
Get data about an event.
getEvents()  : array<string|int, mixed>
Get a list of events to display on the StaffCP webhooks page.
registerEvent()  : void
Register an event.
registerListener()  : void
Register an event listener for a module.
registerWebhooks()  : void
Register webhooks.

Properties

$_events

private static array<string|int, mixed> $_events = []

$_webhooks

private static array<string|int, mixed> $_webhooks = []

Methods

executeEvent()

Execute an event.

public static executeEvent(T $event) : T
Parameters
$event : T
Tags
template

T of AbstractEvent

Return values
T

getEvent()

Get data about an event.

public static getEvent(string $event) : array<string|int, mixed>

Not used internally, currently for WebSend.

Parameters
$event : string

Name of event to get data for.

Tags
returns

array Event data.

Return values
array<string|int, mixed>

getEvents()

Get a list of events to display on the StaffCP webhooks page.

public static getEvents([bool $showInternal = false ]) : array<string|int, mixed>
Parameters
$showInternal : bool = false
Return values
array<string|int, mixed>

List of all currently registered events

registerEvent()

Register an event.

public static registerEvent(AbstractEvent> $event) : void

This must be called in the module's constructor.

Parameters
$event : AbstractEvent>

Event to add.

Tags
throws
Exception

registerListener()

Register an event listener for a module.

public static registerListener(AbstractEvent> $event, callable|class-string $callback[, int $priority = 10 ]) : void

This must be called in the module's constructor.

Parameters
$event : AbstractEvent>

Event to listen to.

$callback : callable|class-string

Listener callback to execute when event is executed. If class name is provided, we will assume there is a static "execute" method on the class.

$priority : int = 10

Execution priority - higher gets executed first

Tags
throws
Exception

registerWebhooks()

Register webhooks.

public static registerWebhooks(array<string|int, mixed> $webhooks) : void
Parameters
$webhooks : array<string|int, mixed>

Array of webhooks to register


        
On this page

Search results