Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 717 Bytes

command_bus.md

File metadata and controls

23 lines (16 loc) · 717 Bytes

Command bus

The command bus is designed to handle commands. It's a publish–subscribe pattern.

You can use HandlerLocatedCommandBus. This bus use CommandHandlerLocator for search the handler for specific command.

use GpsLab\Component\Command\Bus\HandlerLocatedCommandBus;
use GpsLab\Component\Command\Handler\Locator\DirectBindingCommandHandlerLocator;

$locator = new DirectBindingCommandHandlerLocator();
$bus = new HandlerLocatedCommandBus($locator);

$command = new RenameArticleCommand();
$command->new_name = $new_name;

$bus->handle($command);

You can create custom bus implementing the interface CommandBus.