Dispatcher
class Dispatcher implements Dispatcher
Properties
protected Container | $container | The IoC container instance. |
|
protected array | $listeners | The registered event listeners. |
|
protected array | $wildcards | The wildcard listeners. |
|
protected callable | $queueResolver | The queue resolver instance. |
Methods
Register an event listener with the dispatcher.
Setup a wildcard listener callback.
Determine if a given event has listeners.
Register an event and payload to be fired later.
Flush a set of pushed events.
Register an event subscriber with the dispatcher.
Resolve the subscriber instance.
Fire an event until the first non-null response is returned.
Fire an event and call the listeners.
Fire an event and call the listeners.
Parse the given event and payload and prepare them for dispatching.
Determine if the payload has a broadcastable event.
Check if event should be broadcasted by condition.
Get all of the listeners for a given event name.
Get the wildcard listeners for the event.
Add the listeners for the event's interfaces to the given array.
Register an event listener with the dispatcher.
Create a class based listener using the IoC container.
Create the class based event callable.
Parse the class listener into class and method.
Determine if the event handler class should be queued.
Create a callable for putting an event handler on the queue.
Call the queue method on the handler class.
Queue the handler class.
Create the listener and job for a queued listener.
Propogate listener options to the job.
Remove a set of listeners from the dispatcher.
Forget all of the pushed listeners.
Get the queue implementation from the resolver.
Set the queue resolver implementation.
Details
at line 51
void
__construct(Container $container = null)
Create a new event dispatcher instance.
at line 63
void
listen(string|array $events, mixed $listener)
Register an event listener with the dispatcher.
at line 81
protected void
setupWildcardListen(string $event, mixed $listener)
Setup a wildcard listener callback.
at line 92
bool
hasListeners(string $eventName)
Determine if a given event has listeners.
at line 104
void
push(string $event, array $payload = [])
Register an event and payload to be fired later.
at line 117
void
flush(string $event)
Flush a set of pushed events.
at line 128
void
subscribe(object|string $subscriber)
Register an event subscriber with the dispatcher.
at line 141
protected mixed
resolveSubscriber(object|string $subscriber)
Resolve the subscriber instance.
at line 157
array|null
until(string|object $event, mixed $payload = [])
Fire an event until the first non-null response is returned.
at line 170
array|null
fire(string|object $event, mixed $payload = [], bool $halt = false)
Fire an event and call the listeners.
at line 183
array|null
dispatch(string|object $event, mixed $payload = [], bool $halt = false)
Fire an event and call the listeners.
at line 228
protected array
parseEventAndPayload(mixed $event, mixed $payload)
Parse the given event and payload and prepare them for dispatching.
at line 243
protected bool
shouldBroadcast(array $payload)
Determine if the payload has a broadcastable event.
at line 256
protected bool
broadcastWhen(mixed $event)
Check if event should be broadcasted by condition.
at line 268
protected void
broadcastEvent(ShouldBroadcast $event)
Broadcast the given event class.
at line 279
array
getListeners(string $eventName)
Get all of the listeners for a given event name.
at line 298
protected array
getWildcardListeners(string $eventName)
Get the wildcard listeners for the event.
at line 318
protected array
addInterfaceListeners(string $eventName, array $listeners = [])
Add the listeners for the event's interfaces to the given array.
at line 338
Closure
makeListener(string|Closure $listener, bool $wildcard = false)
Register an event listener with the dispatcher.
at line 360
Closure
createClassListener(string $listener, bool $wildcard = false)
Create a class based listener using the IoC container.
at line 379
protected callable
createClassCallable(string $listener)
Create the class based event callable.
at line 396
protected array
parseClassCallable(string $listener)
Parse the class listener into class and method.
at line 407
protected bool
handlerShouldBeQueued(string $class)
Determine if the event handler class should be queued.
at line 425
protected Closure
createQueuedHandlerCallable(string $class, string $method)
Create a callable for putting an event handler on the queue.
at line 448
protected void
callQueueMethodOnHandler(string $class, string $method, array $arguments)
Call the queue method on the handler class.
at line 465
protected void
queueHandler(string $class, string $method, array $arguments)
Queue the handler class.
at line 488
protected array
createListenerAndJob(string $class, string $method, array $arguments)
Create the listener and job for a queued listener.
at line 504
protected mixed
propogateListenerOptions(mixed $listener, mixed $job)
Propogate listener options to the job.
at line 518
void
forget(string $event)
Remove a set of listeners from the dispatcher.
at line 532
void
forgetPushed()
Forget all of the pushed listeners.
at line 546
protected Queue
resolveQueue()
Get the queue implementation from the resolver.
at line 557
$this
setQueueResolver(callable $resolver)
Set the queue resolver implementation.