public function proceed(ProcessStateInterface $process_state, EventInterface $event = null) { $execution_context = $process_state->getExecutionContext(); if ($event) { $execution_context->setParameter('incoming_event', $event); $state = $this->state_machine->execute($process_state, $event->getType()); $execution_context->removeParameter('incoming_event', $event); } else { $state = $this->state_machine->execute($process_state); } $commands = new CommandList(); if ($execution_context->hasParameter('command')) { $command = $execution_context->getParameter('command'); if (!$command instanceof CommandInterface) { throw new RuntimeError(sprintf('Unexpected return type for execution-context var "command". Type of "%s" expected.', CommandInterface::CLASS)); } $commands->push($command); $execution_context->removeParameter('command'); } if ($execution_context->hasParameter('commands')) { $command_list = $execution_context->getParameter('commands'); if (!$command_list instanceof CommandList) { throw new RuntimeError(sprintf('Unexpected return type for execution-context var "commands". Type of "%s" expected.', CommandList::CLASS)); } $commands->append($command_list); $execution_context->removeParameter('commands'); } return $commands; }
protected function getPayloadIdentifier(ProcessStateInterface $process_state) { $identifier_path = $this->options->get('identifier_payload_path', false); $jmes_path_runtime = new AstRuntime(); $identifier = $jmes_path_runtime($identifier_path, $process_state->getPayload()); if (!$identifier) { throw new RuntimeError('Unable to resolve required "identifier" from payload-path:' . $identifier_path . ' within ' . $process_state->getExecutionContext()->getStateMachineName()); } return $identifier; }
protected function getProjection(ProcessStateInterface $process_state) { return $process_state->getExecutionContext()->getParameter($this->options->get('projection_key')); }