PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.6
JetFormBuilder — Dynamic Blocks Form Builder v3.6.6
3.6.6.1 3.6.6 3.6.5.4 3.6.5.3 3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 134 releases
jetformbuilder / includes / actions / events / base-event.php

base-event.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.6, at includes/actions/events/base-event.php

97 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 namespace Jet_Form_Builder\Actions\Events;
5
6 use Jet_Form_Builder\Actions\Types\Base;
7 use Jet_Form_Builder\Classes\Arrayable\Arrayable;
8 use Jet_Form_Builder\Classes\Arrayable\Collection_Item_Interface;
9 use JFB_Components\Repository\Repository_Item_Instance_Trait;
10 use Jet_Form_Builder\Exceptions\Action_Exception;
11
12 // If this file is called directly, abort.
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 abstract class Base_Event implements
18 Repository_Item_Instance_Trait,
19 Collection_Item_Interface,
20 Arrayable {
21
22 /**
23 * @return Base_Executor[]
24 */
25 abstract public function executors(): array;
26
27 public function ignored_executors(): array {
28 return array();
29 }
30
31 /**
32 * @throws Action_Exception
33 */
34 public function execute() {
35 $this->get_executor()->execute();
36 }
37
38
39 /**
40 * @return Base_Executor
41 */
42 final public function get_executor(): Base_Executor {
43 foreach ( $this->executors() as $executor ) {
44 if ( $executor->is_supported() ) {
45 return $executor->set_event( $this );
46 }
47 }
48
49 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
50 wp_die(
51 /* translators: %s - Event class name */
52 sprintf( __( 'Not founded supported executor for %s', 'jet-form-builder' ), static::class )
53 );
54 // phpcs:enable WordPress.Security.EscapeOutput.OutputNotEscaped
55 }
56
57 public function is_valid_action( Base $action ): bool {
58 $unsupported = $action->unsupported_events();
59
60 $unsupported = apply_filters( 'jet-form-builder/events/base-unsupported-events', $unsupported, $action->get_id(), $this->get_id() );
61
62 if ( ! empty( $unsupported ) && in_array( static::class, $unsupported, true ) ) {
63 return false;
64 }
65 $supported = $action->supported_events();
66
67 if ( ! empty( $supported ) && ! in_array( static::class, $supported, true ) ) {
68 return false;
69 }
70
71 return $action->get_events()->in_array( $this );
72 }
73
74 public function get_label(): string {
75 return $this->get_id();
76 }
77
78 public function get_help(): string {
79 return '';
80 }
81
82 public function rep_item_id() {
83 return $this->get_id();
84 }
85
86
87 public function to_array(): array {
88 return array(
89 'value' => $this->get_id(),
90 'label' => $this->get_label(),
91 'help' => $this->get_help(),
92 'self' => static::class,
93 );
94 }
95
96 }
97