default-process-event.php
3 years ago
default-process-executor.php
3 years ago
default-with-gateway-executor.php
3 years ago
default-process-executor.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Actions\Events\Default_Process; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Actions\Events\Base_Executor; |
| 8 | use Jet_Form_Builder\Actions\Events_List; |
| 9 | use Jet_Form_Builder\Actions\Types\Base; |
| 10 | use Jet_Form_Builder\Actions\Types\Save_Record; |
| 11 | use Jet_Form_Builder\Exceptions\Action_Exception; |
| 12 | |
| 13 | class Default_Process_Executor extends Base_Executor { |
| 14 | |
| 15 | public function before_execute() { |
| 16 | do_action( 'jet-form-builder/actions/before-send' ); |
| 17 | |
| 18 | parent::before_execute(); |
| 19 | } |
| 20 | |
| 21 | public function after_execute() { |
| 22 | do_action( 'jet-form-builder/actions/after-send' ); |
| 23 | |
| 24 | parent::after_execute(); |
| 25 | } |
| 26 | |
| 27 | protected function is_valid_action( Base $action ): bool { |
| 28 | return ( ! count( $action->get_events() ) || parent::is_valid_action( $action ) ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * @throws Action_Exception |
| 33 | */ |
| 34 | protected function execute_actions() { |
| 35 | $save = jet_fb_action_handler()->get_action_by_slug( Save_Record::ID ); |
| 36 | |
| 37 | false === $save |
| 38 | ? jet_fb_action_handler()->run_actions( $this ) |
| 39 | : jet_fb_action_handler()->soft_run_actions( $this ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @return bool |
| 44 | */ |
| 45 | public function is_supported(): bool { |
| 46 | return true; |
| 47 | } |
| 48 | } |