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
operators.php
72 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Blocks\Conditional_Block; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Base_Operator; |
| 8 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Between; |
| 9 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Contain; |
| 10 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Equal; |
| 11 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Render_State; |
| 12 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Greater; |
| 13 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_In_The_List; |
| 14 | use Jet_Form_Builder\Blocks\Conditional_Block\Operators\Operator_Less; |
| 15 | use Jet_Form_Builder\Classes\Arrayable\Array_Tools; |
| 16 | use Jet_Form_Builder\Classes\Arrayable\Arrayable; |
| 17 | use Jet_Form_Builder\Classes\Repository\Repository_Pattern_Trait; |
| 18 | use Jet_Form_Builder\Exceptions\Repository_Exception; |
| 19 | |
| 20 | class Operators implements Arrayable { |
| 21 | |
| 22 | use Repository_Pattern_Trait; |
| 23 | |
| 24 | public function __construct() { |
| 25 | $this->rep_install(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @return array |
| 30 | */ |
| 31 | public function rep_instances(): array { |
| 32 | $operators = array( |
| 33 | new Operator_Equal(), |
| 34 | new Operator_Greater(), |
| 35 | new Operator_Less(), |
| 36 | new Operator_Between(), |
| 37 | new Operator_In_The_List(), |
| 38 | new Operator_Contain(), |
| 39 | ); |
| 40 | |
| 41 | if ( Render_State::instance()->is_multiple() ) { |
| 42 | $operators[] = new Operator_Render_State(); |
| 43 | } |
| 44 | |
| 45 | return apply_filters( |
| 46 | 'jet-form-builder/conditional-block/operators', |
| 47 | $operators |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @param string $slug |
| 53 | * |
| 54 | * @throws Repository_Exception |
| 55 | */ |
| 56 | public function isset_operator( string $slug ) { |
| 57 | $this->rep_throw_if_undefined( $slug ); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * @param string $slug |
| 62 | * |
| 63 | * @return Base_Operator |
| 64 | */ |
| 65 | public function get_operator( string $slug ): Base_Operator { |
| 66 | return $this->rep_get_item_or_die( $slug ); |
| 67 | } |
| 68 | |
| 69 | public function to_array(): array { |
| 70 | return Array_Tools::to_array( $this->rep_get_items() ); |
| 71 | } |
| 72 | } |