Dispatcher

class Dispatcher implements Dispatcher, QueueingDispatcher, HandlerResolver (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 Closure|null $queueResolver The queue resolver callback.
protected array $mappings All of the command-to-handler mappings.
protected Closure $mapper The fallback mapping Closure.

Methods

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

Create a new command dispatcher instance.

mixed dispatchFromArray(mixed $command, array $array)

Marshal a command and dispatch it to its appropriate handler.

mixed dispatchFrom(mixed $command, ArrayAccess $source, array $extras = [])

Marshal a command and dispatch it to its appropriate handler.

mixed marshalFromArray(string $command, array $array)

Marshal a command from the given array.

mixed marshal(string $command, ArrayAccess $source, array $extras = [])

Marshal a command from the given array accessible object.

mixed getParameterValueForCommand(string $command, ArrayAccess $source, ReflectionParameter $parameter, array $extras = [])

Get a parameter value for a marshalled command.

mixed dispatch(mixed $command, Closure $afterResolving = null)

Dispatch a command to its appropriate handler.

mixed dispatchNow(mixed $command, Closure $afterResolving = null)

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

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.

mixed resolveHandler(mixed $command)

Get the handler instance for the given command.

string getHandlerClass(mixed $command)

Get the handler class for the given command.

string getHandlerMethod(mixed $command)

Get the handler method for the given command.

string inflectSegment(mixed $command, int $segment)

Get the given handler segment for the given command.

string getMappingSegment(string $className, int $segment)

Get the given segment from a given class handler.

string getMapperSegment(mixed $command, int $segment)

Get the given segment from a given class handler using the custom mapper.

void maps(array $commands)

Register command-to-handler mappings.

void mapUsing(Closure $mapper)

Register a fallback mapper callback.

static string simpleMapping(mixed $command, string $commandNamespace, string $handlerNamespace)

Map the command to a handler within a given root namespace.

$this pipeThrough(array $pipes)

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

Details

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

Create a new command dispatcher instance.

Parameters

Container $container
Closure $queueResolver

Return Value

void

mixed dispatchFromArray(mixed $command, array $array)

Marshal a command and dispatch it to its appropriate handler.

Parameters

mixed $command
array $array

Return Value

mixed

mixed dispatchFrom(mixed $command, ArrayAccess $source, array $extras = [])

Marshal a command and dispatch it to its appropriate handler.

Parameters

mixed $command
ArrayAccess $source
array $extras

Return Value

mixed

protected mixed marshalFromArray(string $command, array $array)

Marshal a command from the given array.

Parameters

string $command
array $array

Return Value

mixed

protected mixed marshal(string $command, ArrayAccess $source, array $extras = [])

Marshal a command from the given array accessible object.

Parameters

string $command
ArrayAccess $source
array $extras

Return Value

mixed

protected mixed getParameterValueForCommand(string $command, ArrayAccess $source, ReflectionParameter $parameter, array $extras = [])

Get a parameter value for a marshalled command.

Parameters

string $command
ArrayAccess $source
ReflectionParameter $parameter
array $extras

Return Value

mixed

mixed dispatch(mixed $command, Closure $afterResolving = null)

Dispatch a command to its appropriate handler.

Parameters

mixed $command
Closure $afterResolving

Return Value

mixed

mixed dispatchNow(mixed $command, Closure $afterResolving = null)

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

Parameters

mixed $command
Closure $afterResolving

Return Value

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

mixed resolveHandler(mixed $command)

Get the handler instance for the given command.

Parameters

mixed $command

Return Value

mixed

string getHandlerClass(mixed $command)

Get the handler class for the given command.

Parameters

mixed $command

Return Value

string

string getHandlerMethod(mixed $command)

Get the handler method for the given command.

Parameters

mixed $command

Return Value

string

protected string inflectSegment(mixed $command, int $segment)

Get the given handler segment for the given command.

Parameters

mixed $command
int $segment

Return Value

string

protected string getMappingSegment(string $className, int $segment)

Get the given segment from a given class handler.

Parameters

string $className
int $segment

Return Value

string

protected string getMapperSegment(mixed $command, int $segment)

Get the given segment from a given class handler using the custom mapper.

Parameters

mixed $command
int $segment

Return Value

string

void maps(array $commands)

Register command-to-handler mappings.

Parameters

array $commands

Return Value

void

void mapUsing(Closure $mapper)

Register a fallback mapper callback.

Parameters

Closure $mapper

Return Value

void

static string simpleMapping(mixed $command, string $commandNamespace, string $handlerNamespace)

Map the command to a handler within a given root namespace.

Parameters

mixed $command
string $commandNamespace
string $handlerNamespace

Return Value

string

$this pipeThrough(array $pipes)

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

Parameters

array $pipes

Return Value

$this

© Taylor Otwell
Licensed under the MIT License.
Laravel is a trademark of Taylor Otwell.
https://laravel.com/api/5.1/Illuminate/Bus/Dispatcher.html