Allow saving unknown step when not changed
[MAILPOET-4629]
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user