condition-types
2 years ago
functions
2 years ago
operators
2 years ago
render-states
2 years ago
rest-api
2 years ago
condition-manager.php
2 years ago
condition-response-object.php
2 years ago
functions.php
2 years ago
operators.php
2 years ago
render-state.php
2 years ago
render-states-collection.php
2 years ago
operators.php
90 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Blocks\Conditional_Block; |
| 5 | |
| 6 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Base_Operator; |
| 7 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Between; |
| 8 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Contain; |
| 9 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Empty; |
| 10 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Equal; |
| 11 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Greater_Or_Equal; |
| 12 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Less_Or_Equal; |
| 13 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Not_Between; |
| 14 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Not_Contain; |
| 15 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Not_Empty; |
| 16 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Not_Equal; |
| 17 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Not_In_The_List; |
| 18 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Render_State; |
| 19 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Greater; |
| 20 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_In_The_List; |
| 21 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Less; |
| 22 | use Jet_Form_Builder\Classes\Arrayable\Array_Tools; |
| 23 | use Jet_Form_Builder\Classes\Arrayable\Arrayable; |
| 24 | use JFB_Components\Repository\Repository_Pattern_Trait; |
| 25 | use Jet_Form_Builder\Exceptions\Repository_Exception; |
| 26 | |
| 27 | // If this file is called directly, abort. |
| 28 | if ( ! defined( 'WPINC' ) ) { |
| 29 | die; |
| 30 | } |
| 31 | |
| 32 | class Operators implements Arrayable { |
| 33 | |
| 34 | use Repository_Pattern_Trait; |
| 35 | |
| 36 | public function __construct() { |
| 37 | $this->rep_install(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @return array |
| 42 | */ |
| 43 | public function rep_instances(): array { |
| 44 | $operators = array( |
| 45 | new Operator_Equal(), |
| 46 | new Operator_Not_Equal(), |
| 47 | new Operator_Empty(), |
| 48 | new Operator_Not_Empty(), |
| 49 | new Operator_Greater(), |
| 50 | new Operator_Greater_Or_Equal(), |
| 51 | new Operator_Less(), |
| 52 | new Operator_Less_Or_Equal(), |
| 53 | new Operator_Between(), |
| 54 | new Operator_Not_Between(), |
| 55 | new Operator_In_The_List(), |
| 56 | new Operator_Not_In_The_List(), |
| 57 | new Operator_Contain(), |
| 58 | new Operator_Not_Contain(), |
| 59 | new Operator_Render_State(), |
| 60 | ); |
| 61 | |
| 62 | return apply_filters( |
| 63 | 'jet-form-builder/conditional-block/operators', |
| 64 | $operators |
| 65 | ); |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * @param string $slug |
| 70 | * |
| 71 | * @throws Repository_Exception |
| 72 | */ |
| 73 | public function isset_operator( string $slug ) { |
| 74 | $this->rep_throw_if_undefined( $slug ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @param string $slug |
| 79 | * |
| 80 | * @return Base_Operator |
| 81 | */ |
| 82 | public function get_operator( string $slug ): Base_Operator { |
| 83 | return $this->rep_get_item_or_die( $slug ); |
| 84 | } |
| 85 | |
| 86 | public function to_array(): array { |
| 87 | return Array_Tools::to_array( $this->rep_get_items() ); |
| 88 | } |
| 89 | } |
| 90 |