PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.0
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Migration / WorkFlows.php

WorkFlows.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.0, at includes/Core/Migration/WorkFlows.php

65 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Migration;
4
5 class WorkFlows {
6 public static function migrate($workFlowsData) {
7 $migrateWorkFlows = [];
8 foreach ($workFlowsData as $workflow) {
9 $migrateWorkFlows[] = self::updateWorkflow($workflow);
10 }
11 return $migrateWorkFlows;
12 }
13
14 public static function updateWorkflow($workflow) {
15 $workflow = (object) $workflow;
16 $flow = [
17 'id' => $workflow->id,
18 'title' => $workflow->title,
19 'action_type' => $workflow->action_type,
20 'action_behaviour' => $workflow->action_behaviour,
21 'action_run' => $workflow->action_run,
22 ];
23 $flowProps = [];
24
25 if ('cond' === $workflow->action_behaviour) {
26 $flowProps['cond_type'] = 'if';
27 $flowProps['logics'] = $workflow->logics;
28 if ('onvalidate' === $workflow->action_type) {
29 // $flowProps['actions']['fields'] = $workflow->actions;
30 $flowProps['actions']['failure'] = $workflow->validateMsg;
31 }
32
33 if ('oninput' === $workflow->action_type) {
34 $flowProps['actions']['fields'] = $workflow->actions;
35 // $flowProps['actions']['success'] = $workflow->successAction;
36 $flowProps['actions']['success'] = [];
37 }
38
39 if ('onload' === $workflow->action_type) {
40 $flowProps['actions']['fields'] = $workflow->actions;
41 // $flowProps['actions']['success'] = $workflow->successAction;
42 }
43 if ('onsubmit' === $workflow->action_type) {
44 $flowProps['actions']['fields'] = $workflow->actions;
45 $flowProps['actions']['success'] = $workflow->successAction;
46 // integration, webhook,
47 }
48 } else {
49 if ('onload' === $workflow->action_type) {
50 $flowProps['cond_type'] = 'always';
51 $flowProps['actions']['fields'] = $workflow->actions;
52 // $flowProps['actions']['success'] = $workflow->successAction;
53 }
54 if ('onsubmit' === $workflow->action_type) {
55 $flowProps['actions']['fields'] = $workflow->actions;
56 $flowProps['actions']['success'] = $workflow->successAction;
57 }
58 }
59
60 $flow['conditions'][] = (object) $flowProps;
61
62 return (object) $flow;
63 }
64 }
65