class CommandBus implements CommandBusInterface

Command bus.

Constants

COMMAND_SUFFIX

Command suffix.

HANDLER_SUFFIX

Handler suffix.

Properties

protected Container $container Container.
protected Onion $onion Onion.

Methods

__construct(Container|null $container = null, Onion|null $onion = null)

Constructor.

int
addMiddleware(string $middleware, bool $inner = true)

Adds middleware.

resolveCommand(CommandInterface|string $command, array $parameters)

Resolves the command.

resolveCommandHandler(CommandInterface $command)

Resolves the command handler.

mixed
executeCommandHandler(CommandHandlerInterface $handler, CommandInterface $command)

Executes the command handler.

mixed
handle(CommandInterface $command)

Handles the command.

resolveOnion(array $middleware)

Resolves the onion instance.

mixed
dispatch(CommandInterface|string $command, array $parameters = [], array $middleware = [])

Dispatches the command to the command handler and returns the result.

Details

at line 55
__construct(Container|null $container = null, Onion|null $onion = null)

Constructor.

Parameters

Container|null $container Container
Onion|null $onion Onion

at line 69
int addMiddleware(string $middleware, bool $inner = true)

Adds middleware.

Parameters

string $middleware Middleware class
bool $inner Add an inner layer?

Return Value

int

at line 81
protected CommandInterface resolveCommand(CommandInterface|string $command, array $parameters)

Resolves the command.

Parameters

CommandInterface|string $command Command
array $parameters Parameters

Return Value

CommandInterface

at line 97
protected CommandHandlerInterface resolveCommandHandler(CommandInterface $command)

Resolves the command handler.

Parameters

CommandInterface $command Command

Return Value

CommandHandlerInterface

at line 126
protected mixed executeCommandHandler(CommandHandlerInterface $handler, CommandInterface $command)

Executes the command handler.

Parameters

CommandHandlerInterface $handler Command handler
CommandInterface $command Command

Return Value

mixed

at line 137
protected mixed handle(CommandInterface $command)

Handles the command.

Parameters

CommandInterface $command Command

Return Value

mixed

at line 155
protected Onion resolveOnion(array $middleware)

Resolves the onion instance.

Parameters

array $middleware Middleware

Return Value

Onion

at line 175
mixed dispatch(CommandInterface|string $command, array $parameters = [], array $middleware = [])

Dispatches the command to the command handler and returns the result.

Parameters

CommandInterface|string $command Command
array $parameters Parameters
array $middleware Middleware

Return Value

mixed