actions
3 years ago
blocks
3 years ago
generators
3 years ago
methods
3 years ago
parsers
3 years ago
preset-sources
3 years ago
jet-engine.php
3 years ago
jet-engine.php
99 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Compatibility\Jet_Engine; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Actions\Methods\Object_Properties_Collection; |
| 8 | use Jet_Form_Builder\Blocks\Manager; |
| 9 | use Jet_Form_Builder\Compatibility\Jet_Engine\Actions\Update_Options; |
| 10 | use Jet_Form_Builder\Compatibility\Jet_Engine\Blocks\Map_Field; |
| 11 | use Jet_Form_Builder\Compatibility\Jet_Engine\Generators\Get_From_Field; |
| 12 | use Jet_Form_Builder\Compatibility\Jet_Engine\Generators\Get_From_Je_Query; |
| 13 | use Jet_Form_Builder\Compatibility\Jet_Engine\Methods\Post_Modification\Post_Je_Relation_Property; |
| 14 | use Jet_Form_Builder\Compatibility\Jet_Engine\Parsers\Map_Field_Parser; |
| 15 | use Jet_Form_Builder\Compatibility\Jet_Engine\Preset_Sources\Preset_Source_Options_Page; |
| 16 | use Jet_Form_Builder\Compatibility\Jet_Engine\Preset_Sources\Preset_User; |
| 17 | |
| 18 | class Jet_Engine { |
| 19 | |
| 20 | public static function register() { |
| 21 | if ( ! function_exists( 'jet_engine' ) ) { |
| 22 | return; |
| 23 | } |
| 24 | new static(); |
| 25 | } |
| 26 | |
| 27 | private function __construct() { |
| 28 | add_filter( |
| 29 | 'jet-form-builder/preset/source-types', |
| 30 | array( $this, 'add_sources' ) |
| 31 | ); |
| 32 | add_filter( |
| 33 | 'jet-form-builder/forms/options-generators', |
| 34 | array( $this, 'add_generators' ) |
| 35 | ); |
| 36 | add_filter( |
| 37 | 'jet-form-builder/parsers-request/register', |
| 38 | array( $this, 'add_parsers' ) |
| 39 | ); |
| 40 | add_filter( |
| 41 | 'jet-form-builder/blocks/items', |
| 42 | array( $this, 'add_blocks' ), 0 |
| 43 | ); |
| 44 | add_action( |
| 45 | 'jet-form-builder/actions/register', |
| 46 | array( $this, 'add_actions' ) |
| 47 | ); |
| 48 | |
| 49 | if ( jet_engine()->relations ) { |
| 50 | add_filter( |
| 51 | 'jet-form-builder/post-modifier/object-properties', |
| 52 | array( $this, 'add_post_properties' ) |
| 53 | ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | public function add_sources( array $sources ): array { |
| 58 | array_push( |
| 59 | $sources, |
| 60 | new Preset_Source_Options_Page(), |
| 61 | new Preset_User() |
| 62 | ); |
| 63 | |
| 64 | return $sources; |
| 65 | } |
| 66 | |
| 67 | public function add_generators( array $generators ): array { |
| 68 | array_push( |
| 69 | $generators, |
| 70 | new Get_From_Field(), |
| 71 | new Get_From_Je_Query() |
| 72 | ); |
| 73 | |
| 74 | return $generators; |
| 75 | } |
| 76 | |
| 77 | public function add_parsers( array $parsers ): array { |
| 78 | $parsers[] = new Map_Field_Parser(); |
| 79 | |
| 80 | return $parsers; |
| 81 | } |
| 82 | |
| 83 | public function add_blocks( array $blocks ): array { |
| 84 | $blocks[] = new Map_Field(); |
| 85 | |
| 86 | return $blocks; |
| 87 | } |
| 88 | |
| 89 | public function add_actions( \Jet_Form_Builder\Actions\Manager $manager ) { |
| 90 | $manager->register_action_type( new Update_Options() ); |
| 91 | } |
| 92 | |
| 93 | public function add_post_properties( |
| 94 | Object_Properties_Collection $collection |
| 95 | ): Object_Properties_Collection { |
| 96 | return $collection->add( new Post_Je_Relation_Property() ); |
| 97 | } |
| 98 | |
| 99 | } |