Esempio n. 1
0
 public function create($connection)
 {
     if (!array_key_exists('type', $connection)) {
         return $this->apiProblem(422, "No type given for the connection");
     }
     if (!array_key_exists('message_handler', $connection)) {
         return $this->apiProblem(422, "No message_handler given for the connection");
     }
     if (!array_key_exists('workflow_id', $connection)) {
         return $this->apiProblem(422, "No workflow_id given for the connection");
     }
     if ($connection['type'] == "start_connection") {
         if (!array_key_exists('start_message', $connection)) {
             return $this->apiProblem(422, "No start_message given for the connection");
         }
         $this->commandBus->dispatch(ScheduleFirstTasksForWorkflow::withData($connection['workflow_id'], $connection['start_message'], $connection['message_handler']));
         return $this->accepted();
     } elseif ($connection['type'] == "source_target_connection") {
         if (!array_key_exists('previous_task', $connection)) {
             return $this->apiProblem(422, "No previous_task given for the connection");
         }
         $this->commandBus->dispatch(ScheduleNextTasksForWorkflow::withData($connection['workflow_id'], $connection['previous_task'], $connection['message_handler']));
         return $this->accepted();
     } else {
         return $this->apiProblem(422, "Unknown connection type");
     }
 }