Documentation

Dispatcher
in package
implements Dispatcher

Interfaces, Classes and Traits

Dispatcher

Table of Contents

$container  : Container
The IoC container instance.
$firing  : array<string|int, mixed>
The event firing stack.
$listeners  : array<string|int, mixed>
The registered event listeners.
$queueResolver  : callable
The queue resolver instance.
$sorted  : array<string|int, mixed>
The sorted event listeners.
$wildcards  : array<string|int, mixed>
The wildcard listeners.
__construct()  : void
Create a new event dispatcher instance.
createClassListener()  : Closure
Create a class based listener using the IoC container.
dispatch()  : array<string|int, mixed>|null
Fire an event and call the listeners.
fire()  : array<string|int, mixed>|null
Fire an event and call the listeners.
firing()  : string
Get the event that is currently firing.
flush()  : void
Flush a set of pushed events.
forget()  : void
Remove a set of listeners from the dispatcher.
forgetPushed()  : void
Forget all of the pushed listeners.
getListeners()  : array<string|int, mixed>
Get all of the listeners for a given event name.
hasListeners()  : bool
Determine if a given event has listeners.
listen()  : void
Register an event listener with the dispatcher.
makeListener()  : mixed
Register an event listener with the dispatcher.
push()  : void
Register an event and payload to be fired later.
setQueueResolver()  : $this
Set the queue resolver implementation.
subscribe()  : void
Register an event subscriber with the dispatcher.
until()  : array<string|int, mixed>|null
Fire an event until the first non-null response is returned.
broadcastEvent()  : void
Broadcast the given event class.
callQueueMethodOnHandler()  : void
Call the queue method on the handler class.
cloneArgumentsForQueueing()  : array<string|int, mixed>
Clone the given arguments for queueing.
createClassCallable()  : callable
Create the class based event callable.
createQueuedHandlerCallable()  : Closure
Create a callable for putting an event handler on the queue.
getWildcardListeners()  : array<string|int, mixed>
Get the wildcard listeners for the event.
handlerShouldBeQueued()  : bool
Determine if the event handler class should be queued.
parseClassCallable()  : array<string|int, mixed>
Parse the class listener into class and method.
resolveQueue()  : Queue
Get the queue implementation from the resolver.
resolveSubscriber()  : mixed
Resolve the subscriber instance.
setupWildcardListen()  : void
Setup a wildcard listener callback.
sortListeners()  : array<string|int, mixed>
Sort the listeners for a given event by priority.

Properties

$firing

The event firing stack.

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

$listeners

The registered event listeners.

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

$queueResolver

The queue resolver instance.

protected callable $queueResolver

$sorted

The sorted event listeners.

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

$wildcards

The wildcard listeners.

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

Methods

__construct()

Create a new event dispatcher instance.

public __construct([Container|null $container = null ]) : void
Parameters
$container : Container|null = null
Return values
void

createClassListener()

Create a class based listener using the IoC container.

public createClassListener(mixed $listener) : Closure
Parameters
$listener : mixed
Return values
Closure

dispatch()

Fire an event and call the listeners.

public dispatch(string|object $event[, mixed $payload = [] ][, bool $halt = false ]) : array<string|int, mixed>|null
Parameters
$event : string|object
$payload : mixed = []
$halt : bool = false
Return values
array<string|int, mixed>|null

fire()

Fire an event and call the listeners.

public fire(string|object $event[, mixed $payload = [] ][, bool $halt = false ]) : array<string|int, mixed>|null
Parameters
$event : string|object
$payload : mixed = []
$halt : bool = false
Return values
array<string|int, mixed>|null

firing()

Get the event that is currently firing.

public firing() : string
Return values
string

flush()

Flush a set of pushed events.

public flush(string $event) : void
Parameters
$event : string
Return values
void

forget()

Remove a set of listeners from the dispatcher.

public forget(string $event) : void
Parameters
$event : string
Return values
void

forgetPushed()

Forget all of the pushed listeners.

public forgetPushed() : void
Return values
void

getListeners()

Get all of the listeners for a given event name.

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

hasListeners()

Determine if a given event has listeners.

public hasListeners(string $eventName) : bool
Parameters
$eventName : string
Return values
bool

listen()

Register an event listener with the dispatcher.

public listen(string|array<string|int, mixed> $events, mixed $listener, int $priority) : void
Parameters
$events : string|array<string|int, mixed>
$listener : mixed
$priority : int
Return values
void

makeListener()

Register an event listener with the dispatcher.

public makeListener(mixed $listener) : mixed
Parameters
$listener : mixed
Return values
mixed

push()

Register an event and payload to be fired later.

public push(string $event[, array<string|int, mixed> $payload = [] ]) : void
Parameters
$event : string
$payload : array<string|int, mixed> = []
Return values
void

setQueueResolver()

Set the queue resolver implementation.

public setQueueResolver(callable $resolver) : $this
Parameters
$resolver : callable
Return values
$this

subscribe()

Register an event subscriber with the dispatcher.

public subscribe(object|string $subscriber) : void
Parameters
$subscriber : object|string
Return values
void

until()

Fire an event until the first non-null response is returned.

public until(string|object $event[, mixed $payload = [] ]) : array<string|int, mixed>|null
Parameters
$event : string|object
$payload : mixed = []
Return values
array<string|int, mixed>|null

callQueueMethodOnHandler()

Call the queue method on the handler class.

protected callQueueMethodOnHandler(string $class, string $method, array<string|int, mixed> $arguments) : void
Parameters
$class : string
$method : string
$arguments : array<string|int, mixed>
Return values
void

cloneArgumentsForQueueing()

Clone the given arguments for queueing.

protected cloneArgumentsForQueueing(array<string|int, mixed> $arguments) : array<string|int, mixed>
Parameters
$arguments : array<string|int, mixed>
Return values
array<string|int, mixed>

createClassCallable()

Create the class based event callable.

protected createClassCallable(string $listener, Container $container) : callable
Parameters
$listener : string
$container : Container
Return values
callable

createQueuedHandlerCallable()

Create a callable for putting an event handler on the queue.

protected createQueuedHandlerCallable(string $class, string $method) : Closure
Parameters
$class : string
$method : string
Return values
Closure

getWildcardListeners()

Get the wildcard listeners for the event.

protected getWildcardListeners(string $eventName) : array<string|int, mixed>
Parameters
$eventName : string
Return values
array<string|int, mixed>

handlerShouldBeQueued()

Determine if the event handler class should be queued.

protected handlerShouldBeQueued(string $class) : bool
Parameters
$class : string
Return values
bool

parseClassCallable()

Parse the class listener into class and method.

protected parseClassCallable(string $listener) : array<string|int, mixed>
Parameters
$listener : string
Return values
array<string|int, mixed>

resolveQueue()

Get the queue implementation from the resolver.

protected resolveQueue() : Queue
Return values
Queue

resolveSubscriber()

Resolve the subscriber instance.

protected resolveSubscriber(object|string $subscriber) : mixed
Parameters
$subscriber : object|string
Return values
mixed

setupWildcardListen()

Setup a wildcard listener callback.

protected setupWildcardListen(string $event, mixed $listener) : void
Parameters
$event : string
$listener : mixed
Return values
void

sortListeners()

Sort the listeners for a given event by priority.

protected sortListeners(string $eventName) : array<string|int, mixed>
Parameters
$eventName : string
Return values
array<string|int, mixed>

Search results