class Dispatcher implements QueueingDispatcher (View source)

Properties

protected Container $container

The container implementation.

protected Pipeline $pipeline

The pipeline instance for the bus.

protected array $pipes

The pipes to send commands through before dispatching.

protected array $handlers

The command to handler mapping for non-self-handling events.

protected Closure|null $queueResolver

The queue resolver callback.

Methods

void
__construct(Container $container, Closure $queueResolver = null)

Create a new command dispatcher instance.

mixed
dispatch(mixed $command)

Dispatch a command to its appropriate handler.

mixed
dispatchSync(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler in the current process.

mixed
dispatchNow(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler in the current process without using the synchronous queue.

Batch|null
findBatch(string $batchId)

Attempt to find the batch with the given ID.

batch(Collection|array $jobs)

Create a new batch of queueable jobs.

chain(Collection|array $jobs)

Create a new chain of queueable jobs.

bool
hasCommandHandler(mixed $command)

Determine if the given command has a handler.

bool|mixed
getCommandHandler(mixed $command)

Retrieve the handler for a command.

bool
commandShouldBeQueued(mixed $command)

Determine if the given command should be queued.

mixed
dispatchToQueue(mixed $command)

Dispatch a command to its appropriate handler behind a queue.

mixed
pushCommandToQueue(Queue $queue, mixed $command)

Push the command onto the given queue instance.

void
dispatchAfterResponse(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler after the current process.

$this
pipeThrough(array $pipes)

Set the pipes through which commands should be piped before dispatching.

$this
map(array $map)

Map a command to a handler.

Details

void __construct(Container $container, Closure $queueResolver = null)

Create a new command dispatcher instance.

Parameters

Container $container
Closure $queueResolver

Return Value

void

mixed dispatch(mixed $command)

Dispatch a command to its appropriate handler.

Parameters

mixed $command

Return Value

mixed

mixed dispatchSync(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler in the current process.

Queueable jobs will be dispatched to the "sync" queue.

Parameters

mixed $command
mixed $handler

Return Value

mixed

mixed dispatchNow(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler in the current process without using the synchronous queue.

Parameters

mixed $command
mixed $handler

Return Value

mixed

Batch|null findBatch(string $batchId)

Attempt to find the batch with the given ID.

Parameters

string $batchId

Return Value

Batch|null

PendingBatch batch(Collection|array $jobs)

Create a new batch of queueable jobs.

Parameters

Collection|array $jobs

Return Value

PendingBatch

PendingChain chain(Collection|array $jobs)

Create a new chain of queueable jobs.

Parameters

Collection|array $jobs

Return Value

PendingChain

bool hasCommandHandler(mixed $command)

Determine if the given command has a handler.

Parameters

mixed $command

Return Value

bool

bool|mixed getCommandHandler(mixed $command)

Retrieve the handler for a command.

Parameters

mixed $command

Return Value

bool|mixed

protected bool commandShouldBeQueued(mixed $command)

Determine if the given command should be queued.

Parameters

mixed $command

Return Value

bool

mixed dispatchToQueue(mixed $command)

Dispatch a command to its appropriate handler behind a queue.

Parameters

mixed $command

Return Value

mixed

Exceptions

RuntimeException

protected mixed pushCommandToQueue(Queue $queue, mixed $command)

Push the command onto the given queue instance.

Parameters

Queue $queue
mixed $command

Return Value

mixed

void dispatchAfterResponse(mixed $command, mixed $handler = null)

Dispatch a command to its appropriate handler after the current process.

Parameters

mixed $command
mixed $handler

Return Value

void

$this pipeThrough(array $pipes)

Set the pipes through which commands should be piped before dispatching.

Parameters

array $pipes

Return Value

$this

$this map(array $map)

Map a command to a handler.

Parameters

array $map

Return Value

$this