PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.1
JetFormBuilder — Dynamic Blocks Form Builder v2.1.1
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / gateways / migrate-legacy-data.php
jetformbuilder / includes / gateways Last commit date
db-models 3 years ago meta-boxes 3 years ago pages 3 years ago paypal 3 years ago query-views 3 years ago rest-api 3 years ago scenarios-abstract 3 years ago table-views 3 years ago base-gateway-action.php 3 years ago base-gateway.php 3 years ago base-scenario-gateway.php 3 years ago gateway-manager.php 3 years ago gateways-editor-data.php 3 years ago legacy-base-gateway.php 3 years ago migrate-legacy-data.php 3 years ago scenario-item.php 3 years ago
migrate-legacy-data.php
84 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Gateways;
5
6 use Jet_Form_Builder\Actions\Events\Default_Process\Default_Process_Event;
7 use Jet_Form_Builder\Actions\Events\Gateway_Failed\Gateway_Failed_Event;
8 use Jet_Form_Builder\Actions\Events\Gateway_Success\Gateway_Success_Event;
9 use Jet_Form_Builder\Actions\Events_List;
10
11 class Migrate_Legacy_Data {
12
13 protected $gateways;
14
15 public function __construct( array $gateways ) {
16 $this->gateways = $gateways;
17 }
18
19 public static function migrate( array $gateways ) {
20 if ( ! empty( $gateways['last_migrate'] ) ) {
21 return;
22 }
23 $self = new static( $gateways );
24
25 jet_fb_action_handler()->merge_events(
26 $self->get_actions_ids()
27 );
28 }
29
30 protected function get_actions_ids(): array {
31 $on_success = $this->get_active_actions( $this->gateways['notifications_success'] ?? array() );
32 $on_failed = $this->get_active_actions( $this->gateways['notifications_failed'] ?? array() );
33 $on_before = $this->get_active_actions( $this->gateways['notifications_before'] ?? array() );
34 $use_redirect = $this->gateways['use_success_redirect'] ?? false;
35
36 $has_redirect = false;
37
38 if ( ! $on_success && ! $on_failed && ! $on_before && ! $use_redirect ) {
39 return array();
40 }
41
42 $response = array();
43
44 foreach ( jet_fb_action_handler()->get_all() as $action ) {
45 $events = new Events_List();
46
47 if ( in_array( $action->_id, $on_success, true ) ) {
48 $events->push( Gateway_Success_Event::class );
49 }
50 if ( in_array( $action->_id, $on_failed, true ) ) {
51 $events->push( Gateway_Failed_Event::class );
52 }
53 if ( in_array( $action->_id, $on_before, true ) ) {
54 $events->push( Default_Process_Event::class );
55 }
56 if ( $use_redirect && ! $has_redirect && 'redirect_to_page' === $action->get_id() ) {
57 $events->push( Gateway_Success_Event::class );
58 $has_redirect = true;
59 }
60
61 if ( ! $events ) {
62 continue;
63 }
64
65 $response[ $action->_id ] = $events;
66 }
67
68 return $response;
69 }
70
71 protected function get_active_actions( $actions ): array {
72 $response = array();
73
74 foreach ( $actions as $id => $settings ) {
75 if ( ! empty( $settings['active'] ) ) {
76 $response[] = $id;
77 }
78 }
79
80 return $response;
81 }
82
83 }
84