Skip to content

Ability to dispatch a Command to its Handler #7

@keithmifsud

Description

@keithmifsud

The Command Bus:

Given an instance of a CommandHandlerResolver, it should be able to dispatch the command to the Handler.

Like so:

// An array of commands with handlers.
$commandsWithHandlers = [
    Domain\Command\DoSometing::class =>
        Domain\Hanlder\DoSomething::class,

    Domain\Command\DoSomethingElse::class =>
        Domain\Handler\DoSomethingElse::class,
];


$commandBus = new \SwellPhp\Admiral\CommandBus(
    new \SwellPhp\Admiral\ArrayResolver($commandsWithHandlers)
);

// Instantiates the command.
$command = new \Domain\Command\DoSometing(
    'some',
    'parameters'
);

// Dispath a command and it will be handled in the backgound.
$commandBus->dispatch($command)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions