Dispatcher
Implements
Uses
Properties
$listeners array
The registered event listeners.
$wildcards array
The wildcard listeners.
$wildcardsCache array
The cached wildcard listeners.
$queueResolver callable
The queue resolver instance.
Methods
__construct ( Container $container ) : void
Create a new event dispatcher instance.
Parameters
- $container Container |null
listen ( $events , $listener ) : void
Register an event listener with the dispatcher.
Parameters
setupWildcardListen ( $event , $listener ) : void
Setup a wildcard listener callback.
Parameters
- $event string
- $listener Closure |string
hasListeners ( $eventName ) : bool
Determine if a given event has listeners.
Parameters
- $eventName string
hasWildcardListeners ( $eventName ) : bool
Determine if the given event has any wildcard listeners.
Parameters
- $eventName string
push ( $event , $payload ) : void
Register an event and payload to be fired later.
Parameters
- $event string
- $payload object|array
flush ( $event ) : void
Flush a set of pushed events.
Parameters
- $event string
subscribe ( $subscriber ) : void
Register an event subscriber with the dispatcher.
Parameters
- $subscriber object|string
resolveSubscriber ( $subscriber ) : mixed
Resolve the subscriber instance.
Parameters
- $subscriber object|string
until ( $event , $payload ) : mixed
Fire an event until the first non-null response is returned.
Parameters
- $event string|object
- $payload mixed
dispatch ( $event , $payload , $halt ) : array|null
Fire an event and call the listeners.
Parameters
- $event string|object
- $payload mixed
- $halt bool
parseEventAndPayload ( $event , $payload ) : array
Parse the given event and payload and prepare them for dispatching.
Parameters
- $event mixed
- $payload mixed
shouldBroadcast ( array $payload ) : bool
Determine if the payload has a broadcastable event.
Parameters
- $payload array
broadcastWhen ( $event ) : bool
Check if the event should be broadcasted by the condition.
Parameters
- $event mixed
broadcastEvent ( $event ) : void
Broadcast the given event class.
Parameters
- $event ShouldBroadcast
getListeners ( $eventName ) : array
Get all of the listeners for a given event name.
Parameters
- $eventName string
getWildcardListeners ( $eventName ) : array
Get the wildcard listeners for the event.
Parameters
- $eventName string
addInterfaceListeners ( $eventName , array $listeners ) : array
Add the listeners for the event's interfaces to the given array.
Parameters
- $eventName string
- $listeners array
prepareListeners ( string $eventName ) : Closure[]
Prepare the listeners for a given event.
Parameters
- $eventName string
makeListener ( $listener , $wildcard ) : Closure
Register an event listener with the dispatcher.
Parameters
- $listener Closure |string|array
- $wildcard bool
createClassListener ( $listener , $wildcard ) : Closure
Create a class based listener using the IoC container.
Parameters
- $listener string
- $wildcard bool
createClassCallable ( $listener ) : callable
Create the class based event callable.
Parameters
- $listener array|string
parseClassCallable ( $listener ) : array
Parse the class listener into class and method.
Parameters
- $listener string
handlerShouldBeQueued ( $class ) : bool
Determine if the event handler class should be queued.
Parameters
- $class string
createQueuedHandlerCallable ( $class , $method ) : Closure
Create a callable for putting an event handler on the queue.
Parameters
- $class string
- $method string
handlerShouldBeDispatchedAfterDatabaseTransactions ( $listener ) : bool
Determine if the given event handler should be dispatched after all database transactions have committed.
Parameters
- $listener object|mixed
createCallbackForListenerRunningAfterCommits ( $listener , $method ) : Closure
Create a callable for dispatching a listener after database transactions.
Parameters
- $listener mixed
- $method string
handlerWantsToBeQueued ( $class , $arguments ) : bool
Determine if the event handler wants to be queued.
Parameters
- $class string
- $arguments array
queueHandler ( $class , $method , $arguments ) : void
Queue the handler class.
Parameters
- $class string
- $method string
- $arguments array
createListenerAndJob ( $class , $method , $arguments ) : array
Create the listener and job for a queued listener.
Parameters
- $class string
- $method string
- $arguments array
propagateListenerOptions ( $listener , $job ) : mixed
Propagate listener options to the job.
Parameters
- $listener mixed
- $job CallQueuedListener
forget ( $event ) : void
Remove a set of listeners from the dispatcher.
Parameters
- $event string
forgetPushed ( ) : void
Forget all of the pushed listeners.
setQueueResolver ( callable $resolver ) : $this
Set the queue resolver implementation.
Parameters
- $resolver callable
getRawListeners ( ) : array
Gets the raw, unprepared listeners.