PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 / form-messages / msg-router.php
jetformbuilder / includes / form-messages Last commit date
actions 2 years ago action-messages-manager.php 2 years ago builder.php 2 years ago manager.php 2 years ago msg-router.php 2 years ago status-info.php 2 years ago
msg-router.php
119 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Form_Messages;
5
6 // If this file is called directly, abort.
7 if ( ! defined( 'WPINC' ) ) {
8 die;
9 }
10
11 class Msg_Router {
12
13 /** @var Builder */
14 private $builder;
15
16 /** @var Manager */
17 private $manager;
18
19 private $form_id;
20 private $actions;
21
22
23 public function __construct() {
24 $this->builder = new Builder();
25 $this->manager = new Manager();
26 }
27
28 public function get_form_id() {
29 return (int) $this->form_id;
30 }
31
32 public function set_form_id( $form_id ) {
33 if ( ! $form_id || $form_id === $this->get_form_id() ) {
34 return false;
35 }
36 $this->form_id = (int) $form_id;
37
38 return true;
39 }
40
41 public function set_actions( $actions ) {
42 if ( ! $actions || ! is_array( $actions ) ) {
43 return false;
44 }
45 $this->actions = $actions;
46
47 return true;
48 }
49
50 public function get_actions() {
51 return (array) $this->actions;
52 }
53
54
55 public function set_up( $data = false ) {
56 $this->maybe_set_form_id_from_handler( $data['form_id'] ?? false );
57 $this->maybe_set_actions_from_handler( $data['actions'] ?? false );
58
59 return $this;
60 }
61
62 public function maybe_set_form_id_from_handler( $form_id ) {
63 if ( $this->set_form_id( $form_id ) ) {
64 return true;
65 }
66
67 // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
68 return $this->set_form_id( jet_form_builder()->form_handler->form_id ?: false );
69 }
70
71 public function maybe_set_actions_from_handler( $actions ) {
72 if ( $this->set_actions( $actions ) ) {
73 return true;
74 }
75
76 return $this->query_actions_if_empty();
77 }
78
79 public function query_actions() {
80 if ( ! $this->form_id ) {
81 return false;
82 }
83
84 $this->set_actions(
85 jet_fb_action_handler()
86 ->set_form_id( $this->form_id )
87 ->get_all()
88 );
89
90 return true;
91 }
92
93 public function query_actions_if_empty() {
94 if ( $this->actions && is_array( $this->actions ) ) {
95 return true;
96 }
97
98 return $this->query_actions();
99 }
100
101 /**
102 * @param $data
103 *
104 * @return Builder
105 */
106 public function get_builder( $data = array() ) {
107 $this->set_up( $data );
108
109 return $this->builder;
110 }
111
112 public function get_manager( $data = array() ) {
113 $this->set_up( $data );
114
115 return $this->manager->set_up();
116 }
117
118 }
119