PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.3
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.3
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 1.1.2 1.1.3 1.1.4 All 131 releases
jetformbuilder / includes / generators / base.php

base.php in JetFormBuilder — Dynamic Blocks Form Builder 3.6.5.3, at includes/generators/base.php

81 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Jet_Form_Builder\Generators;
4
5 // If this file is called directly, abort.
6 if ( ! defined( 'WPINC' ) ) {
7 die;
8 }
9
10 abstract class Base {
11
12 /**
13 * @var \Jet_Form_Builder\Blocks\Types\Base
14 */
15 protected $block;
16
17 /**
18 * Returns generator ID
19 *
20 * @return [type] [description]
21 */
22 abstract public function get_id();
23
24 /**
25 * Returns generator name
26 *
27 * @return [type] [description]
28 */
29 abstract public function get_name();
30
31 /**
32 * Returns generated options list
33 *
34 * @param $args
35 *
36 * @return array
37 */
38 abstract public function generate( $args );
39
40 public function can_generate() {
41 return true;
42 }
43
44 public function incoming_args() {
45 return array(
46 'generator_field' => function ( $value ) {
47 return $value;
48 },
49 );
50 }
51
52 public function get_values( $args ) {
53 $fields = array();
54
55 foreach ( $this->incoming_args() as $name => $parse_callable ) {
56 $fields[ $name ] = isset( $args[ $name ] ) ? call_user_func( $parse_callable, $args[ $name ] ) : false;
57 }
58
59 return $this->generate( $fields );
60 }
61
62 /**
63 * @param \Jet_Form_Builder\Blocks\Types\Base $block
64 */
65 public function set_block( \Jet_Form_Builder\Blocks\Types\Base $block ) {
66 $this->block = $block;
67 }
68
69 /**
70 * @return \Jet_Form_Builder\Blocks\Types\Base
71 */
72 public function get_block(): \Jet_Form_Builder\Blocks\Types\Base {
73 return $this->block;
74 }
75
76 public function clear_block() {
77 $this->block = null;
78 }
79
80 }
81