Prooph\ServiceBus\QueryBus::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_FINDER, function (ActionEvent $actionEvent) {
            $finder = $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLER);
            if (is_callable($finder)) {
                $query = $actionEvent->getParam(self::EVENT_PARAM_MESSAGE);
                $deferred = $actionEvent->getParam(self::EVENT_PARAM_DEFERRED);
                $finder($query, $deferred);
                $actionEvent->setParam(self::EVENT_PARAM_MESSAGE_HANDLED, true);
            }
        });
        $this->events = $actionEventDispatcher;
    }