/**
  * @param PublishWorkflow $command
  * @throws Exception\WorkflowNotFound
  */
 public function handle(PublishWorkflow $command)
 {
     $workflow = $this->workflowCollection->get($command->workflowId());
     if (is_null($workflow)) {
         throw WorkflowNotFound::withId($command->workflowId());
     }
     $workflow->releaseCurrentVersion($command->releaseNumber(), $this->workflowPublisher);
 }
 public function create($data)
 {
     if (!array_key_exists('workflow_id', $data)) {
         return $this->apiProblem(422, "No workflow_id given for the release");
     }
     $workflowData = $this->workflowFinder->find($data['workflow_id']);
     if (!$workflowData) {
         return $this->apiProblem(404, "Workflow can not be found");
     }
     $newRelease = (int) $workflowData['current_release'];
     $newRelease++;
     $this->commandBus->dispatch(PublishWorkflow::withReleaseNumber($newRelease, $data['workflow_id']));
     return $this->location($this->url()->fromRoute('prooph.link/process_config/api/workflow_release', ['id' => $newRelease]));
 }