EmitterInterface
extends
ListenerAcceptorInterface
in
Table of Contents
Constants
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
P_HIGH
High priority.
public
mixed
P_HIGH
= 100
Tags
P_LOW
Low priority.
public
mixed
P_LOW
= -100
Tags
P_NORMAL
Normal priority.
public
mixed
P_NORMAL
= 0
Tags
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
$thisaddOneTimeListener()
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
$thisemit()
Emit an event.
public
emit(string|EventInterface $event) : EventInterface
Parameters
- $event : string|EventInterface
Return values
EventInterfaceemitBatch()
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>emitGeneratedEvents()
Release all events stored in a generator
public
emitGeneratedEvents(GeneratorInterface $generator) : array<string|int, EventInterface>
Parameters
- $generator : GeneratorInterface
Return values
array<string|int, EventInterface>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
boolremoveAllListeners()
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
$thisremoveListener()
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
$thisuseListenerProvider()
Use a provider to add listeners.
public
useListenerProvider(ListenerProviderInterface $provider) : $this
Parameters
- $provider : ListenerProviderInterface