Documentation

Emitter
in package
implements EmitterInterface

Table of Contents

Interfaces

EmitterInterface

Properties

$listeners  : array<string|int, mixed>
The registered listeners.
$sortedListeners  : array<string|int, ListenerInterface>
The sorted listeners

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.
clearSortedListeners()  : mixed
Clear the sorted listeners for an event
ensureEvent()  : EventInterface
Ensure event input is of type EventInterface or convert it.
ensureListener()  : ListenerInterface
Ensure the input is a listener.
getSortedListeners()  : array<string|int, ListenerInterface>
Get the listeners sorted by priority for a given event.
invokeListeners()  : void
Invoke the listeners for an event.
prepareEvent()  : array<string|int, mixed>
Prepare an event for emitting.

Properties

$listeners

The registered listeners.

protected array<string|int, mixed> $listeners = []

$sortedListeners

The sorted listeners

protected array<string|int, ListenerInterface> $sortedListeners = []

Listeners will get sorted and stored for re-use.

Methods

addListener()

Add a listener for an event.

public addListener(mixed $event, mixed $listener[, mixed $priority = self::P_NORMAL ]) : $this
Parameters
$event : mixed
$listener : mixed
$priority : mixed = self::P_NORMAL
Tags
inheritdoc
Return values
$this

addOneTimeListener()

Add a one time listener for an event.

public addOneTimeListener(mixed $event, mixed $listener[, mixed $priority = self::P_NORMAL ]) : $this
Parameters
$event : mixed
$listener : mixed
$priority : mixed = self::P_NORMAL
Tags
inheritdoc
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>
Tags
inheritdoc
Return values
array<string|int, mixed>

getListeners()

Get all the listeners for an event.

public getListeners(mixed $event) : array<string|int, mixed>
Parameters
$event : mixed
Tags
inheritdoc
Return values
array<string|int, mixed>

hasListeners()

Check whether an event has listeners.

public hasListeners(mixed $event) : bool
Parameters
$event : mixed
Tags
inheritdoc
Return values
bool

removeAllListeners()

Remove all listeners for an event.

public removeAllListeners(mixed $event) : $this
Parameters
$event : mixed
Tags
inheritdoc
Return values
$this

removeListener()

Remove a specific listener for an event.

public removeListener(mixed $event, mixed $listener) : $this
Parameters
$event : mixed
$listener : mixed
Tags
inheritdoc
Return values
$this

clearSortedListeners()

Clear the sorted listeners for an event

protected clearSortedListeners(mixed $event) : mixed
Parameters
$event : mixed

getSortedListeners()

Get the listeners sorted by priority for a given event.

protected getSortedListeners(string $event) : array<string|int, ListenerInterface>
Parameters
$event : string
Return values
array<string|int, ListenerInterface>

invokeListeners()

Invoke the listeners for an event.

protected invokeListeners(string $name, EventInterface $event, array<string|int, mixed> $arguments) : void
Parameters
$name : string
$event : EventInterface
$arguments : array<string|int, mixed>

prepareEvent()

Prepare an event for emitting.

protected prepareEvent(string|EventInterface $event) : array<string|int, mixed>
Parameters
$event : string|EventInterface
Return values
array<string|int, mixed>

        
On this page

Search results