Return created workflow with ID when using create-from-template endpoint
[MAILPOET-4533]
This commit is contained in:
@ -29,7 +29,11 @@ class CreateWorkflowFromTemplateController {
|
|||||||
throw UnexpectedValueException::create()->withMessage('Template not found.');
|
throw UnexpectedValueException::create()->withMessage('Template not found.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->storage->createWorkflow($template->getWorkflow());
|
$workflowId = $this->storage->createWorkflow($template->getWorkflow());
|
||||||
return $template->getWorkflow();
|
$workflow = $this->storage->getWorkflow($workflowId);
|
||||||
|
if (!$workflow) {
|
||||||
|
throw UnexpectedValueException::create()->withMessage('Workflow not found.');
|
||||||
|
}
|
||||||
|
return $workflow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,7 @@ class Workflow {
|
|||||||
|
|
||||||
public function toArray(): array {
|
public function toArray(): array {
|
||||||
return [
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
'name' => $this->name,
|
'name' => $this->name,
|
||||||
'status' => $this->status,
|
'status' => $this->status,
|
||||||
'author' => $this->author->ID,
|
'author' => $this->author->ID,
|
||||||
|
@ -19,8 +19,8 @@ class WorkflowsCreateFromTemplateEndpoint extends Endpoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function handle(Request $request): Response {
|
public function handle(Request $request): Response {
|
||||||
$this->createWorkflowFromTemplateController->createWorkflow((string)$request->getParam('slug'));
|
$workflow = $this->createWorkflowFromTemplateController->createWorkflow((string)$request->getParam('slug'));
|
||||||
return new Response();
|
return new Response($workflow->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRequestSchema(): array {
|
public static function getRequestSchema(): array {
|
||||||
|
Reference in New Issue
Block a user