1 | <?php |
||
9 | class GroupBuilder extends FieldBuilder |
||
10 | { |
||
11 | /** |
||
12 | * Used to contain and add fields |
||
13 | * @var FieldsBuilder |
||
14 | */ |
||
15 | protected $fieldsBuilder; |
||
16 | |||
17 | /** |
||
18 | * @param string $name Field name |
||
19 | * @param string $type Field name |
||
20 | * @param array $config Field configuration |
||
21 | */ |
||
22 | public function __construct($name, $type = 'group', $config = []) |
||
28 | |||
29 | /** |
||
30 | * Add multiple fields either via an array or from another builder |
||
31 | * @param array|FieldsBuilder $fields |
||
32 | * @return $this |
||
33 | */ |
||
34 | public function addFields($fields) |
||
39 | |||
40 | /** |
||
41 | * Return a group field configuration array |
||
42 | * @return array |
||
43 | */ |
||
44 | public function build() |
||
51 | |||
52 | /** |
||
53 | * Returns call chain to parentContext |
||
54 | * @return FieldBuilder |
||
55 | */ |
||
56 | public function endGroup() |
||
60 | |||
61 | /** |
||
62 | * Returns call chain to parentContext |
||
63 | * @return FieldBuilder |
||
64 | */ |
||
65 | public function end() |
||
69 | |||
70 | /** |
||
71 | * Intercept missing methods, pass any methods that begin with add to the |
||
72 | * internal fieldsBuilder |
||
73 | * @param string $method |
||
74 | * @param array $args |
||
75 | * @return mixed |
||
76 | */ |
||
77 | public function __call($method, $args) |
||
87 | |||
88 | /** |
||
89 | * Calls an add field method on the FieldsBuilder |
||
90 | * @param string $method [description] |
||
91 | * @param array $args |
||
92 | * @return FieldBuilder |
||
93 | */ |
||
94 | private function callAddFieldMethod($method, $args) |
||
98 | |||
99 | /** |
||
100 | * Remove a field by name |
||
101 | * @param string $name Field to remove |
||
102 | * @return $this |
||
103 | */ |
||
104 | public function removeField($name) |
||
110 | |||
111 | /** |
||
112 | * Modify an already defined field |
||
113 | * @param string $name Name of the field |
||
114 | * @param array|\Closure $modify Array of field configs or a closure that accepts |
||
115 | * a FieldsBuilder and returns a FieldsBuilder. |
||
116 | * @throws ModifyFieldReturnTypeException if $modify is a closure and doesn't |
||
117 | * return a FieldsBuilder. |
||
118 | * @throws FieldNotFoundException if the field name doesn't exist. |
||
119 | * @return $this |
||
120 | */ |
||
121 | public function modifyField($name, $modify) |
||
128 | } |
||
129 |