/**
  * @param ChangeWorkflowName $command
  * @throws Exception\WorkflowNotFound
  */
 public function handle(ChangeWorkflowName $command)
 {
     $workflow = $this->workflowCollection->get($command->workflowId());
     if (is_null($workflow)) {
         throw WorkflowNotFound::withId($command->workflowId());
     }
     $workflow->changeName($command->name());
 }
예제 #2
0
 public function update($id, $data)
 {
     if (!array_key_exists('name', $data)) {
         return $this->apiProblem(422, "No name given for the workflow");
     }
     try {
         $this->commandBus->dispatch(ChangeWorkflowName::to($data['name'], $id));
     } catch (CommandDispatchException $ex) {
         if ($ex->getFailedCommandDispatch()->getException() instanceof WorkflowNotFound) {
             return $this->apiProblem(404, "Workflow not found");
         } else {
             throw $ex->getFailedCommandDispatch()->getException();
         }
     }
     return $this->accepted();
 }