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