Allow saving unknown step when not changed

[MAILPOET-4629]
This commit is contained in:
Jan Jakes
2022-09-22 15:28:13 +02:00
committed by David Remer
parent dbf17204a0
commit 1a51412849

View File

@@ -20,17 +20,17 @@ class UpdateStepsController {
public function updateSteps(Workflow $workflow, array $data): Workflow {
$steps = [];
foreach ($data as $index => $stepData) {
$step = $this->processStep($stepData);
$step = $this->processStep($stepData, $workflow->getStep($stepData['id']));
$steps[$index] = $step;
}
$workflow->setSteps($steps);
return $workflow;
}
private function processStep(array $data): Step {
private function processStep(array $data, ?Step $existingStep): Step {
$key = $data['key'];
$step = $this->registry->getStep($key);
if (!$step) {
if (!$step && $existingStep && $data !== $existingStep->toArray()) {
throw Exceptions::workflowStepNotFound($key);
}
return Step::fromArray($data);