PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.0
JetFormBuilder — Dynamic Blocks Form Builder v3.0.0
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 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 / actions / events / base-executor.php
jetformbuilder / includes / actions / events Last commit date
bad-request 3 years ago default-process 3 years ago default-required 3 years ago gateway-failed 3 years ago gateway-success 3 years ago never 3 years ago on-dynamic-state 3 years ago base-action-event.php 3 years ago base-event.php 3 years ago base-executor.php 3 years ago base-gateway-event.php 3 years ago gateway-base-executor.php 3 years ago
base-executor.php
162 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Actions\Events;
5
6 use Jet_Form_Builder\Actions\Events_List;
7 use Jet_Form_Builder\Actions\Events_Manager;
8 use Jet_Form_Builder\Actions\Types\Base;
9 use Jet_Form_Builder\Exceptions\Action_Exception;
10
11 abstract class Base_Executor implements \ArrayAccess, \Iterator, \Countable {
12
13 /** @var Base_Event */
14 private $event;
15 private $action_ids = array();
16 private $position = 0;
17
18 abstract public function is_supported(): bool;
19
20 public function before_execute() {
21 $this->validate_actions();
22 }
23
24 public function after_execute() {
25 }
26
27 /**
28 * @throws Action_Exception
29 */
30 final public function execute() {
31 /*
32 * Here you can set custom hooks or validate actions.
33 *
34 * By default all actions is executed,
35 * even if they should run on another event
36 */
37 $this->before_execute();
38
39 // execute all actions
40 $this->execute_actions();
41
42 $this->after_execute();
43 }
44
45 protected function validate_actions() {
46 jet_fb_action_handler()->sort_hidden_actions();
47
48 $this->action_ids = array();
49 $actions = jet_fb_action_handler()->get_all();
50
51 foreach ( $actions as $action ) {
52 if ( ! $this->is_valid_action( $action ) ) {
53 continue;
54 }
55 $action->on_validate( $this );
56
57 $this->action_ids[] = $action->_id;
58 }
59 }
60
61 /**
62 * @throws Action_Exception
63 */
64 protected function execute_actions() {
65 jet_fb_action_handler()->soft_run_actions( $this );
66 }
67
68 protected function is_valid_action( Base $action ): bool {
69 return $this->get_event()->is_valid_action( $action );
70 }
71
72 final public function set_event( Base_Event $event ): Base_Executor {
73 $this->event = $event;
74
75 return $this;
76 }
77
78 /**
79 * @return Base_Event
80 */
81 public function get_event(): Base_Event {
82 return $this->event;
83 }
84
85 /**
86 * @return Base
87 */
88 #[\ReturnTypeWillChange]
89 public function current() {
90 return jet_fb_action_handler()->get_action_by_id(
91 $this->action_ids[ $this->position ] ?? 0
92 );
93 }
94
95 #[\ReturnTypeWillChange]
96 public function next() {
97 ++ $this->position;
98 }
99
100 /**
101 * @return bool|float|int|string|null
102 */
103 #[\ReturnTypeWillChange]
104 public function key() {
105 return $this->position;
106 }
107
108 /**
109 * @return bool
110 */
111 public function valid(): bool {
112 return isset( $this->action_ids[ $this->position ] );
113 }
114
115 #[\ReturnTypeWillChange]
116 public function rewind() {
117 $this->position = 0;
118 }
119
120 /**
121 * @param mixed $offset
122 *
123 * @return bool
124 */
125 public function offsetExists( $offset ): bool {
126 return isset( jet_fb_action_handler()->form_actions[ $offset ] );
127 }
128
129 /**
130 * @param mixed $offset
131 *
132 * @return mixed
133 */
134 #[\ReturnTypeWillChange]
135 public function offsetGet( $offset ) {
136 return jet_fb_action_handler()->get_action_by_id( $offset );
137 }
138
139 /**
140 * @param mixed $offset
141 * @param mixed $value
142 */
143 #[\ReturnTypeWillChange]
144 public function offsetSet( $offset, $value ) {
145 }
146
147 /**
148 * @param mixed $offset
149 */
150 #[\ReturnTypeWillChange]
151 public function offsetUnset( $offset ) {
152 jet_fb_action_handler()->get_action_by_id( $offset )->unregister();
153 }
154
155 /**
156 * @return int
157 */
158 public function count(): int {
159 return count( $this->action_ids );
160 }
161 }
162