Introduce Workflow::equals() and move decision to update a record to storage

[MAILPOET-4430]
This commit is contained in:
David Remer
2022-08-04 08:24:48 +03:00
committed by Veljko V
parent 3885194b48
commit 457d361ee9
3 changed files with 21 additions and 8 deletions

View File

@ -38,21 +38,16 @@ class UpdateWorkflowController {
throw Exceptions::workflowNotFound($id);
}
$changed = false;
$storedData = $workflow->toArray();
if (array_key_exists('name', $data) && $workflow->getName() !== $data['name']) {
if (array_key_exists('name', $data)) {
$workflow->setName($data['name']);
$changed = true;
}
if (array_key_exists('status', $data) && $workflow->getStatus() !== $data['status']) {
if (array_key_exists('status', $data)) {
$this->checkWorkflowStatus($data['status']);
$workflow->setStatus($data['status']);
$changed = true;
}
if (array_key_exists('steps', $data) && json_decode($storedData['steps'], true) !== $data['steps']) {
if (array_key_exists('steps', $data)) {
$this->validateWorkflowSteps($workflow, $data['steps']);
$this->updateStepsController->updateSteps($workflow, $data['steps']);
foreach ($workflow->getSteps() as $step) {