Prooph\ServiceBus\CommandBus::setActionEventEmitter PHP Method

setActionEventEmitter() public method

Inject an ActionEventDispatcher instance
public setActionEventEmitter ( Prooph\Common\Event\ActionEventEmitter $actionEventDispatcher ) : void
$actionEventDispatcher Prooph\Common\Event\ActionEventEmitter
return void
    public function setActionEventEmitter(ActionEventEmitter $actionEventDispatcher)
    {
        $actionEventDispatcher->attachListener(self::EVENT_INVOKE_HANDLER, function (ActionEvent $actionEvent) {
            $commandHandler = $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLER);
            if (is_callable($commandHandler)) {
                $command = $actionEvent->getParam(self::EVENT_PARAM_MESSAGE);
                $commandHandler($command);
                $actionEvent->setParam(self::EVENT_PARAM_MESSAGE_HANDLED, true);
            }
        });
        $this->events = $actionEventDispatcher;
    }