class Dispatcher implements QueueingDispatcher

Traits

Properties

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 bool $allowsDispatchingAfterResponses

Indicate if dispatching after response is disabled.

Methods

mixed
getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)

Get a configuration value from an attribute, falling back to a property.

mixed
extractAttributeValue(object $instance)

Extract the value from an attribute instance.

object|null
getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)

Get an instance of the given attribute class from the target class or its parents.

bool
propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

string|null
resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

string|null
resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

queueRoutes()

Get the queue routes manager instance.

queueRoutesContainer()

Get the container that owns the queue routes.

__construct(Container $container, Closure|null $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.

void
bulk(iterable $jobs)

Dispatch multiple commands in bulk to their appropriate handlers on the queue.

Batch|null
findBatch(string $batchId)

Attempt to find the batch with the given ID.

batch(mixed $jobs)

Create a new batch of queueable jobs.

mixed
chain(mixed $jobs = null)

Create a new chain of queueable jobs.

bool
hasCommandHandler(mixed $command)

Determine if the given command has a handler.

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.

pipeThrough(array $pipes)

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

map(array $map)

Map a command to a handler.

withDispatchingAfterResponses()

Allow dispatching after responses.

withoutDispatchingAfterResponses()

Disable dispatching after responses.

Details

protected mixed getAttributeValue(object $target, string $attributeClass, string|null $property = null, mixed $default = null)

Get a configuration value from an attribute, falling back to a property.

Parameters

object $target
string $attributeClass
string|null $property
mixed $default

Return Value

mixed

protected mixed extractAttributeValue(object $instance)

Extract the value from an attribute instance.

Parameters

object $instance

Return Value

mixed

protected object|null getAttributeInstance(object $target, string $attributeClass, ReflectionClass|null $declaringClass = null)

Get an instance of the given attribute class from the target class or its parents.

Parameters

object $target
string $attributeClass
ReflectionClass|null $declaringClass

Return Value

object|null

protected bool propertyOverridesAttribute(object $target, ReflectionClass $reflection, string|null $property, ReflectionClass $attributeDeclaringClass)

Determine if a property declared on a child class overrides an inherited attribute.

Parameters

object $target
ReflectionClass $reflection
string|null $property
ReflectionClass $attributeDeclaringClass

Return Value

bool

string|null resolveConnectionFromQueueRoute(object $queueable, UnitEnum|string|null $queue = null)

Resolve the default connection name for a given queueable instance.

Parameters

object $queueable
UnitEnum|string|null $queue

the caller-selected queue, overriding the queueable's queue when resolving a forwarded connection

Return Value

string|null

string|null resolveQueueFromQueueRoute(object $queueable)

Resolve the default queue name for a given queueable instance.

Parameters

object $queueable

Return Value

string|null

protected QueueRoutes queueRoutes()

Get the queue routes manager instance.

Return Value

QueueRoutes

at line 291
protected Container queueRoutesContainer()

Get the container that owns the queue routes.

Return Value

Container

at line 53
__construct(Container $container, Closure|null $queueResolver = null)

Create a new command dispatcher instance.

Parameters

Container $container
Closure|null $queueResolver

at line 63
mixed dispatch(mixed $command)

Dispatch a command to its appropriate handler.

Parameters

mixed $command

Return Value

mixed

at line 75
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

at line 90
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

at line 122
void bulk(iterable $jobs)

Dispatch multiple commands in bulk to their appropriate handlers on the queue.

Parameters

iterable $jobs

Return Value

void

at line 164
Batch|null findBatch(string $batchId)

Attempt to find the batch with the given ID.

Parameters

string $batchId

Return Value

Batch|null

at line 172
PendingBatch batch(mixed $jobs)

Create a new batch of queueable jobs.

Parameters

mixed $jobs

Return Value

PendingBatch

at line 180
mixed chain(mixed $jobs = null)

Create a new chain of queueable jobs.

Parameters

mixed $jobs

Return Value

mixed

at line 191
bool hasCommandHandler(mixed $command)

Determine if the given command has a handler.

Parameters

mixed $command

Return Value

bool

at line 199
mixed getCommandHandler(mixed $command)

Retrieve the handler for a command.

Parameters

mixed $command

Return Value

mixed

at line 211
protected bool commandShouldBeQueued(mixed $command)

Determine if the given command should be queued.

Parameters

mixed $command

Return Value

bool

at line 221
mixed dispatchToQueue(mixed $command)

Dispatch a command to its appropriate handler behind a queue.

Parameters

mixed $command

Return Value

mixed

Exceptions

RuntimeException

at line 243
protected mixed pushCommandToQueue(Queue $queue, mixed $command)

Push the command onto the given queue instance.

Parameters

Queue $queue
mixed $command

Return Value

mixed

at line 261
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

at line 303
Dispatcher pipeThrough(array $pipes)

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

Boot-only. The pipes persist on the singleton dispatcher for the worker lifetime and apply to every subsequent dispatch; per-request use races across coroutines.

Parameters

array $pipes

Return Value

Dispatcher

at line 316
Dispatcher map(array $map)

Map a command to a handler.

Boot-only. The handler map persists on the singleton dispatcher for the worker lifetime; per-request use races across coroutines.

Parameters

array $map

Return Value

Dispatcher

at line 329
Dispatcher withDispatchingAfterResponses()

Allow dispatching after responses.

Boot-only. Toggles a flag on the singleton dispatcher for the worker lifetime; per-request use races across coroutines.

Return Value

Dispatcher

at line 342
Dispatcher withoutDispatchingAfterResponses()

Disable dispatching after responses.

Boot-only. Toggles a flag on the singleton dispatcher for the worker lifetime; per-request use races across coroutines.

Return Value

Dispatcher