Skip to content

Commit

Permalink
check if workflow is available before migrating
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Oct 13, 2023
1 parent c6b0ea6 commit 170e189
Showing 1 changed file with 40 additions and 17 deletions.
57 changes: 40 additions & 17 deletions src/Migrations/Version20230908101855.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,29 +29,52 @@ public function up(Schema $schema): void

$conditionalLogic = array_map(static function ($logic) use ($workflowIdMap) {
return [
'condition' => array_map(static function ($condition) use ($workflowIdMap) {
if ($condition['type'] !== 'outputWorkflow') {
return $condition;
}
'condition' => array_filter(
array_map(static function ($condition) use ($workflowIdMap) {
if ($condition['type'] !== 'outputWorkflow') {
return $condition;
}

foreach ($condition['outputWorkflows'] as $index => $outputWorkflowId) {
$condition['outputWorkflows'][$index] = $workflowIdMap[$outputWorkflowId];
}
$condition['outputWorkflows'][0] = 21;
$condition['outputWorkflows'][1] = 1;

return $condition;
foreach ($condition['outputWorkflows'] as $index => $outputWorkflowId) {

}, $logic['condition']),
'action' => array_map(static function ($action) use ($workflowIdMap) {
if ($action['type'] !== 'switchOutputWorkflow') {
return $action;
}
if (!isset($workflowIdMap[$outputWorkflowId])) {
unset($condition['outputWorkflows'][$index]);
continue;
}

$action['workflowName'] = $workflowIdMap[$action['workflowId']];
unset($action['workflowId']);
$condition['outputWorkflows'][$index] = $workflowIdMap[$outputWorkflowId];
}

return $action;
if (count($condition['outputWorkflows']) === 0) {
return null;
}

}, $logic['action'])
$condition['outputWorkflows'] = array_values($condition['outputWorkflows']);

return $condition;

}, $logic['condition'])
),
'action' => array_filter(
array_map(static function ($action) use ($workflowIdMap) {
if ($action['type'] !== 'switchOutputWorkflow') {
return $action;
}

if (!isset($workflowIdMap[$action['workflowId']])) {
return null;
}

$action['workflowName'] = $workflowIdMap[$action['workflowId']];
unset($action['workflowId']);

return $action;

}, $logic['action'])
)
];
}, unserialize($form['conditionalLogic']));

Expand Down

0 comments on commit 170e189

Please sign in to comment.