EmitterTrait
Table of Contents
Methods
- addListener() : $this
- Add a listener for an event.
- addOneTimeListener() : $this
- Add a one time listener for an event.
- emit() : EventInterface
- Emit an event.
- removeAllListeners() : $this
- Remove all listeners for an event.
- removeListener() : $this
- Remove a specific listener for an event.
- useListenerProvider() : $this
- Add listeners from a provider.
Methods
addListener()
Add a listener for an event.
public
addListener(string $event, ListenerInterface|callable $listener[, int $priority = ListenerAcceptorInterface::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 = ListenerAcceptorInterface::P_NORMAL
Return values
$thisaddOneTimeListener()
Add a one time listener for an event.
public
addOneTimeListener(string $event, ListenerInterface|callable $listener[, int $priority = ListenerAcceptorInterface::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 = ListenerAcceptorInterface::P_NORMAL
Return values
$thisemit()
Emit an event.
public
emit(string|EventInterface $event) : EventInterface
Parameters
- $event : string|EventInterface
Return values
EventInterfaceremoveAllListeners()
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()
Add listeners from a provider.
public
useListenerProvider(ListenerProviderInterface $provider) : $this
Parameters
- $provider : ListenerProviderInterface