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
94 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 | |
| 17 | class Jet_Engine { |
| 18 | |
| 19 | public static function register() { |
| 20 | if ( ! function_exists( 'jet_engine' ) ) { |
| 21 | return; |
| 22 | } |
| 23 | new static(); |
| 24 | } |
| 25 | |
| 26 | private function __construct() { |
| 27 | add_filter( |
| 28 | 'jet-form-builder/preset/source-types', |
| 29 | array( $this, 'add_sources' ) |
| 30 | ); |
| 31 | add_filter( |
| 32 | 'jet-form-builder/forms/options-generators', |
| 33 | array( $this, 'add_generators' ) |
| 34 | ); |
| 35 | add_filter( |
| 36 | 'jet-form-builder/parsers-request/register', |
| 37 | array( $this, 'add_parsers' ) |
| 38 | ); |
| 39 | add_filter( |
| 40 | 'jet-form-builder/blocks/items', |
| 41 | array( $this, 'add_blocks' ), 0 |
| 42 | ); |
| 43 | add_action( |
| 44 | 'jet-form-builder/actions/register', |
| 45 | array( $this, 'add_actions' ) |
| 46 | ); |
| 47 | |
| 48 | if ( jet_engine()->relations ) { |
| 49 | add_filter( |
| 50 | 'jet-form-builder/post-modifier/object-properties', |
| 51 | array( $this, 'add_post_properties' ) |
| 52 | ); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public function add_sources( array $sources ): array { |
| 57 | $sources[] = new Preset_Source_Options_Page(); |
| 58 | |
| 59 | return $sources; |
| 60 | } |
| 61 | |
| 62 | public function add_generators( array $generators ): array { |
| 63 | array_push( |
| 64 | $generators, |
| 65 | new Get_From_Field(), |
| 66 | new Get_From_Je_Query() |
| 67 | ); |
| 68 | |
| 69 | return $generators; |
| 70 | } |
| 71 | |
| 72 | public function add_parsers( array $parsers ): array { |
| 73 | $parsers[] = new Map_Field_Parser(); |
| 74 | |
| 75 | return $parsers; |
| 76 | } |
| 77 | |
| 78 | public function add_blocks( array $blocks ): array { |
| 79 | $blocks[] = new Map_Field(); |
| 80 | |
| 81 | return $blocks; |
| 82 | } |
| 83 | |
| 84 | public function add_actions( \Jet_Form_Builder\Actions\Manager $manager ) { |
| 85 | $manager->register_action_type( new Update_Options() ); |
| 86 | } |
| 87 | |
| 88 | public function add_post_properties( |
| 89 | Object_Properties_Collection $collection |
| 90 | ): Object_Properties_Collection { |
| 91 | return $collection->add( new Post_Je_Relation_Property() ); |
| 92 | } |
| 93 | |
| 94 | } |