Documentation

EmitterInterface extends ListenerAcceptorInterface

Table of Contents

Constants

P_HIGH  = 100
High priority.
P_LOW  = -100
Low priority.
P_NORMAL  = 0
Normal priority.

Methods

addListener()  : $this
Add a listener for an event.
addOneTimeListener()  : $this
Add a one time listener for an event.
emit()  : EventInterface
Emit an event.
emitBatch()  : array<string|int, mixed>
Emit a batch of events.
emitGeneratedEvents()  : array<string|int, EventInterface>
Release all events stored in a generator
getListeners()  : array<string|int, mixed>
Get all the listeners for an event.
hasListeners()  : bool
Check whether an event has listeners.
removeAllListeners()  : $this
Remove all listeners for an event.
removeListener()  : $this
Remove a specific listener for an event.
useListenerProvider()  : $this
Use a provider to add listeners.

Constants

Methods

addListener()

Add a listener for an event.

public addListener(string $event, ListenerInterface|callable $listener[, int $priority = self::P_NORMAL ]) : $this

The first parameter should be the event name, and the second should be the event listener. It may implement the League\Event\ListenerInterface or simply be "callable". In this case, the priority emitter also accepts an optional third parameter specifying the priority as an integer. You may use one of our predefined constants here if you want.

Parameters
$event : string
$listener : ListenerInterface|callable
$priority : int = self::P_NORMAL
Return values
$this

addOneTimeListener()

Add a one time listener for an event.

public addOneTimeListener(string $event, ListenerInterface|callable $listener[, int $priority = self::P_NORMAL ]) : $this

The first parameter should be the event name, and the second should be the event listener. It may implement the League\Event\ListenerInterface or simply be "callable".

Parameters
$event : string
$listener : ListenerInterface|callable
$priority : int = self::P_NORMAL
Return values
$this

emitBatch()

Emit a batch of events.

public emitBatch(array<string|int, mixed> $events) : array<string|int, mixed>
Parameters
$events : array<string|int, mixed>
Return values
array<string|int, mixed>

getListeners()

Get all the listeners for an event.

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

The first parameter should be the event name. We'll return an array of all the registered even listeners, or an empty array if there are none.

Parameters
$event : string
Return values
array<string|int, mixed>

hasListeners()

Check whether an event has listeners.

public hasListeners(string $event) : bool

The first parameter should be the event name. We'll return true if the event has one or more registered even listeners, and false otherwise.

Parameters
$event : string
Return values
bool

removeAllListeners()

Remove all listeners for an event.

public removeAllListeners(string $event) : $this

The first parameter should be the event name. All event listeners will be removed.

Parameters
$event : string
Return values
$this

removeListener()

Remove a specific listener for an event.

public removeListener(string $event, ListenerInterface|callable $listener) : $this

The first parameter should be the event name, and the second should be the event listener. It may implement the League\Event\ListenerInterface or simply be "callable".

Parameters
$event : string
$listener : ListenerInterface|callable
Return values
$this

        
On this page

Search results