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