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