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 / blocks / conditional-block / condition-manager.php
jetformbuilder / includes / blocks / conditional-block Last commit date
functions 3 years ago operators 3 years ago render-states 3 years ago condition-item.php 3 years ago condition-manager.php 3 years ago condition-response-object.php 3 years ago functions.php 3 years ago operators.php 3 years ago render-state.php 3 years ago render-states-collection.php 3 years ago
condition-manager.php
80 lines
1 <?php
2
3
4 namespace Jet_Form_Builder\Blocks\Conditional_Block;
5
6 use Jet_Form_Builder\Blocks\Exceptions\Condition_Exception;
7 use Jet_Form_Builder\Blocks\Exceptions\Render_Empty_Field;
8 use Jet_Form_Builder\Classes\Arrayable\Arrayable;
9 use Jet_Form_Builder\Classes\Instance_Trait;
10 use Jet_Form_Builder\Classes\Tools;
11 use Jet_Form_Builder\Exceptions\Repository_Exception;
12
13 /**
14 * @method static Condition_Manager instance()
15 *
16 * Class Condition_Manager
17 * @package Jet_Form_Builder\Blocks\Conditional_Block
18 */
19 class Condition_Manager implements Arrayable {
20
21 use Instance_Trait;
22
23 private $operators;
24 private $functions;
25
26 private function __construct() {
27 $this->operators = new Operators();
28 $this->functions = new Functions();
29 }
30
31 public function prepare( array $conditions ): array {
32 $response = array();
33
34 foreach ( $conditions as $condition ) {
35 try {
36 $item = new Condition_Item( $condition );
37 } catch ( Repository_Exception $exception ) {
38 continue;
39 }
40
41 /**
42 * Catch Condition_Exception on this level,
43 * because in future we can implement "OR" operator
44 * between all conditions.
45 *
46 * Here we could access the global option
47 */
48 try {
49 $response[] = $item->to_array();
50 } catch ( Condition_Exception $exception ) {
51 /**
52 * This exception catches in
53 *
54 * @see \Jet_Form_Builder\Blocks\Types\Base::render_callback_field
55 */
56 throw new Render_Empty_Field( 'This is temporary.' );
57 }
58 }
59
60 return $response;
61 }
62
63 public function to_array(): array {
64 return array(
65 'functions' => Tools::with_placeholder( $this->get_functions()->to_array() ),
66 'operators' => Tools::with_placeholder( $this->get_operators()->to_array() ),
67 'render_states' => Tools::with_placeholder( Render_State::instance()->to_array() ),
68 );
69 }
70
71 public function get_operators(): Operators {
72 return $this->operators;
73 }
74
75 public function get_functions(): Functions {
76 return $this->functions;
77 }
78
79 }
80