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