1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Class EE_Form_Section |
5
|
|
|
* Model Fields: |
6
|
|
|
* FSC_ID int |
7
|
|
|
* FSC_UUID string |
8
|
|
|
* FSC_appliesTo string |
9
|
|
|
* FSC_belongsTo string |
10
|
|
|
* FSC_htmlClass string |
11
|
|
|
* FSC_order int |
12
|
|
|
* FSC_relation string |
13
|
|
|
* FSC_status string |
14
|
|
|
* FSC_wpUser int |
15
|
|
|
* |
16
|
|
|
* @author Brent Christensen |
17
|
|
|
* @since $VID:$ |
18
|
|
|
*/ |
19
|
|
|
class EE_Form_Section extends EE_Soft_Delete_Base_Class |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param array $props_n_values |
24
|
|
|
* @return EE_Form_Section |
25
|
|
|
* @throws EE_Error |
26
|
|
|
* @throws ReflectionException |
27
|
|
|
*/ |
28
|
|
|
public static function new_instance(array $props_n_values = []): EE_Form_Section |
29
|
|
|
{ |
30
|
|
|
$has_object = parent::_check_for_object($props_n_values, __CLASS__); |
31
|
|
|
return $has_object |
32
|
|
|
?: new self($props_n_values); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param array $props_n_values |
38
|
|
|
* @return EE_Form_Section |
39
|
|
|
* @throws EE_Error |
40
|
|
|
* @throws ReflectionException |
41
|
|
|
*/ |
42
|
|
|
public static function new_instance_from_db(array $props_n_values = []): EE_Form_Section |
43
|
|
|
{ |
44
|
|
|
return new self($props_n_values); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Form Section UUID (universally unique identifier) |
50
|
|
|
* |
51
|
|
|
* @return string |
52
|
|
|
* @throws EE_Error |
53
|
|
|
* @throws ReflectionException |
54
|
|
|
*/ |
55
|
|
|
public function UUID(): string |
56
|
|
|
{ |
57
|
|
|
return $this->get('FSC_UUID'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Form user types that this form section should be presented to. |
63
|
|
|
* Values correspond to the EEM_Form_Section::APPLIES_TO_* constants. |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
* @throws EE_Error |
67
|
|
|
* @throws ReflectionException |
68
|
|
|
*/ |
69
|
|
|
public function appliesTo(): string |
70
|
|
|
{ |
71
|
|
|
return $this->get('FSC_appliesTo'); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* UUID or ID of related entity this form section belongs to. |
77
|
|
|
* |
78
|
|
|
* @return string |
79
|
|
|
* @throws EE_Error |
80
|
|
|
* @throws ReflectionException |
81
|
|
|
*/ |
82
|
|
|
public function belongsTo(): string |
83
|
|
|
{ |
84
|
|
|
return $this->get('FSC_belongsTo'); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* HTML classes to be applied to this form section's container. |
90
|
|
|
* |
91
|
|
|
* @return string |
92
|
|
|
* @throws EE_Error |
93
|
|
|
* @throws ReflectionException |
94
|
|
|
*/ |
95
|
|
|
public function htmlClass(): string |
96
|
|
|
{ |
97
|
|
|
return $this->get('FSC_htmlClass'); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Order in which form section appears in a form. |
103
|
|
|
* |
104
|
|
|
* @return int |
105
|
|
|
* @throws EE_Error |
106
|
|
|
* @throws ReflectionException |
107
|
|
|
*/ |
108
|
|
|
public function order(): int |
109
|
|
|
{ |
110
|
|
|
return $this->get('FSC_order'); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* Related model type. |
116
|
|
|
* |
117
|
|
|
* @return string |
118
|
|
|
* @throws EE_Error |
119
|
|
|
* @throws ReflectionException |
120
|
|
|
*/ |
121
|
|
|
public function relation(): string |
122
|
|
|
{ |
123
|
|
|
return $this->get('FSC_relation'); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Whether form section is active, archived, trashed, or used as a default on new forms. |
129
|
|
|
* Values correspond to the EEM_Form_Section::STATUS_* constants. |
130
|
|
|
* |
131
|
|
|
* @return string |
132
|
|
|
* @throws EE_Error |
133
|
|
|
* @throws ReflectionException |
134
|
|
|
*/ |
135
|
|
|
public function status(): string |
136
|
|
|
{ |
137
|
|
|
return $this->get('FSC_status'); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* returns the id the wordpress user who created this question |
143
|
|
|
* |
144
|
|
|
* @return int |
145
|
|
|
* @throws EE_Error |
146
|
|
|
* @throws ReflectionException |
147
|
|
|
*/ |
148
|
|
|
public function wpUser(): int |
149
|
|
|
{ |
150
|
|
|
return $this->get('FSC_wpUser'); |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* Form user types that this form section should be presented to. |
156
|
|
|
* Values correspond to the EEM_Form_Section::APPLIES_TO_* constants. |
157
|
|
|
* |
158
|
|
|
* @param string $user_type |
159
|
|
|
* @throws EE_Error |
160
|
|
|
* @throws ReflectionException |
161
|
|
|
*/ |
162
|
|
|
public function setAppliesTo(string $user_type) |
163
|
|
|
{ |
164
|
|
|
$this->set('FSC_appliesTo', $user_type); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* UUID or ID of related entity this form section belongs to. |
170
|
|
|
* |
171
|
|
|
* @param string $relation_UUID |
172
|
|
|
* @throws EE_Error |
173
|
|
|
* @throws ReflectionException |
174
|
|
|
*/ |
175
|
|
|
public function setBelongsTo(string $relation_UUID) |
176
|
|
|
{ |
177
|
|
|
$this->set('FSC_belongsTo', $relation_UUID); |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* HTML classes to be applied to this form section's container. |
183
|
|
|
* |
184
|
|
|
* @param string $html_class |
185
|
|
|
* @throws EE_Error |
186
|
|
|
* @throws ReflectionException |
187
|
|
|
*/ |
188
|
|
|
public function setHtmlClass(string $html_class) |
189
|
|
|
{ |
190
|
|
|
$this->set('FSC_htmlClass', $html_class); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Order in which form section appears in a form. |
196
|
|
|
* |
197
|
|
|
* @param int $order |
198
|
|
|
* @throws EE_Error |
199
|
|
|
* @throws ReflectionException |
200
|
|
|
*/ |
201
|
|
|
public function setOrder(int $order) |
202
|
|
|
{ |
203
|
|
|
$this->set('FSC_order', $order); |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* Related model type. |
209
|
|
|
* |
210
|
|
|
* @param string $relation |
211
|
|
|
* @throws EE_Error |
212
|
|
|
* @throws ReflectionException |
213
|
|
|
*/ |
214
|
|
|
public function setRelation(string $relation) |
215
|
|
|
{ |
216
|
|
|
$this->set('FSC_relation', $relation); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
|
220
|
|
|
/** |
221
|
|
|
* Whether form section is active, archived, trashed, or used as a default on new forms. |
222
|
|
|
* Values correspond to the EEM_Form_Section::STATUS_* constants. |
223
|
|
|
* |
224
|
|
|
* @param string $status |
225
|
|
|
* @throws EE_Error |
226
|
|
|
* @throws ReflectionException |
227
|
|
|
*/ |
228
|
|
|
public function setStatus(string $status) |
229
|
|
|
{ |
230
|
|
|
$this->set('FSC_status', $status); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
|
234
|
|
|
/** |
235
|
|
|
* returns the id the wordpress user who created this question |
236
|
|
|
* |
237
|
|
|
* @param int $wp_user |
238
|
|
|
* @throws EE_Error |
239
|
|
|
* @throws ReflectionException |
240
|
|
|
*/ |
241
|
|
|
public function setWpUser(int $wp_user) |
242
|
|
|
{ |
243
|
|
|
$this->set('FSC_wpUser', $wp_user); |
244
|
|
|
} |
245
|
|
|
} |
246
|
|
|
|