Prooph\ServiceBus\CommandBus::processCommand PHP Method

processCommand() protected method

protected processCommand ( $command )
    protected function processCommand($command)
    {
        $actionEvent = $this->getActionEventEmitter()->getNewActionEvent();
        $actionEvent->setTarget($this);
        try {
            $this->initialize($command, $actionEvent);
            if ($actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLER) === null) {
                $actionEvent->setName(self::EVENT_ROUTE);
                $this->trigger($actionEvent);
            }
            if ($actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLER) === null) {
                throw new RuntimeException(sprintf("CommandBus was not able to identify a CommandHandler for command %s", $this->getMessageName($command)));
            }
            $handler = $actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLER);
            if (is_string($handler) && !is_callable($handler)) {
                $actionEvent->setName(self::EVENT_LOCATE_HANDLER);
                $this->trigger($actionEvent);
            }
            $actionEvent->setName(self::EVENT_INVOKE_HANDLER);
            $this->trigger($actionEvent);
            if (!$actionEvent->getParam(self::EVENT_PARAM_MESSAGE_HANDLED)) {
                throw new RuntimeException(sprintf('Command %s was not handled', $this->getMessageName($command)));
            }
            $this->triggerFinalize($actionEvent);
        } catch (\Exception $ex) {
            $this->handleException($actionEvent, $ex);
        }
    }