/** * @param mixed $data * @return mixed|void */ public function create($data) { if (!array_key_exists('name', $data)) { return $this->apiProblem(422, "No name given for the workflow"); } $workflowId = WorkflowId::generate(); try { $command = CreateWorkflow::withName($data['name'], $workflowId); } catch (\Exception $e) { return $this->apiProblem(422, $e->getMessage()); } $this->commandBus->dispatch($command); return $this->location($this->url()->fromRoute('prooph.link/process_config/api/workflow', ['id' => $workflowId->toString()])); }
/** * @param CreateWorkflow $command */ public function handle(CreateWorkflow $command) { $workflow = $this->processingNode->setUpNewWorkflow($command->workflowId(), $command->workflowName()); $this->workflowCollection->add($workflow); }