@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function __construct() |
71 | 71 | { |
72 | - $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | + $this->primary_registrant_data = ['line_item_id' => null, ]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | public function initializeRegistrantData(EE_Registration $registration): void |
81 | 81 | { |
82 | 82 | $reg_url_link = $registration->reg_url_link(); |
83 | - $this->registrations[ $reg_url_link ] = $registration; |
|
84 | - $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
85 | - $this->registrant_data[ $reg_url_link ] = []; |
|
83 | + $this->registrations[$reg_url_link] = $registration; |
|
84 | + $this->registrant_answers[$reg_url_link] = $registration->answers(); |
|
85 | + $this->registrant_data[$reg_url_link] = []; |
|
86 | 86 | $this->attendee_counter++; |
87 | 87 | } |
88 | 88 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function getRegistrant(string $reg_url_link): ?EE_Registration |
122 | 122 | { |
123 | - return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | + return $this->registrations[$reg_url_link] ?? null; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | public function getRegistrantData(string $reg_url_link): ?array |
132 | 132 | { |
133 | - return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | + return $this->registrant_data[$reg_url_link] ?? null; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
143 | 143 | { |
144 | - $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | + $this->registrant_data[$reg_url_link][$key] = $value; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | } |
178 | 178 | foreach ($critical_attendee_details as $critical_attendee_detail) { |
179 | 179 | if ( |
180 | - ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | - || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
180 | + ! isset($this->registrant_data[$reg_url_link][$critical_attendee_detail]) |
|
181 | + || empty($this->registrant_data[$reg_url_link][$critical_attendee_detail]) |
|
182 | 182 | ) { |
183 | - $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
183 | + $this->registrant_data[$reg_url_link][$critical_attendee_detail] = $this->primary_registrant->get( |
|
184 | 184 | $critical_attendee_detail |
185 | 185 | ); |
186 | 186 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | */ |
195 | 195 | public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
196 | 196 | { |
197 | - $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
197 | + $this->registrant_data[$reg_url_link] = $registrant_data; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | */ |
214 | 214 | public function addRequiredQuestion(string $identifier, string $required_question): void |
215 | 215 | { |
216 | - $this->required_questions[ $identifier ] = $required_question; |
|
216 | + $this->required_questions[$identifier] = $required_question; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | */ |
223 | 223 | public function registrantAnswers(string $reg_url_link): array |
224 | 224 | { |
225 | - return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
225 | + return $this->registrant_answers[$reg_url_link] ?? []; |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
235 | 235 | { |
236 | - $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
236 | + $this->registrant_answers[$reg_url_link][$identifier] = $answer; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | */ |
245 | 245 | public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
246 | 246 | { |
247 | - return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
247 | + return $this->registrant_answers[$reg_url_link][$identifier] ?? null; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public function addPrimaryRegistrantDataValue(string $key, $value): void |
278 | 278 | { |
279 | - $this->primary_registrant_data[ $key ] = $value; |
|
279 | + $this->primary_registrant_data[$key] = $value; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | public function getPrimaryRegistrantDataValue(string $key) |
288 | 288 | { |
289 | - return $this->primary_registrant_data[ $key ] ?? null; |
|
289 | + return $this->primary_registrant_data[$key] ?? null; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
360 | 360 | { |
361 | 361 | // store a bit of data about the primary attendee |
362 | - if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | - $this->primary_registrant_data[ $form_input ] = $input_value; |
|
362 | + if ( ! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | + $this->primary_registrant_data[$form_input] = $input_value; |
|
364 | 364 | return $input_value; |
365 | 365 | } |
366 | 366 | // or copy value from primary if incoming value is not set |
@@ -18,355 +18,355 @@ |
||
18 | 18 | */ |
19 | 19 | class RegistrantData |
20 | 20 | { |
21 | - /** |
|
22 | - * @var int |
|
23 | - */ |
|
24 | - private $attendee_counter = 0; |
|
25 | - |
|
26 | - /** |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - private $registrant_data = []; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var bool |
|
33 | - */ |
|
34 | - private $copy_primary = false; |
|
35 | - |
|
36 | - /** |
|
37 | - * @var array |
|
38 | - */ |
|
39 | - private $required_questions = []; |
|
40 | - |
|
41 | - /** |
|
42 | - * @var EE_Registration[] |
|
43 | - */ |
|
44 | - private $registrations = []; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var EE_Answer[][] |
|
48 | - */ |
|
49 | - private $registrant_answers = []; |
|
50 | - |
|
51 | - /** |
|
52 | - * array for tracking reg form data for the primary registrant |
|
53 | - * |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - private $primary_registrant_data; |
|
57 | - |
|
58 | - /** |
|
59 | - * the attendee object created for the primary registrant |
|
60 | - * |
|
61 | - * @var EE_Attendee |
|
62 | - */ |
|
63 | - private $primary_registrant; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * RegistrantData constructor. |
|
68 | - */ |
|
69 | - public function __construct() |
|
70 | - { |
|
71 | - $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - /** |
|
76 | - * @param EE_Registration $registration |
|
77 | - * @throws EE_Error |
|
78 | - */ |
|
79 | - public function initializeRegistrantData(EE_Registration $registration): void |
|
80 | - { |
|
81 | - $reg_url_link = $registration->reg_url_link(); |
|
82 | - $this->registrations[ $reg_url_link ] = $registration; |
|
83 | - $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
84 | - $this->registrant_data[ $reg_url_link ] = []; |
|
85 | - $this->attendee_counter++; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return int |
|
91 | - */ |
|
92 | - public function attendeeCount(): int |
|
93 | - { |
|
94 | - return $this->attendee_counter; |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - public function copyPrimary(): bool |
|
102 | - { |
|
103 | - return $this->copy_primary; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param bool $copy_primary |
|
109 | - */ |
|
110 | - public function setCopyPrimary(bool $copy_primary): void |
|
111 | - { |
|
112 | - $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $reg_url_link |
|
118 | - * @return array|null |
|
119 | - */ |
|
120 | - public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
121 | - { |
|
122 | - return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param string $reg_url_link |
|
128 | - * @return array|null |
|
129 | - */ |
|
130 | - public function getRegistrantData(string $reg_url_link): ?array |
|
131 | - { |
|
132 | - return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * @param string $reg_url_link |
|
138 | - * @param string $key |
|
139 | - * @param mixed $value |
|
140 | - */ |
|
141 | - public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
142 | - { |
|
143 | - $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
149 | - * |
|
150 | - * @param string $reg_url_link |
|
151 | - * @throws EE_Error |
|
152 | - * @throws ReflectionException |
|
153 | - */ |
|
154 | - public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
155 | - { |
|
156 | - if ($this->currentRegistrantIsPrimary()) { |
|
157 | - return; |
|
158 | - } |
|
159 | - // bare minimum critical details include first name, last name, email address |
|
160 | - $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
161 | - // add address info to critical details? |
|
162 | - if ( |
|
163 | - apply_filters( |
|
164 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
165 | - false |
|
166 | - ) |
|
167 | - ) { |
|
168 | - $critical_attendee_details += [ |
|
169 | - 'ATT_address', |
|
170 | - 'ATT_address2', |
|
171 | - 'ATT_city', |
|
172 | - 'STA_ID', |
|
173 | - 'CNT_ISO', |
|
174 | - 'ATT_zip', |
|
175 | - 'ATT_phone', |
|
176 | - ]; |
|
177 | - } |
|
178 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
179 | - if ( |
|
180 | - ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | - || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | - ) { |
|
183 | - $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
184 | - $critical_attendee_detail |
|
185 | - ); |
|
186 | - } |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param string $reg_url_link |
|
193 | - * @param array $registrant_data |
|
194 | - */ |
|
195 | - public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
196 | - { |
|
197 | - $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * @return array |
|
203 | - */ |
|
204 | - public function getRequiredQuestions(): array |
|
205 | - { |
|
206 | - return $this->required_questions; |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * @param string $identifier |
|
212 | - * @param string $required_question |
|
213 | - */ |
|
214 | - public function addRequiredQuestion(string $identifier, string $required_question): void |
|
215 | - { |
|
216 | - $this->required_questions[ $identifier ] = $required_question; |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - /** |
|
221 | - * @return EE_Answer[] |
|
222 | - */ |
|
223 | - public function registrantAnswers(string $reg_url_link): array |
|
224 | - { |
|
225 | - return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
226 | - } |
|
227 | - |
|
228 | - |
|
229 | - /** |
|
230 | - * @param string $reg_url_link |
|
231 | - * @param string $identifier the answer cache ID |
|
232 | - * @param EE_Answer $answer |
|
233 | - */ |
|
234 | - public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
235 | - { |
|
236 | - $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
237 | - } |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * @param string $reg_url_link |
|
242 | - * @param string $identifier |
|
243 | - * @return EE_Answer|null |
|
244 | - */ |
|
245 | - public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
246 | - { |
|
247 | - return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - |
|
252 | - /** |
|
253 | - * @param string $reg_url_link |
|
254 | - * @param string $identifier |
|
255 | - * @return bool |
|
256 | - */ |
|
257 | - public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
258 | - { |
|
259 | - $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
260 | - return $registrant_answer instanceof EE_Answer; |
|
261 | - } |
|
262 | - |
|
263 | - |
|
264 | - /** |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - public function primaryRegistrantData(): array |
|
268 | - { |
|
269 | - return $this->primary_registrant_data; |
|
270 | - } |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * @param string $key |
|
275 | - * @param mixed $value |
|
276 | - */ |
|
277 | - public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
278 | - { |
|
279 | - $this->primary_registrant_data[ $key ] = $value; |
|
280 | - } |
|
281 | - |
|
282 | - |
|
283 | - /** |
|
284 | - * @param string $key |
|
285 | - * @return mixed |
|
286 | - */ |
|
287 | - public function getPrimaryRegistrantDataValue(string $key) |
|
288 | - { |
|
289 | - return $this->primary_registrant_data[ $key ] ?? null; |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @param array $primary_registrant_data |
|
295 | - */ |
|
296 | - public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
297 | - { |
|
298 | - $this->primary_registrant_data = $primary_registrant_data; |
|
299 | - } |
|
300 | - |
|
301 | - |
|
302 | - /** |
|
303 | - * @return EE_Attendee |
|
304 | - */ |
|
305 | - public function primaryRegistrant(): EE_Attendee |
|
306 | - { |
|
307 | - return $this->primary_registrant; |
|
308 | - } |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * @return bool |
|
313 | - */ |
|
314 | - public function primaryRegistrantIsValid(): bool |
|
315 | - { |
|
316 | - return $this->primary_registrant instanceof EE_Attendee; |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * @param EE_Attendee $primary_registrant |
|
322 | - */ |
|
323 | - public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
324 | - { |
|
325 | - $this->primary_registrant = $primary_registrant; |
|
326 | - } |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * @param string $reg_url_link |
|
331 | - * @return bool |
|
332 | - */ |
|
333 | - public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
334 | - { |
|
335 | - return $this->attendeeCount() === 1 |
|
336 | - || ( |
|
337 | - $this->attendeeCount() === 1 |
|
338 | - && $reg_url_link !== '' |
|
339 | - && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
340 | - ); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * @return bool |
|
346 | - */ |
|
347 | - public function currentRegistrantIsNotPrimary(): bool |
|
348 | - { |
|
349 | - return $this->attendeeCount() > 1; |
|
350 | - } |
|
351 | - |
|
352 | - |
|
353 | - /** |
|
354 | - * @param string $reg_url_link |
|
355 | - * @param string $form_input |
|
356 | - * @param mixed $input_value |
|
357 | - * @return mixed|null |
|
358 | - */ |
|
359 | - public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
360 | - { |
|
361 | - // store a bit of data about the primary attendee |
|
362 | - if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | - $this->primary_registrant_data[ $form_input ] = $input_value; |
|
364 | - return $input_value; |
|
365 | - } |
|
366 | - // or copy value from primary if incoming value is not set |
|
367 | - if ($input_value === null && $this->copyPrimary()) { |
|
368 | - $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
369 | - } |
|
370 | - return $input_value; |
|
371 | - } |
|
21 | + /** |
|
22 | + * @var int |
|
23 | + */ |
|
24 | + private $attendee_counter = 0; |
|
25 | + |
|
26 | + /** |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + private $registrant_data = []; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var bool |
|
33 | + */ |
|
34 | + private $copy_primary = false; |
|
35 | + |
|
36 | + /** |
|
37 | + * @var array |
|
38 | + */ |
|
39 | + private $required_questions = []; |
|
40 | + |
|
41 | + /** |
|
42 | + * @var EE_Registration[] |
|
43 | + */ |
|
44 | + private $registrations = []; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var EE_Answer[][] |
|
48 | + */ |
|
49 | + private $registrant_answers = []; |
|
50 | + |
|
51 | + /** |
|
52 | + * array for tracking reg form data for the primary registrant |
|
53 | + * |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + private $primary_registrant_data; |
|
57 | + |
|
58 | + /** |
|
59 | + * the attendee object created for the primary registrant |
|
60 | + * |
|
61 | + * @var EE_Attendee |
|
62 | + */ |
|
63 | + private $primary_registrant; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * RegistrantData constructor. |
|
68 | + */ |
|
69 | + public function __construct() |
|
70 | + { |
|
71 | + $this->primary_registrant_data = ['line_item_id' => null,]; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + /** |
|
76 | + * @param EE_Registration $registration |
|
77 | + * @throws EE_Error |
|
78 | + */ |
|
79 | + public function initializeRegistrantData(EE_Registration $registration): void |
|
80 | + { |
|
81 | + $reg_url_link = $registration->reg_url_link(); |
|
82 | + $this->registrations[ $reg_url_link ] = $registration; |
|
83 | + $this->registrant_answers[ $reg_url_link ] = $registration->answers(); |
|
84 | + $this->registrant_data[ $reg_url_link ] = []; |
|
85 | + $this->attendee_counter++; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return int |
|
91 | + */ |
|
92 | + public function attendeeCount(): int |
|
93 | + { |
|
94 | + return $this->attendee_counter; |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + public function copyPrimary(): bool |
|
102 | + { |
|
103 | + return $this->copy_primary; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param bool $copy_primary |
|
109 | + */ |
|
110 | + public function setCopyPrimary(bool $copy_primary): void |
|
111 | + { |
|
112 | + $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $reg_url_link |
|
118 | + * @return array|null |
|
119 | + */ |
|
120 | + public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
121 | + { |
|
122 | + return $this->registrations[ $reg_url_link ] ?? null; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param string $reg_url_link |
|
128 | + * @return array|null |
|
129 | + */ |
|
130 | + public function getRegistrantData(string $reg_url_link): ?array |
|
131 | + { |
|
132 | + return $this->registrant_data[ $reg_url_link ] ?? null; |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * @param string $reg_url_link |
|
138 | + * @param string $key |
|
139 | + * @param mixed $value |
|
140 | + */ |
|
141 | + public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
142 | + { |
|
143 | + $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
149 | + * |
|
150 | + * @param string $reg_url_link |
|
151 | + * @throws EE_Error |
|
152 | + * @throws ReflectionException |
|
153 | + */ |
|
154 | + public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
155 | + { |
|
156 | + if ($this->currentRegistrantIsPrimary()) { |
|
157 | + return; |
|
158 | + } |
|
159 | + // bare minimum critical details include first name, last name, email address |
|
160 | + $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
161 | + // add address info to critical details? |
|
162 | + if ( |
|
163 | + apply_filters( |
|
164 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
165 | + false |
|
166 | + ) |
|
167 | + ) { |
|
168 | + $critical_attendee_details += [ |
|
169 | + 'ATT_address', |
|
170 | + 'ATT_address2', |
|
171 | + 'ATT_city', |
|
172 | + 'STA_ID', |
|
173 | + 'CNT_ISO', |
|
174 | + 'ATT_zip', |
|
175 | + 'ATT_phone', |
|
176 | + ]; |
|
177 | + } |
|
178 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
179 | + if ( |
|
180 | + ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
181 | + || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | + ) { |
|
183 | + $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
184 | + $critical_attendee_detail |
|
185 | + ); |
|
186 | + } |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param string $reg_url_link |
|
193 | + * @param array $registrant_data |
|
194 | + */ |
|
195 | + public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
196 | + { |
|
197 | + $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * @return array |
|
203 | + */ |
|
204 | + public function getRequiredQuestions(): array |
|
205 | + { |
|
206 | + return $this->required_questions; |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * @param string $identifier |
|
212 | + * @param string $required_question |
|
213 | + */ |
|
214 | + public function addRequiredQuestion(string $identifier, string $required_question): void |
|
215 | + { |
|
216 | + $this->required_questions[ $identifier ] = $required_question; |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + /** |
|
221 | + * @return EE_Answer[] |
|
222 | + */ |
|
223 | + public function registrantAnswers(string $reg_url_link): array |
|
224 | + { |
|
225 | + return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
226 | + } |
|
227 | + |
|
228 | + |
|
229 | + /** |
|
230 | + * @param string $reg_url_link |
|
231 | + * @param string $identifier the answer cache ID |
|
232 | + * @param EE_Answer $answer |
|
233 | + */ |
|
234 | + public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
235 | + { |
|
236 | + $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
237 | + } |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * @param string $reg_url_link |
|
242 | + * @param string $identifier |
|
243 | + * @return EE_Answer|null |
|
244 | + */ |
|
245 | + public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
246 | + { |
|
247 | + return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + |
|
252 | + /** |
|
253 | + * @param string $reg_url_link |
|
254 | + * @param string $identifier |
|
255 | + * @return bool |
|
256 | + */ |
|
257 | + public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
258 | + { |
|
259 | + $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
260 | + return $registrant_answer instanceof EE_Answer; |
|
261 | + } |
|
262 | + |
|
263 | + |
|
264 | + /** |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + public function primaryRegistrantData(): array |
|
268 | + { |
|
269 | + return $this->primary_registrant_data; |
|
270 | + } |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * @param string $key |
|
275 | + * @param mixed $value |
|
276 | + */ |
|
277 | + public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
278 | + { |
|
279 | + $this->primary_registrant_data[ $key ] = $value; |
|
280 | + } |
|
281 | + |
|
282 | + |
|
283 | + /** |
|
284 | + * @param string $key |
|
285 | + * @return mixed |
|
286 | + */ |
|
287 | + public function getPrimaryRegistrantDataValue(string $key) |
|
288 | + { |
|
289 | + return $this->primary_registrant_data[ $key ] ?? null; |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @param array $primary_registrant_data |
|
295 | + */ |
|
296 | + public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
297 | + { |
|
298 | + $this->primary_registrant_data = $primary_registrant_data; |
|
299 | + } |
|
300 | + |
|
301 | + |
|
302 | + /** |
|
303 | + * @return EE_Attendee |
|
304 | + */ |
|
305 | + public function primaryRegistrant(): EE_Attendee |
|
306 | + { |
|
307 | + return $this->primary_registrant; |
|
308 | + } |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * @return bool |
|
313 | + */ |
|
314 | + public function primaryRegistrantIsValid(): bool |
|
315 | + { |
|
316 | + return $this->primary_registrant instanceof EE_Attendee; |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * @param EE_Attendee $primary_registrant |
|
322 | + */ |
|
323 | + public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
324 | + { |
|
325 | + $this->primary_registrant = $primary_registrant; |
|
326 | + } |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * @param string $reg_url_link |
|
331 | + * @return bool |
|
332 | + */ |
|
333 | + public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
334 | + { |
|
335 | + return $this->attendeeCount() === 1 |
|
336 | + || ( |
|
337 | + $this->attendeeCount() === 1 |
|
338 | + && $reg_url_link !== '' |
|
339 | + && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
340 | + ); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * @return bool |
|
346 | + */ |
|
347 | + public function currentRegistrantIsNotPrimary(): bool |
|
348 | + { |
|
349 | + return $this->attendeeCount() > 1; |
|
350 | + } |
|
351 | + |
|
352 | + |
|
353 | + /** |
|
354 | + * @param string $reg_url_link |
|
355 | + * @param string $form_input |
|
356 | + * @param mixed $input_value |
|
357 | + * @return mixed|null |
|
358 | + */ |
|
359 | + public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
360 | + { |
|
361 | + // store a bit of data about the primary attendee |
|
362 | + if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
363 | + $this->primary_registrant_data[ $form_input ] = $input_value; |
|
364 | + return $input_value; |
|
365 | + } |
|
366 | + // or copy value from primary if incoming value is not set |
|
367 | + if ($input_value === null && $this->copyPrimary()) { |
|
368 | + $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
369 | + } |
|
370 | + return $input_value; |
|
371 | + } |
|
372 | 372 | } |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | |
54 | 54 | public function translate_js_strings() |
55 | 55 | { |
56 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
56 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | 57 | ' is a required question.', |
58 | 58 | 'event_espresso' |
59 | 59 | ); |
60 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
60 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | 61 | ' is a required question. Please enter a value for at least one of the options.', |
62 | 62 | 'event_espresso' |
63 | 63 | ); |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | 'Please answer all required questions correctly before proceeding.', |
66 | 66 | 'event_espresso' |
67 | 67 | ); |
68 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
68 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | 69 | esc_html_x( |
70 | 70 | 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
71 | 71 | 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | ), |
74 | 74 | '<br/>' |
75 | 75 | ); |
76 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
76 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | 77 | 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
78 | 78 | 'event_espresso' |
79 | 79 | ); |
80 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
80 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | 81 | 'You must enter a valid email address.', |
82 | 82 | 'event_espresso' |
83 | 83 | ); |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | if (empty($valid_data)) { |
323 | 323 | return $this->inValidDataError(); |
324 | 324 | } |
325 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
325 | + if ( ! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
326 | 326 | return $this->inValidTransactionError(); |
327 | 327 | } |
328 | 328 | // get cached registrations |
@@ -334,14 +334,14 @@ discard block |
||
334 | 334 | /** @var RegFormHandler $reg_form_handler */ |
335 | 335 | $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
336 | 336 | // extract attendee info from form data and save to model objects |
337 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
337 | + if ( ! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
338 | 338 | // return immediately if the previous step exited early due to errors |
339 | 339 | return false; |
340 | 340 | } |
341 | 341 | // if first pass thru SPCO, |
342 | 342 | // then let's check processed registrations against the total number of tickets in the cart |
343 | 343 | $registrations_processed = $reg_form_handler->attendeeCount(); |
344 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
344 | + if ( ! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
345 | 345 | return $this->registrationProcessingError($registrations_processed); |
346 | 346 | } |
347 | 347 | // mark this reg step as completed |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
409 | 409 | 'event_espresso' |
410 | 410 | ), |
411 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
411 | + '<a href="'.get_post_type_archive_link('espresso_events').'" >', |
|
412 | 412 | '</a>', |
413 | 413 | '<br />' |
414 | 414 | ); |
@@ -22,862 +22,862 @@ |
||
22 | 22 | */ |
23 | 23 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
24 | 24 | { |
25 | - /** |
|
26 | - * @var RegForm |
|
27 | - */ |
|
28 | - public $reg_form; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var int |
|
32 | - */ |
|
33 | - protected $reg_form_count = 0; |
|
34 | - |
|
35 | - |
|
36 | - /** |
|
37 | - * class constructor |
|
38 | - * |
|
39 | - * @access public |
|
40 | - * @param EE_Checkout $checkout |
|
41 | - */ |
|
42 | - public function __construct(EE_Checkout $checkout) |
|
43 | - { |
|
44 | - $this->_slug = 'attendee_information'; |
|
45 | - $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
46 | - $this->checkout = $checkout; |
|
47 | - $this->_reset_success_message(); |
|
48 | - $this->set_instructions( |
|
49 | - esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - public function translate_js_strings() |
|
55 | - { |
|
56 | - EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | - ' is a required question.', |
|
58 | - 'event_espresso' |
|
59 | - ); |
|
60 | - EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | - ' is a required question. Please enter a value for at least one of the options.', |
|
62 | - 'event_espresso' |
|
63 | - ); |
|
64 | - EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
65 | - 'Please answer all required questions correctly before proceeding.', |
|
66 | - 'event_espresso' |
|
67 | - ); |
|
68 | - EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | - esc_html_x( |
|
70 | - 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
71 | - 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
72 | - 'event_espresso' |
|
73 | - ), |
|
74 | - '<br/>' |
|
75 | - ); |
|
76 | - EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | - 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
78 | - 'event_espresso' |
|
79 | - ); |
|
80 | - EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | - 'You must enter a valid email address.', |
|
82 | - 'event_espresso' |
|
83 | - ); |
|
84 | - EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
85 | - 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
86 | - 'event_espresso' |
|
87 | - ); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - public function enqueue_styles_and_scripts() |
|
92 | - { |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - /** |
|
97 | - * @return boolean |
|
98 | - */ |
|
99 | - public function initialize_reg_step(): bool |
|
100 | - { |
|
101 | - return true; |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return RegForm |
|
107 | - * @throws DomainException |
|
108 | - * @throws InvalidArgumentException |
|
109 | - * @throws EntityNotFoundException |
|
110 | - * @throws InvalidDataTypeException |
|
111 | - * @throws InvalidInterfaceException |
|
112 | - */ |
|
113 | - public function generate_reg_form(): RegForm |
|
114 | - { |
|
115 | - $this->setLegacyFiltersForRegFormGeneration(); |
|
116 | - /** @var RegFormDependencyHandler $dependency_handler */ |
|
117 | - $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
118 | - $dependency_handler->registerDependencies(); |
|
119 | - // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
120 | - return LoaderFactory::getShared(RegForm::class, [$this]); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * @since $VID:$ |
|
126 | - */ |
|
127 | - private function setLegacyFiltersForRegFormGeneration() |
|
128 | - { |
|
129 | - add_filter( |
|
130 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters', |
|
131 | - [$this, 'registrationQuestionGroupsQueryParameters'], |
|
132 | - 1, |
|
133 | - 2 |
|
134 | - ); |
|
135 | - add_filter( |
|
136 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form', |
|
137 | - [$this, 'registrationQuestionGroupsRegForm'], |
|
138 | - 1, |
|
139 | - 3 |
|
140 | - ); |
|
141 | - add_filter( |
|
142 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo', |
|
143 | - [$this, 'registrationRegFormPrintCopyInfo'], |
|
144 | - 1, |
|
145 | - 2 |
|
146 | - ); |
|
147 | - add_filter( |
|
148 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params', |
|
149 | - [$this, 'registrationRegFormRelatedQuestionsQueryParams'], |
|
150 | - 1, |
|
151 | - 3 |
|
152 | - ); |
|
153 | - add_filter( |
|
154 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions', |
|
155 | - [$this, 'registrationRegFormBeforeQuestionGroupQuestions'], |
|
156 | - 1, |
|
157 | - 3 |
|
158 | - ); |
|
159 | - add_filter( |
|
160 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array', |
|
161 | - [$this, 'registrationRegFormSubsections'], |
|
162 | - 1, |
|
163 | - 3 |
|
164 | - ); |
|
165 | - add_filter( |
|
166 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions', |
|
167 | - [$this, 'registrationRegFormAfterQuestionGroupQuestions'], |
|
168 | - 1, |
|
169 | - 3 |
|
170 | - ); |
|
171 | - add_filter( |
|
172 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args', |
|
173 | - [$this, 'autoCopyAttendeeInfoTemplateArgs'], |
|
174 | - 1 |
|
175 | - ); |
|
176 | - add_filter( |
|
177 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options', |
|
178 | - [$this, 'generateQuestionInputCountryOptions'], |
|
179 | - 1, |
|
180 | - 4 |
|
181 | - ); |
|
182 | - add_filter( |
|
183 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options', |
|
184 | - [$this, 'generateQuestionInputStateOptions'], |
|
185 | - 1, |
|
186 | - 4 |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * @param array $query_params |
|
193 | - * @param EE_Registration $registration |
|
194 | - * @return mixed|void |
|
195 | - * @since $VID:$ |
|
196 | - */ |
|
197 | - public function registrationQuestionGroupsQueryParameters( |
|
198 | - array $query_params, |
|
199 | - EE_Registration $registration |
|
200 | - ) { |
|
201 | - return apply_filters( |
|
202 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
203 | - $query_params, |
|
204 | - $registration, |
|
205 | - $this |
|
206 | - ); |
|
207 | - } |
|
208 | - |
|
209 | - |
|
210 | - /** |
|
211 | - * @param RegFormQuestionGroup $question_group_reg_form |
|
212 | - * @param EE_Registration $registration |
|
213 | - * @param EE_Question_Group $question_group |
|
214 | - * @return mixed|void |
|
215 | - * @since $VID:$ |
|
216 | - */ |
|
217 | - public function registrationQuestionGroupsRegForm( |
|
218 | - RegFormQuestionGroup $question_group_reg_form, |
|
219 | - EE_Registration $registration, |
|
220 | - EE_Question_Group $question_group |
|
221 | - ) { |
|
222 | - return apply_filters( |
|
223 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
224 | - $question_group_reg_form, |
|
225 | - $registration, |
|
226 | - $question_group, |
|
227 | - $this |
|
228 | - ); |
|
229 | - } |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * @param int $print_copy_info |
|
234 | - * @param int $attendee_nmbr |
|
235 | - * @return mixed|void |
|
236 | - * @since $VID:$ |
|
237 | - */ |
|
238 | - public function registrationRegFormPrintCopyInfo( |
|
239 | - int $print_copy_info, |
|
240 | - int $attendee_nmbr |
|
241 | - ) { |
|
242 | - return apply_filters( |
|
243 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
244 | - $print_copy_info, |
|
245 | - $attendee_nmbr |
|
246 | - ); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * @param array $query_params |
|
252 | - * @param EE_Question_Group $question_group |
|
253 | - * @param EE_Registration $registration |
|
254 | - * @return mixed|void |
|
255 | - * @since $VID:$ |
|
256 | - */ |
|
257 | - public function registrationRegFormRelatedQuestionsQueryParams( |
|
258 | - array $query_params, |
|
259 | - EE_Question_Group $question_group, |
|
260 | - EE_Registration $registration |
|
261 | - ) { |
|
262 | - return apply_filters( |
|
263 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
264 | - $query_params, |
|
265 | - $question_group, |
|
266 | - $registration, |
|
267 | - $this |
|
268 | - ); |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - /** |
|
273 | - * @param $html |
|
274 | - * @param EE_Registration $registration |
|
275 | - * @param EE_Question_Group $question_group |
|
276 | - * @return mixed|void |
|
277 | - * @since $VID:$ |
|
278 | - */ |
|
279 | - public function registrationRegFormBeforeQuestionGroupQuestions( |
|
280 | - $html, |
|
281 | - EE_Registration $registration, |
|
282 | - EE_Question_Group $question_group |
|
283 | - ) { |
|
284 | - return apply_filters( |
|
285 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
286 | - $html, |
|
287 | - $registration, |
|
288 | - $question_group, |
|
289 | - $this |
|
290 | - ); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @param array $form_subsections |
|
296 | - * @param EE_Registration $registration |
|
297 | - * @param EE_Question_Group $question_group |
|
298 | - * @return mixed|void |
|
299 | - * @since $VID:$ |
|
300 | - */ |
|
301 | - public function registrationRegFormSubsections( |
|
302 | - array $form_subsections, |
|
303 | - EE_Registration $registration, |
|
304 | - EE_Question_Group $question_group |
|
305 | - ) { |
|
306 | - return apply_filters( |
|
307 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
308 | - $form_subsections, |
|
309 | - $registration, |
|
310 | - $question_group, |
|
311 | - $this |
|
312 | - ); |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param $html |
|
318 | - * @param EE_Registration $registration |
|
319 | - * @param EE_Question_Group $question_group |
|
320 | - * @return mixed|void |
|
321 | - * @since $VID:$ |
|
322 | - */ |
|
323 | - public function registrationRegFormAfterQuestionGroupQuestions( |
|
324 | - $html, |
|
325 | - EE_Registration $registration, |
|
326 | - EE_Question_Group $question_group |
|
327 | - ) { |
|
328 | - return apply_filters( |
|
329 | - 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
330 | - $html, |
|
331 | - $registration, |
|
332 | - $question_group, |
|
333 | - $this |
|
334 | - ); |
|
335 | - } |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * @param array $template_args |
|
340 | - * @return mixed|void |
|
341 | - * @since $VID:$ |
|
342 | - */ |
|
343 | - public function autoCopyAttendeeInfoTemplateArgs(array $template_args = []) |
|
344 | - { |
|
345 | - return apply_filters( |
|
346 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
347 | - $template_args |
|
348 | - ); |
|
349 | - } |
|
350 | - |
|
351 | - |
|
352 | - /** |
|
353 | - * @param array $country_options |
|
354 | - * @param EE_Registration $registration |
|
355 | - * @param EE_Question $question |
|
356 | - * @param EE_Answer|null $answer |
|
357 | - * @return mixed|void |
|
358 | - * @since $VID:$ |
|
359 | - */ |
|
360 | - public function generateQuestionInputCountryOptions( |
|
361 | - array $country_options, |
|
362 | - EE_Registration $registration, |
|
363 | - EE_Question $question, |
|
364 | - ?EE_Answer $answer |
|
365 | - ) { |
|
366 | - return apply_filters( |
|
367 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
368 | - $country_options, |
|
369 | - $this, |
|
370 | - $registration, |
|
371 | - $question, |
|
372 | - $answer |
|
373 | - ); |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * @param array $state_options |
|
379 | - * @param EE_Registration $registration |
|
380 | - * @param EE_Question $question |
|
381 | - * @param EE_Answer|null $answer |
|
382 | - * @return mixed|void |
|
383 | - * @since $VID:$ |
|
384 | - */ |
|
385 | - public function generateQuestionInputStateOptions( |
|
386 | - array $state_options, |
|
387 | - EE_Registration $registration, |
|
388 | - EE_Question $question, |
|
389 | - ?EE_Answer $answer |
|
390 | - ) { |
|
391 | - return apply_filters( |
|
392 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
393 | - $state_options, |
|
394 | - $this, |
|
395 | - $registration, |
|
396 | - $question, |
|
397 | - $answer |
|
398 | - ); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * looking for hooks? |
|
404 | - * this method has been replaced by: |
|
405 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
406 | - * |
|
407 | - * @deprecated $VID:$ |
|
408 | - */ |
|
409 | - private function _registrations_reg_form() |
|
410 | - { |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * looking for hooks? |
|
416 | - * this method has been replaced by: |
|
417 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
418 | - * |
|
419 | - * @deprecated $VID:$ |
|
420 | - */ |
|
421 | - private function _additional_attendee_reg_info_input() |
|
422 | - { |
|
423 | - } |
|
424 | - |
|
425 | - |
|
426 | - /** |
|
427 | - * looking for hooks? |
|
428 | - * this method has been replaced by: |
|
429 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
430 | - * |
|
431 | - * @deprecated $VID:$ |
|
432 | - */ |
|
433 | - private function _question_group_reg_form() |
|
434 | - { |
|
435 | - } |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * looking for hooks? |
|
440 | - * this method has been replaced by: |
|
441 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
442 | - * |
|
443 | - * @deprecated $VID:$ |
|
444 | - */ |
|
445 | - private function _question_group_header() |
|
446 | - { |
|
447 | - } |
|
448 | - |
|
449 | - |
|
450 | - /** |
|
451 | - * looking for hooks? |
|
452 | - * this method has been replaced by: |
|
453 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
454 | - * |
|
455 | - * @deprecated $VID:$ |
|
456 | - */ |
|
457 | - private function _copy_attendee_info_form() |
|
458 | - { |
|
459 | - } |
|
460 | - |
|
461 | - |
|
462 | - /** |
|
463 | - * looking for hooks? |
|
464 | - * this method has been replaced by: |
|
465 | - * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
466 | - * |
|
467 | - * @deprecated $VID:$ |
|
468 | - */ |
|
469 | - private function _auto_copy_attendee_info() |
|
470 | - { |
|
471 | - } |
|
472 | - |
|
473 | - |
|
474 | - /** |
|
475 | - * looking for hooks? |
|
476 | - * this method has been replaced by: |
|
477 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
478 | - * |
|
479 | - * @deprecated $VID:$ |
|
480 | - */ |
|
481 | - private function _copy_attendee_info_inputs() |
|
482 | - { |
|
483 | - } |
|
484 | - |
|
485 | - |
|
486 | - /** |
|
487 | - * looking for hooks? |
|
488 | - * this method has been replaced by: |
|
489 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
490 | - * |
|
491 | - * @deprecated $VID:$ |
|
492 | - */ |
|
493 | - private function _additional_primary_registrant_inputs() |
|
494 | - { |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - /** |
|
499 | - * looking for hooks? |
|
500 | - * this method has been replaced by: |
|
501 | - * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
502 | - * |
|
503 | - * @param EE_Registration $registration |
|
504 | - * @param EE_Question $question |
|
505 | - * @return EE_Form_Input_Base |
|
506 | - * @throws EE_Error |
|
507 | - * @throws ReflectionException |
|
508 | - * @deprecated $VID:$ |
|
509 | - */ |
|
510 | - public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
511 | - { |
|
512 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
513 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
514 | - return $reg_form_question_factory->create($registration, $question); |
|
515 | - } |
|
516 | - |
|
517 | - |
|
518 | - /** |
|
519 | - * looking for hooks? |
|
520 | - * this method has been replaced by: |
|
521 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
522 | - * |
|
523 | - * @deprecated $VID:$ |
|
524 | - */ |
|
525 | - private function _generate_question_input() |
|
526 | - { |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - /** |
|
531 | - * looking for hooks? |
|
532 | - * this method has been replaced by: |
|
533 | - * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
534 | - * |
|
535 | - * @param array|null $countries_list |
|
536 | - * @param EE_Question|null $question |
|
537 | - * @param EE_Registration|null $registration |
|
538 | - * @param EE_Answer|null $answer |
|
539 | - * @return array 2d keys are country IDs, values are their names |
|
540 | - * @throws EE_Error |
|
541 | - * @throws ReflectionException |
|
542 | - * @deprecated $VID:$ |
|
543 | - */ |
|
544 | - public function use_cached_countries_for_form_input( |
|
545 | - array $countries_list = null, |
|
546 | - EE_Question $question = null, |
|
547 | - EE_Registration $registration = null, |
|
548 | - EE_Answer $answer = null |
|
549 | - ): array { |
|
550 | - /** @var CountryOptions $country_options */ |
|
551 | - $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
552 | - return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * looking for hooks? |
|
558 | - * this method has been replaced by: |
|
559 | - * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
560 | - * |
|
561 | - * @param array|null $states_list |
|
562 | - * @param EE_Question|null $question |
|
563 | - * @param EE_Registration|null $registration |
|
564 | - * @param EE_Answer|null $answer |
|
565 | - * @return array 2d keys are state IDs, values are their names |
|
566 | - * @throws EE_Error |
|
567 | - * @throws ReflectionException |
|
568 | - * @deprecated $VID:$ |
|
569 | - */ |
|
570 | - public function use_cached_states_for_form_input( |
|
571 | - array $states_list = null, |
|
572 | - EE_Question $question = null, |
|
573 | - EE_Registration $registration = null, |
|
574 | - EE_Answer $answer = null |
|
575 | - ): array { |
|
576 | - /** @var StateOptions $state_options */ |
|
577 | - $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
578 | - return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
579 | - } |
|
580 | - |
|
581 | - |
|
582 | - /********************************************************************************************************/ |
|
583 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
584 | - /********************************************************************************************************/ |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * @return bool |
|
589 | - * @throws EE_Error |
|
590 | - * @throws InvalidArgumentException |
|
591 | - * @throws ReflectionException |
|
592 | - * @throws RuntimeException |
|
593 | - * @throws InvalidDataTypeException |
|
594 | - * @throws InvalidInterfaceException |
|
595 | - */ |
|
596 | - public function process_reg_step(): bool |
|
597 | - { |
|
598 | - $this->setLegacyFiltersForRegFormProcessing(); |
|
599 | - // grab validated data from form |
|
600 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
601 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
602 | - if (empty($valid_data)) { |
|
603 | - return $this->inValidDataError(); |
|
604 | - } |
|
605 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
606 | - return $this->inValidTransactionError(); |
|
607 | - } |
|
608 | - // get cached registrations |
|
609 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
610 | - // verify we got the goods |
|
611 | - if (empty($registrations)) { |
|
612 | - return $this->noRegistrationsError(); |
|
613 | - } |
|
614 | - /** @var RegFormHandler $reg_form_handler */ |
|
615 | - $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
616 | - // extract attendee info from form data and save to model objects |
|
617 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
618 | - // return immediately if the previous step exited early due to errors |
|
619 | - return false; |
|
620 | - } |
|
621 | - // if first pass thru SPCO, |
|
622 | - // then let's check processed registrations against the total number of tickets in the cart |
|
623 | - $registrations_processed = $reg_form_handler->attendeeCount(); |
|
624 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
625 | - return $this->registrationProcessingError($registrations_processed); |
|
626 | - } |
|
627 | - // mark this reg step as completed |
|
628 | - $this->set_completed(); |
|
629 | - $this->_set_success_message( |
|
630 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
631 | - ); |
|
632 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
633 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
634 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
635 | - return true; |
|
636 | - } |
|
637 | - |
|
638 | - |
|
639 | - /** |
|
640 | - * @since $VID:$ |
|
641 | - */ |
|
642 | - private function setLegacyFiltersForRegFormProcessing() |
|
643 | - { |
|
644 | - add_filter( |
|
645 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass', |
|
646 | - [$this, 'preRegistrationProcess'], |
|
647 | - 1, |
|
648 | - 5 |
|
649 | - ); |
|
650 | - add_filter( |
|
651 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data', |
|
652 | - [$this, 'validDataLineItem'], |
|
653 | - 1, |
|
654 | - 2 |
|
655 | - ); |
|
656 | - add_filter( |
|
657 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
658 | - [$this, 'saveRegistrationFormInput'], |
|
659 | - 1, |
|
660 | - 4 |
|
661 | - ); |
|
662 | - add_filter( |
|
663 | - 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
664 | - [$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'], |
|
665 | - 1 |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - /** |
|
671 | - * @param bool $bypass |
|
672 | - * @param int $attendee_count |
|
673 | - * @param EE_Registration $registration |
|
674 | - * @param array $registrations |
|
675 | - * @param array $reg_form_data |
|
676 | - * @return mixed|void |
|
677 | - * @since $VID:$ |
|
678 | - */ |
|
679 | - public function preRegistrationProcess( |
|
680 | - bool $bypass, |
|
681 | - int $attendee_count, |
|
682 | - EE_Registration $registration, |
|
683 | - array $registrations, |
|
684 | - array $reg_form_data |
|
685 | - ) { |
|
686 | - return apply_filters( |
|
687 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
688 | - $bypass, |
|
689 | - $attendee_count, |
|
690 | - $registration, |
|
691 | - $registrations, |
|
692 | - $reg_form_data, |
|
693 | - $this |
|
694 | - ); |
|
695 | - } |
|
696 | - |
|
697 | - |
|
698 | - /** |
|
699 | - * @param array $reg_form_data |
|
700 | - * @param EE_Registration $registration |
|
701 | - * @return mixed|void |
|
702 | - * @since $VID:$ |
|
703 | - */ |
|
704 | - public function validDataLineItem(array $reg_form_data, EE_Registration $registration) |
|
705 | - { |
|
706 | - return apply_filters( |
|
707 | - 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
708 | - $reg_form_data, |
|
709 | - $registration |
|
710 | - ); |
|
711 | - } |
|
712 | - |
|
713 | - |
|
714 | - /** |
|
715 | - * @param bool $save |
|
716 | - * @param EE_Registration $registration |
|
717 | - * @param $form_input |
|
718 | - * @param $input_value |
|
719 | - * @return mixed|void |
|
720 | - * @since $VID:$ |
|
721 | - */ |
|
722 | - public function saveRegistrationFormInput(bool $save, EE_Registration $registration, $form_input, $input_value) |
|
723 | - { |
|
724 | - return apply_filters( |
|
725 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
726 | - $save, |
|
727 | - $registration, |
|
728 | - $form_input, |
|
729 | - $input_value, |
|
730 | - $this |
|
731 | - ); |
|
732 | - } |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * @param bool $merge_data |
|
737 | - * @return mixed|void |
|
738 | - * @since $VID:$ |
|
739 | - */ |
|
740 | - public function mergeAddressDetailsWithCriticalAttendeeDetails(bool $merge_data) |
|
741 | - { |
|
742 | - return apply_filters( |
|
743 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
744 | - $merge_data |
|
745 | - ); |
|
746 | - } |
|
747 | - |
|
748 | - |
|
749 | - /** |
|
750 | - * @return bool |
|
751 | - * @since $VID:$ |
|
752 | - */ |
|
753 | - private function inValidDataError(): bool |
|
754 | - { |
|
755 | - EE_Error::add_error( |
|
756 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
757 | - __FILE__, |
|
758 | - __FUNCTION__, |
|
759 | - __LINE__ |
|
760 | - ); |
|
761 | - return false; |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - /** |
|
766 | - * @return bool |
|
767 | - * @since $VID:$ |
|
768 | - */ |
|
769 | - private function inValidTransactionError(): bool |
|
770 | - { |
|
771 | - EE_Error::add_error( |
|
772 | - esc_html__( |
|
773 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
774 | - 'event_espresso' |
|
775 | - ), |
|
776 | - __FILE__, |
|
777 | - __FUNCTION__, |
|
778 | - __LINE__ |
|
779 | - ); |
|
780 | - return false; |
|
781 | - } |
|
782 | - |
|
783 | - |
|
784 | - /** |
|
785 | - * @return bool |
|
786 | - * @since $VID:$ |
|
787 | - */ |
|
788 | - private function noRegistrationsError(): bool |
|
789 | - { |
|
790 | - // combine the old translated string with a new one, in order to not break translations |
|
791 | - $error_message = esc_html__( |
|
792 | - 'Your form data could not be applied to any valid registrations.', |
|
793 | - 'event_espresso' |
|
794 | - ); |
|
795 | - $error_message .= sprintf( |
|
796 | - esc_html_x( |
|
797 | - '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
798 | - '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
799 | - 'event_espresso' |
|
800 | - ), |
|
801 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
802 | - '</a>', |
|
803 | - '<br />' |
|
804 | - ); |
|
805 | - EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
806 | - return false; |
|
807 | - } |
|
808 | - |
|
809 | - |
|
810 | - /** |
|
811 | - * @param int $registrations_processed |
|
812 | - * @return bool |
|
813 | - * @since $VID:$ |
|
814 | - */ |
|
815 | - private function registrationProcessingError(int $registrations_processed): bool |
|
816 | - { |
|
817 | - // generate a correctly translated string for all possible singular/plural combinations |
|
818 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
819 | - $error_msg = sprintf( |
|
820 | - esc_html_x( |
|
821 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
822 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
823 | - 'event_espresso' |
|
824 | - ), |
|
825 | - $this->checkout->total_ticket_count, |
|
826 | - $registrations_processed |
|
827 | - ); |
|
828 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
829 | - $error_msg = sprintf( |
|
830 | - esc_html_x( |
|
831 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
832 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
833 | - 'event_espresso' |
|
834 | - ), |
|
835 | - $this->checkout->total_ticket_count, |
|
836 | - $registrations_processed |
|
837 | - ); |
|
838 | - } else { |
|
839 | - $error_msg = sprintf( |
|
840 | - esc_html__( |
|
841 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
842 | - 'event_espresso' |
|
843 | - ), |
|
844 | - $this->checkout->total_ticket_count, |
|
845 | - $registrations_processed |
|
846 | - ); |
|
847 | - } |
|
848 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
849 | - return false; |
|
850 | - } |
|
851 | - |
|
852 | - |
|
853 | - /** |
|
854 | - * update_reg_step |
|
855 | - * this is the final step after a user revisits the site to edit their attendee information |
|
856 | - * this gets called AFTER the process_reg_step() method above |
|
857 | - * |
|
858 | - * @return bool |
|
859 | - * @throws EE_Error |
|
860 | - * @throws InvalidArgumentException |
|
861 | - * @throws ReflectionException |
|
862 | - * @throws RuntimeException |
|
863 | - * @throws InvalidDataTypeException |
|
864 | - * @throws InvalidInterfaceException |
|
865 | - */ |
|
866 | - public function update_reg_step(): bool |
|
867 | - { |
|
868 | - // save everything |
|
869 | - if ($this->process_reg_step()) { |
|
870 | - $this->checkout->redirect = true; |
|
871 | - $this->checkout->redirect_url = add_query_arg( |
|
872 | - [ |
|
873 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
874 | - 'revisit' => true, |
|
875 | - ], |
|
876 | - $this->checkout->thank_you_page_url |
|
877 | - ); |
|
878 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
879 | - return true; |
|
880 | - } |
|
881 | - return false; |
|
882 | - } |
|
25 | + /** |
|
26 | + * @var RegForm |
|
27 | + */ |
|
28 | + public $reg_form; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var int |
|
32 | + */ |
|
33 | + protected $reg_form_count = 0; |
|
34 | + |
|
35 | + |
|
36 | + /** |
|
37 | + * class constructor |
|
38 | + * |
|
39 | + * @access public |
|
40 | + * @param EE_Checkout $checkout |
|
41 | + */ |
|
42 | + public function __construct(EE_Checkout $checkout) |
|
43 | + { |
|
44 | + $this->_slug = 'attendee_information'; |
|
45 | + $this->_name = esc_html__('Attendee Information', 'event_espresso'); |
|
46 | + $this->checkout = $checkout; |
|
47 | + $this->_reset_success_message(); |
|
48 | + $this->set_instructions( |
|
49 | + esc_html__('Please answer the following registration questions before proceeding.', 'event_espresso') |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + public function translate_js_strings() |
|
55 | + { |
|
56 | + EE_Registry::$i18n_js_strings['required_field'] = esc_html__( |
|
57 | + ' is a required question.', |
|
58 | + 'event_espresso' |
|
59 | + ); |
|
60 | + EE_Registry::$i18n_js_strings['required_multi_field'] = esc_html__( |
|
61 | + ' is a required question. Please enter a value for at least one of the options.', |
|
62 | + 'event_espresso' |
|
63 | + ); |
|
64 | + EE_Registry::$i18n_js_strings['answer_required_questions'] = esc_html__( |
|
65 | + 'Please answer all required questions correctly before proceeding.', |
|
66 | + 'event_espresso' |
|
67 | + ); |
|
68 | + EE_Registry::$i18n_js_strings['attendee_info_copied'] = sprintf( |
|
69 | + esc_html_x( |
|
70 | + 'The attendee information was successfully copied.%sPlease ensure the rest of the registration form is completed before proceeding.', |
|
71 | + 'The attendee information was successfully copied.(line break)Please ensure the rest of the registration form is completed before proceeding.', |
|
72 | + 'event_espresso' |
|
73 | + ), |
|
74 | + '<br/>' |
|
75 | + ); |
|
76 | + EE_Registry::$i18n_js_strings['attendee_info_copy_error'] = esc_html__( |
|
77 | + 'An unknown error occurred on the server while attempting to copy the attendee information. Please refresh the page and try again.', |
|
78 | + 'event_espresso' |
|
79 | + ); |
|
80 | + EE_Registry::$i18n_js_strings['enter_valid_email'] = esc_html__( |
|
81 | + 'You must enter a valid email address.', |
|
82 | + 'event_espresso' |
|
83 | + ); |
|
84 | + EE_Registry::$i18n_js_strings['valid_email_and_questions'] = esc_html__( |
|
85 | + 'You must enter a valid email address and answer all other required questions before you can proceed.', |
|
86 | + 'event_espresso' |
|
87 | + ); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + public function enqueue_styles_and_scripts() |
|
92 | + { |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + /** |
|
97 | + * @return boolean |
|
98 | + */ |
|
99 | + public function initialize_reg_step(): bool |
|
100 | + { |
|
101 | + return true; |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return RegForm |
|
107 | + * @throws DomainException |
|
108 | + * @throws InvalidArgumentException |
|
109 | + * @throws EntityNotFoundException |
|
110 | + * @throws InvalidDataTypeException |
|
111 | + * @throws InvalidInterfaceException |
|
112 | + */ |
|
113 | + public function generate_reg_form(): RegForm |
|
114 | + { |
|
115 | + $this->setLegacyFiltersForRegFormGeneration(); |
|
116 | + /** @var RegFormDependencyHandler $dependency_handler */ |
|
117 | + $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
118 | + $dependency_handler->registerDependencies(); |
|
119 | + // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
120 | + return LoaderFactory::getShared(RegForm::class, [$this]); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * @since $VID:$ |
|
126 | + */ |
|
127 | + private function setLegacyFiltersForRegFormGeneration() |
|
128 | + { |
|
129 | + add_filter( |
|
130 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_groups_query_parameters', |
|
131 | + [$this, 'registrationQuestionGroupsQueryParameters'], |
|
132 | + 1, |
|
133 | + 2 |
|
134 | + ); |
|
135 | + add_filter( |
|
136 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__question_group_reg_form', |
|
137 | + [$this, 'registrationQuestionGroupsRegForm'], |
|
138 | + 1, |
|
139 | + 3 |
|
140 | + ); |
|
141 | + add_filter( |
|
142 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantForm__generateFormArgs__printCopyInfo', |
|
143 | + [$this, 'registrationRegFormPrintCopyInfo'], |
|
144 | + 1, |
|
145 | + 2 |
|
146 | + ); |
|
147 | + add_filter( |
|
148 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__related_questions_query_params', |
|
149 | + [$this, 'registrationRegFormRelatedQuestionsQueryParams'], |
|
150 | + 1, |
|
151 | + 3 |
|
152 | + ); |
|
153 | + add_filter( |
|
154 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__before_question_group_questions', |
|
155 | + [$this, 'registrationRegFormBeforeQuestionGroupQuestions'], |
|
156 | + 1, |
|
157 | + 3 |
|
158 | + ); |
|
159 | + add_filter( |
|
160 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__subsections_array', |
|
161 | + [$this, 'registrationRegFormSubsections'], |
|
162 | + 1, |
|
163 | + 3 |
|
164 | + ); |
|
165 | + add_filter( |
|
166 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormQuestionGroup__generateFormArgs__after_question_group_questions', |
|
167 | + [$this, 'registrationRegFormAfterQuestionGroupQuestions'], |
|
168 | + 1, |
|
169 | + 3 |
|
170 | + ); |
|
171 | + add_filter( |
|
172 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_AutoCopyAttendeeInfoForm__construct__template_args', |
|
173 | + [$this, 'autoCopyAttendeeInfoTemplateArgs'], |
|
174 | + 1 |
|
175 | + ); |
|
176 | + add_filter( |
|
177 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_CountryOptions__generateLegacyCountryOptions__country_options', |
|
178 | + [$this, 'generateQuestionInputCountryOptions'], |
|
179 | + 1, |
|
180 | + 4 |
|
181 | + ); |
|
182 | + add_filter( |
|
183 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_StateOptions__generateLegacyStateOptions__state_options', |
|
184 | + [$this, 'generateQuestionInputStateOptions'], |
|
185 | + 1, |
|
186 | + 4 |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * @param array $query_params |
|
193 | + * @param EE_Registration $registration |
|
194 | + * @return mixed|void |
|
195 | + * @since $VID:$ |
|
196 | + */ |
|
197 | + public function registrationQuestionGroupsQueryParameters( |
|
198 | + array $query_params, |
|
199 | + EE_Registration $registration |
|
200 | + ) { |
|
201 | + return apply_filters( |
|
202 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form__question_groups_query_parameters', |
|
203 | + $query_params, |
|
204 | + $registration, |
|
205 | + $this |
|
206 | + ); |
|
207 | + } |
|
208 | + |
|
209 | + |
|
210 | + /** |
|
211 | + * @param RegFormQuestionGroup $question_group_reg_form |
|
212 | + * @param EE_Registration $registration |
|
213 | + * @param EE_Question_Group $question_group |
|
214 | + * @return mixed|void |
|
215 | + * @since $VID:$ |
|
216 | + */ |
|
217 | + public function registrationQuestionGroupsRegForm( |
|
218 | + RegFormQuestionGroup $question_group_reg_form, |
|
219 | + EE_Registration $registration, |
|
220 | + EE_Question_Group $question_group |
|
221 | + ) { |
|
222 | + return apply_filters( |
|
223 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', |
|
224 | + $question_group_reg_form, |
|
225 | + $registration, |
|
226 | + $question_group, |
|
227 | + $this |
|
228 | + ); |
|
229 | + } |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * @param int $print_copy_info |
|
234 | + * @param int $attendee_nmbr |
|
235 | + * @return mixed|void |
|
236 | + * @since $VID:$ |
|
237 | + */ |
|
238 | + public function registrationRegFormPrintCopyInfo( |
|
239 | + int $print_copy_info, |
|
240 | + int $attendee_nmbr |
|
241 | + ) { |
|
242 | + return apply_filters( |
|
243 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___registrations_reg_form___printCopyInfo', |
|
244 | + $print_copy_info, |
|
245 | + $attendee_nmbr |
|
246 | + ); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * @param array $query_params |
|
252 | + * @param EE_Question_Group $question_group |
|
253 | + * @param EE_Registration $registration |
|
254 | + * @return mixed|void |
|
255 | + * @since $VID:$ |
|
256 | + */ |
|
257 | + public function registrationRegFormRelatedQuestionsQueryParams( |
|
258 | + array $query_params, |
|
259 | + EE_Question_Group $question_group, |
|
260 | + EE_Registration $registration |
|
261 | + ) { |
|
262 | + return apply_filters( |
|
263 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__related_questions_query_params', |
|
264 | + $query_params, |
|
265 | + $question_group, |
|
266 | + $registration, |
|
267 | + $this |
|
268 | + ); |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + /** |
|
273 | + * @param $html |
|
274 | + * @param EE_Registration $registration |
|
275 | + * @param EE_Question_Group $question_group |
|
276 | + * @return mixed|void |
|
277 | + * @since $VID:$ |
|
278 | + */ |
|
279 | + public function registrationRegFormBeforeQuestionGroupQuestions( |
|
280 | + $html, |
|
281 | + EE_Registration $registration, |
|
282 | + EE_Question_Group $question_group |
|
283 | + ) { |
|
284 | + return apply_filters( |
|
285 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', |
|
286 | + $html, |
|
287 | + $registration, |
|
288 | + $question_group, |
|
289 | + $this |
|
290 | + ); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @param array $form_subsections |
|
296 | + * @param EE_Registration $registration |
|
297 | + * @param EE_Question_Group $question_group |
|
298 | + * @return mixed|void |
|
299 | + * @since $VID:$ |
|
300 | + */ |
|
301 | + public function registrationRegFormSubsections( |
|
302 | + array $form_subsections, |
|
303 | + EE_Registration $registration, |
|
304 | + EE_Question_Group $question_group |
|
305 | + ) { |
|
306 | + return apply_filters( |
|
307 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__question_group_reg_form__subsections_array', |
|
308 | + $form_subsections, |
|
309 | + $registration, |
|
310 | + $question_group, |
|
311 | + $this |
|
312 | + ); |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param $html |
|
318 | + * @param EE_Registration $registration |
|
319 | + * @param EE_Question_Group $question_group |
|
320 | + * @return mixed|void |
|
321 | + * @since $VID:$ |
|
322 | + */ |
|
323 | + public function registrationRegFormAfterQuestionGroupQuestions( |
|
324 | + $html, |
|
325 | + EE_Registration $registration, |
|
326 | + EE_Question_Group $question_group |
|
327 | + ) { |
|
328 | + return apply_filters( |
|
329 | + 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', |
|
330 | + $html, |
|
331 | + $registration, |
|
332 | + $question_group, |
|
333 | + $this |
|
334 | + ); |
|
335 | + } |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * @param array $template_args |
|
340 | + * @return mixed|void |
|
341 | + * @since $VID:$ |
|
342 | + */ |
|
343 | + public function autoCopyAttendeeInfoTemplateArgs(array $template_args = []) |
|
344 | + { |
|
345 | + return apply_filters( |
|
346 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__auto_copy_attendee_info__template_args', |
|
347 | + $template_args |
|
348 | + ); |
|
349 | + } |
|
350 | + |
|
351 | + |
|
352 | + /** |
|
353 | + * @param array $country_options |
|
354 | + * @param EE_Registration $registration |
|
355 | + * @param EE_Question $question |
|
356 | + * @param EE_Answer|null $answer |
|
357 | + * @return mixed|void |
|
358 | + * @since $VID:$ |
|
359 | + */ |
|
360 | + public function generateQuestionInputCountryOptions( |
|
361 | + array $country_options, |
|
362 | + EE_Registration $registration, |
|
363 | + EE_Question $question, |
|
364 | + ?EE_Answer $answer |
|
365 | + ) { |
|
366 | + return apply_filters( |
|
367 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', |
|
368 | + $country_options, |
|
369 | + $this, |
|
370 | + $registration, |
|
371 | + $question, |
|
372 | + $answer |
|
373 | + ); |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * @param array $state_options |
|
379 | + * @param EE_Registration $registration |
|
380 | + * @param EE_Question $question |
|
381 | + * @param EE_Answer|null $answer |
|
382 | + * @return mixed|void |
|
383 | + * @since $VID:$ |
|
384 | + */ |
|
385 | + public function generateQuestionInputStateOptions( |
|
386 | + array $state_options, |
|
387 | + EE_Registration $registration, |
|
388 | + EE_Question $question, |
|
389 | + ?EE_Answer $answer |
|
390 | + ) { |
|
391 | + return apply_filters( |
|
392 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', |
|
393 | + $state_options, |
|
394 | + $this, |
|
395 | + $registration, |
|
396 | + $question, |
|
397 | + $answer |
|
398 | + ); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * looking for hooks? |
|
404 | + * this method has been replaced by: |
|
405 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
406 | + * |
|
407 | + * @deprecated $VID:$ |
|
408 | + */ |
|
409 | + private function _registrations_reg_form() |
|
410 | + { |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * looking for hooks? |
|
416 | + * this method has been replaced by: |
|
417 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
418 | + * |
|
419 | + * @deprecated $VID:$ |
|
420 | + */ |
|
421 | + private function _additional_attendee_reg_info_input() |
|
422 | + { |
|
423 | + } |
|
424 | + |
|
425 | + |
|
426 | + /** |
|
427 | + * looking for hooks? |
|
428 | + * this method has been replaced by: |
|
429 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
430 | + * |
|
431 | + * @deprecated $VID:$ |
|
432 | + */ |
|
433 | + private function _question_group_reg_form() |
|
434 | + { |
|
435 | + } |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * looking for hooks? |
|
440 | + * this method has been replaced by: |
|
441 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
442 | + * |
|
443 | + * @deprecated $VID:$ |
|
444 | + */ |
|
445 | + private function _question_group_header() |
|
446 | + { |
|
447 | + } |
|
448 | + |
|
449 | + |
|
450 | + /** |
|
451 | + * looking for hooks? |
|
452 | + * this method has been replaced by: |
|
453 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
454 | + * |
|
455 | + * @deprecated $VID:$ |
|
456 | + */ |
|
457 | + private function _copy_attendee_info_form() |
|
458 | + { |
|
459 | + } |
|
460 | + |
|
461 | + |
|
462 | + /** |
|
463 | + * looking for hooks? |
|
464 | + * this method has been replaced by: |
|
465 | + * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
466 | + * |
|
467 | + * @deprecated $VID:$ |
|
468 | + */ |
|
469 | + private function _auto_copy_attendee_info() |
|
470 | + { |
|
471 | + } |
|
472 | + |
|
473 | + |
|
474 | + /** |
|
475 | + * looking for hooks? |
|
476 | + * this method has been replaced by: |
|
477 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
478 | + * |
|
479 | + * @deprecated $VID:$ |
|
480 | + */ |
|
481 | + private function _copy_attendee_info_inputs() |
|
482 | + { |
|
483 | + } |
|
484 | + |
|
485 | + |
|
486 | + /** |
|
487 | + * looking for hooks? |
|
488 | + * this method has been replaced by: |
|
489 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
490 | + * |
|
491 | + * @deprecated $VID:$ |
|
492 | + */ |
|
493 | + private function _additional_primary_registrant_inputs() |
|
494 | + { |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + /** |
|
499 | + * looking for hooks? |
|
500 | + * this method has been replaced by: |
|
501 | + * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
502 | + * |
|
503 | + * @param EE_Registration $registration |
|
504 | + * @param EE_Question $question |
|
505 | + * @return EE_Form_Input_Base |
|
506 | + * @throws EE_Error |
|
507 | + * @throws ReflectionException |
|
508 | + * @deprecated $VID:$ |
|
509 | + */ |
|
510 | + public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
511 | + { |
|
512 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
513 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
514 | + return $reg_form_question_factory->create($registration, $question); |
|
515 | + } |
|
516 | + |
|
517 | + |
|
518 | + /** |
|
519 | + * looking for hooks? |
|
520 | + * this method has been replaced by: |
|
521 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
522 | + * |
|
523 | + * @deprecated $VID:$ |
|
524 | + */ |
|
525 | + private function _generate_question_input() |
|
526 | + { |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + /** |
|
531 | + * looking for hooks? |
|
532 | + * this method has been replaced by: |
|
533 | + * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
534 | + * |
|
535 | + * @param array|null $countries_list |
|
536 | + * @param EE_Question|null $question |
|
537 | + * @param EE_Registration|null $registration |
|
538 | + * @param EE_Answer|null $answer |
|
539 | + * @return array 2d keys are country IDs, values are their names |
|
540 | + * @throws EE_Error |
|
541 | + * @throws ReflectionException |
|
542 | + * @deprecated $VID:$ |
|
543 | + */ |
|
544 | + public function use_cached_countries_for_form_input( |
|
545 | + array $countries_list = null, |
|
546 | + EE_Question $question = null, |
|
547 | + EE_Registration $registration = null, |
|
548 | + EE_Answer $answer = null |
|
549 | + ): array { |
|
550 | + /** @var CountryOptions $country_options */ |
|
551 | + $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
552 | + return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * looking for hooks? |
|
558 | + * this method has been replaced by: |
|
559 | + * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
560 | + * |
|
561 | + * @param array|null $states_list |
|
562 | + * @param EE_Question|null $question |
|
563 | + * @param EE_Registration|null $registration |
|
564 | + * @param EE_Answer|null $answer |
|
565 | + * @return array 2d keys are state IDs, values are their names |
|
566 | + * @throws EE_Error |
|
567 | + * @throws ReflectionException |
|
568 | + * @deprecated $VID:$ |
|
569 | + */ |
|
570 | + public function use_cached_states_for_form_input( |
|
571 | + array $states_list = null, |
|
572 | + EE_Question $question = null, |
|
573 | + EE_Registration $registration = null, |
|
574 | + EE_Answer $answer = null |
|
575 | + ): array { |
|
576 | + /** @var StateOptions $state_options */ |
|
577 | + $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
578 | + return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
579 | + } |
|
580 | + |
|
581 | + |
|
582 | + /********************************************************************************************************/ |
|
583 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
584 | + /********************************************************************************************************/ |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * @return bool |
|
589 | + * @throws EE_Error |
|
590 | + * @throws InvalidArgumentException |
|
591 | + * @throws ReflectionException |
|
592 | + * @throws RuntimeException |
|
593 | + * @throws InvalidDataTypeException |
|
594 | + * @throws InvalidInterfaceException |
|
595 | + */ |
|
596 | + public function process_reg_step(): bool |
|
597 | + { |
|
598 | + $this->setLegacyFiltersForRegFormProcessing(); |
|
599 | + // grab validated data from form |
|
600 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
601 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
602 | + if (empty($valid_data)) { |
|
603 | + return $this->inValidDataError(); |
|
604 | + } |
|
605 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
606 | + return $this->inValidTransactionError(); |
|
607 | + } |
|
608 | + // get cached registrations |
|
609 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
610 | + // verify we got the goods |
|
611 | + if (empty($registrations)) { |
|
612 | + return $this->noRegistrationsError(); |
|
613 | + } |
|
614 | + /** @var RegFormHandler $reg_form_handler */ |
|
615 | + $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
616 | + // extract attendee info from form data and save to model objects |
|
617 | + if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
618 | + // return immediately if the previous step exited early due to errors |
|
619 | + return false; |
|
620 | + } |
|
621 | + // if first pass thru SPCO, |
|
622 | + // then let's check processed registrations against the total number of tickets in the cart |
|
623 | + $registrations_processed = $reg_form_handler->attendeeCount(); |
|
624 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
625 | + return $this->registrationProcessingError($registrations_processed); |
|
626 | + } |
|
627 | + // mark this reg step as completed |
|
628 | + $this->set_completed(); |
|
629 | + $this->_set_success_message( |
|
630 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
631 | + ); |
|
632 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
633 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
634 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
635 | + return true; |
|
636 | + } |
|
637 | + |
|
638 | + |
|
639 | + /** |
|
640 | + * @since $VID:$ |
|
641 | + */ |
|
642 | + private function setLegacyFiltersForRegFormProcessing() |
|
643 | + { |
|
644 | + add_filter( |
|
645 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegistrations__bypass', |
|
646 | + [$this, 'preRegistrationProcess'], |
|
647 | + 1, |
|
648 | + 5 |
|
649 | + ); |
|
650 | + add_filter( |
|
651 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormHandler__processRegFormData__registrant_form_data', |
|
652 | + [$this, 'validDataLineItem'], |
|
653 | + 1, |
|
654 | + 2 |
|
655 | + ); |
|
656 | + add_filter( |
|
657 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegFormInputHandler__saveRegistrationFormInput', |
|
658 | + [$this, 'saveRegistrationFormInput'], |
|
659 | + 1, |
|
660 | + 4 |
|
661 | + ); |
|
662 | + add_filter( |
|
663 | + 'FHEE__EventEspresso_core_domain_services_registration_form_v1_RegistrantData__ensureCriticalRegistrantDataIsSet', |
|
664 | + [$this, 'mergeAddressDetailsWithCriticalAttendeeDetails'], |
|
665 | + 1 |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + /** |
|
671 | + * @param bool $bypass |
|
672 | + * @param int $attendee_count |
|
673 | + * @param EE_Registration $registration |
|
674 | + * @param array $registrations |
|
675 | + * @param array $reg_form_data |
|
676 | + * @return mixed|void |
|
677 | + * @since $VID:$ |
|
678 | + */ |
|
679 | + public function preRegistrationProcess( |
|
680 | + bool $bypass, |
|
681 | + int $attendee_count, |
|
682 | + EE_Registration $registration, |
|
683 | + array $registrations, |
|
684 | + array $reg_form_data |
|
685 | + ) { |
|
686 | + return apply_filters( |
|
687 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___process_registrations__pre_registration_process', |
|
688 | + $bypass, |
|
689 | + $attendee_count, |
|
690 | + $registration, |
|
691 | + $registrations, |
|
692 | + $reg_form_data, |
|
693 | + $this |
|
694 | + ); |
|
695 | + } |
|
696 | + |
|
697 | + |
|
698 | + /** |
|
699 | + * @param array $reg_form_data |
|
700 | + * @param EE_Registration $registration |
|
701 | + * @return mixed|void |
|
702 | + * @since $VID:$ |
|
703 | + */ |
|
704 | + public function validDataLineItem(array $reg_form_data, EE_Registration $registration) |
|
705 | + { |
|
706 | + return apply_filters( |
|
707 | + 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', |
|
708 | + $reg_form_data, |
|
709 | + $registration |
|
710 | + ); |
|
711 | + } |
|
712 | + |
|
713 | + |
|
714 | + /** |
|
715 | + * @param bool $save |
|
716 | + * @param EE_Registration $registration |
|
717 | + * @param $form_input |
|
718 | + * @param $input_value |
|
719 | + * @return mixed|void |
|
720 | + * @since $VID:$ |
|
721 | + */ |
|
722 | + public function saveRegistrationFormInput(bool $save, EE_Registration $registration, $form_input, $input_value) |
|
723 | + { |
|
724 | + return apply_filters( |
|
725 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___save_registration_form_input', |
|
726 | + $save, |
|
727 | + $registration, |
|
728 | + $form_input, |
|
729 | + $input_value, |
|
730 | + $this |
|
731 | + ); |
|
732 | + } |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * @param bool $merge_data |
|
737 | + * @return mixed|void |
|
738 | + * @since $VID:$ |
|
739 | + */ |
|
740 | + public function mergeAddressDetailsWithCriticalAttendeeDetails(bool $merge_data) |
|
741 | + { |
|
742 | + return apply_filters( |
|
743 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
744 | + $merge_data |
|
745 | + ); |
|
746 | + } |
|
747 | + |
|
748 | + |
|
749 | + /** |
|
750 | + * @return bool |
|
751 | + * @since $VID:$ |
|
752 | + */ |
|
753 | + private function inValidDataError(): bool |
|
754 | + { |
|
755 | + EE_Error::add_error( |
|
756 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
757 | + __FILE__, |
|
758 | + __FUNCTION__, |
|
759 | + __LINE__ |
|
760 | + ); |
|
761 | + return false; |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + /** |
|
766 | + * @return bool |
|
767 | + * @since $VID:$ |
|
768 | + */ |
|
769 | + private function inValidTransactionError(): bool |
|
770 | + { |
|
771 | + EE_Error::add_error( |
|
772 | + esc_html__( |
|
773 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
774 | + 'event_espresso' |
|
775 | + ), |
|
776 | + __FILE__, |
|
777 | + __FUNCTION__, |
|
778 | + __LINE__ |
|
779 | + ); |
|
780 | + return false; |
|
781 | + } |
|
782 | + |
|
783 | + |
|
784 | + /** |
|
785 | + * @return bool |
|
786 | + * @since $VID:$ |
|
787 | + */ |
|
788 | + private function noRegistrationsError(): bool |
|
789 | + { |
|
790 | + // combine the old translated string with a new one, in order to not break translations |
|
791 | + $error_message = esc_html__( |
|
792 | + 'Your form data could not be applied to any valid registrations.', |
|
793 | + 'event_espresso' |
|
794 | + ); |
|
795 | + $error_message .= sprintf( |
|
796 | + esc_html_x( |
|
797 | + '%3$sThis can sometimes happen if too much time has been taken to complete the registration process.%3$sPlease return to the %1$sEvent List%2$s and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
798 | + '(line break)This can sometimes happen if too much time has been taken to complete the registration process.(line break)Please return to the (link)Event List(end link) and reselect your tickets. If the problem continues, please contact the site administrator.', |
|
799 | + 'event_espresso' |
|
800 | + ), |
|
801 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
802 | + '</a>', |
|
803 | + '<br />' |
|
804 | + ); |
|
805 | + EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
806 | + return false; |
|
807 | + } |
|
808 | + |
|
809 | + |
|
810 | + /** |
|
811 | + * @param int $registrations_processed |
|
812 | + * @return bool |
|
813 | + * @since $VID:$ |
|
814 | + */ |
|
815 | + private function registrationProcessingError(int $registrations_processed): bool |
|
816 | + { |
|
817 | + // generate a correctly translated string for all possible singular/plural combinations |
|
818 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
819 | + $error_msg = sprintf( |
|
820 | + esc_html_x( |
|
821 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
822 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
823 | + 'event_espresso' |
|
824 | + ), |
|
825 | + $this->checkout->total_ticket_count, |
|
826 | + $registrations_processed |
|
827 | + ); |
|
828 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
829 | + $error_msg = sprintf( |
|
830 | + esc_html_x( |
|
831 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
832 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
833 | + 'event_espresso' |
|
834 | + ), |
|
835 | + $this->checkout->total_ticket_count, |
|
836 | + $registrations_processed |
|
837 | + ); |
|
838 | + } else { |
|
839 | + $error_msg = sprintf( |
|
840 | + esc_html__( |
|
841 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
842 | + 'event_espresso' |
|
843 | + ), |
|
844 | + $this->checkout->total_ticket_count, |
|
845 | + $registrations_processed |
|
846 | + ); |
|
847 | + } |
|
848 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
849 | + return false; |
|
850 | + } |
|
851 | + |
|
852 | + |
|
853 | + /** |
|
854 | + * update_reg_step |
|
855 | + * this is the final step after a user revisits the site to edit their attendee information |
|
856 | + * this gets called AFTER the process_reg_step() method above |
|
857 | + * |
|
858 | + * @return bool |
|
859 | + * @throws EE_Error |
|
860 | + * @throws InvalidArgumentException |
|
861 | + * @throws ReflectionException |
|
862 | + * @throws RuntimeException |
|
863 | + * @throws InvalidDataTypeException |
|
864 | + * @throws InvalidInterfaceException |
|
865 | + */ |
|
866 | + public function update_reg_step(): bool |
|
867 | + { |
|
868 | + // save everything |
|
869 | + if ($this->process_reg_step()) { |
|
870 | + $this->checkout->redirect = true; |
|
871 | + $this->checkout->redirect_url = add_query_arg( |
|
872 | + [ |
|
873 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
874 | + 'revisit' => true, |
|
875 | + ], |
|
876 | + $this->checkout->thank_you_page_url |
|
877 | + ); |
|
878 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
879 | + return true; |
|
880 | + } |
|
881 | + return false; |
|
882 | + } |
|
883 | 883 | } |
@@ -29,172 +29,172 @@ |
||
29 | 29 | class CoreAssetManager extends AssetManager |
30 | 30 | { |
31 | 31 | |
32 | - // WordPress core / Third party JS asset handles |
|
33 | - const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
34 | - |
|
35 | - const JS_HANDLE_CORE = 'espresso_core'; |
|
36 | - |
|
37 | - const JS_HANDLE_I18N = 'eei18n'; |
|
38 | - |
|
39 | - const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
40 | - |
|
41 | - const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | - |
|
43 | - const RAMDA_VERSION = '0.27.1'; |
|
44 | - |
|
45 | - // EE CSS assets handles |
|
46 | - const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
47 | - |
|
48 | - const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var EE_Currency_Config $currency_config |
|
52 | - */ |
|
53 | - protected $currency_config; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var EE_Template_Config $template_config |
|
57 | - */ |
|
58 | - protected $template_config; |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * CoreAssetRegister constructor. |
|
63 | - * |
|
64 | - * @param AssetCollection $assets |
|
65 | - * @param EE_Currency_Config $currency_config |
|
66 | - * @param EE_Template_Config $template_config |
|
67 | - * @param DomainInterface $domain |
|
68 | - * @param Registry $registry |
|
69 | - */ |
|
70 | - public function __construct( |
|
71 | - AssetCollection $assets, |
|
72 | - EE_Currency_Config $currency_config, |
|
73 | - EE_Template_Config $template_config, |
|
74 | - DomainInterface $domain, |
|
75 | - Registry $registry |
|
76 | - ) { |
|
77 | - $this->currency_config = $currency_config; |
|
78 | - $this->template_config = $template_config; |
|
79 | - parent::__construct($domain, $assets, $registry); |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @throws DomainException |
|
85 | - * @throws DuplicateCollectionIdentifierException |
|
86 | - * @throws InvalidArgumentException |
|
87 | - * @throws InvalidDataTypeException |
|
88 | - * @throws InvalidEntityException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @since 4.9.62.p |
|
91 | - */ |
|
92 | - public function addAssets() |
|
93 | - { |
|
94 | - $this->addJavascriptFiles(); |
|
95 | - $this->addStylesheetFiles(); |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @throws DomainException |
|
101 | - * @throws DuplicateCollectionIdentifierException |
|
102 | - * @throws InvalidArgumentException |
|
103 | - * @throws InvalidDataTypeException |
|
104 | - * @throws InvalidEntityException |
|
105 | - * @throws InvalidInterfaceException |
|
106 | - * @since 4.9.62.p |
|
107 | - */ |
|
108 | - public function addJavascriptFiles() |
|
109 | - { |
|
110 | - $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
111 | - $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
112 | - $this->addJavascript( |
|
113 | - CoreAssetManager::JS_HANDLE_CORE, |
|
114 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
115 | - [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
116 | - )->setInlineDataCallback( |
|
117 | - function () { |
|
118 | - wp_localize_script( |
|
119 | - CoreAssetManager::JS_HANDLE_CORE, |
|
120 | - CoreAssetManager::JS_HANDLE_I18N, |
|
121 | - EE_Registry::$i18n_js_strings |
|
122 | - ); |
|
123 | - } |
|
124 | - ); |
|
125 | - $this->loadQtipJs(); |
|
126 | - $this->addVendorJavascript( |
|
127 | - CoreAssetManager::JS_HANDLE_RAMDA, |
|
128 | - [], |
|
129 | - true, |
|
130 | - CoreAssetManager::RAMDA_VERSION |
|
131 | - ); |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @throws DuplicateCollectionIdentifierException |
|
137 | - * @throws InvalidDataTypeException |
|
138 | - * @throws InvalidEntityException |
|
139 | - * @throws DomainException |
|
140 | - * @since 4.9.62.p |
|
141 | - */ |
|
142 | - public function addStylesheetFiles() |
|
143 | - { |
|
144 | - if ($this->template_config->enable_default_style && ! is_admin()) { |
|
145 | - $this->addStylesheet( |
|
146 | - CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
147 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
148 | - ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
149 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
150 | - ['dashicons'] |
|
151 | - ); |
|
152 | - //Load custom style sheet if available |
|
153 | - if ($this->template_config->custom_style_sheet !== null) { |
|
154 | - $this->addStylesheet( |
|
155 | - CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
156 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
157 | - [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
158 | - ); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * Returns configuration data for the js Currency VO. |
|
166 | - * |
|
167 | - * @return array |
|
168 | - * @since 4.9.71.p |
|
169 | - */ |
|
170 | - private function getCurrencySettings() |
|
171 | - { |
|
172 | - return [ |
|
173 | - 'code' => $this->currency_config->code, |
|
174 | - 'singularLabel' => $this->currency_config->name, |
|
175 | - 'pluralLabel' => $this->currency_config->plural, |
|
176 | - 'sign' => $this->currency_config->sign, |
|
177 | - 'signB4' => $this->currency_config->sign_b4, |
|
178 | - 'decimalPlaces' => $this->currency_config->dec_plc, |
|
179 | - 'decimalMark' => $this->currency_config->dec_mrk, |
|
180 | - 'thousandsSeparator' => $this->currency_config->thsnds, |
|
181 | - ]; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * replacement: |
|
187 | - * EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
188 | - * |
|
189 | - * @param JavascriptAsset $script |
|
190 | - * @deprecated $VID:$ |
|
191 | - */ |
|
192 | - public function loadQtipJs(JavascriptAsset $script = null) |
|
193 | - { |
|
194 | - // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
195 | - // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
196 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
197 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
198 | - } |
|
199 | - } |
|
32 | + // WordPress core / Third party JS asset handles |
|
33 | + const JS_HANDLE_JS_CORE = 'eejs-core'; |
|
34 | + |
|
35 | + const JS_HANDLE_CORE = 'espresso_core'; |
|
36 | + |
|
37 | + const JS_HANDLE_I18N = 'eei18n'; |
|
38 | + |
|
39 | + const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
|
40 | + |
|
41 | + const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | + |
|
43 | + const RAMDA_VERSION = '0.27.1'; |
|
44 | + |
|
45 | + // EE CSS assets handles |
|
46 | + const CSS_HANDLE_DEFAULT = 'espresso_default'; |
|
47 | + |
|
48 | + const CSS_HANDLE_CUSTOM = 'espresso_custom_css'; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var EE_Currency_Config $currency_config |
|
52 | + */ |
|
53 | + protected $currency_config; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var EE_Template_Config $template_config |
|
57 | + */ |
|
58 | + protected $template_config; |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * CoreAssetRegister constructor. |
|
63 | + * |
|
64 | + * @param AssetCollection $assets |
|
65 | + * @param EE_Currency_Config $currency_config |
|
66 | + * @param EE_Template_Config $template_config |
|
67 | + * @param DomainInterface $domain |
|
68 | + * @param Registry $registry |
|
69 | + */ |
|
70 | + public function __construct( |
|
71 | + AssetCollection $assets, |
|
72 | + EE_Currency_Config $currency_config, |
|
73 | + EE_Template_Config $template_config, |
|
74 | + DomainInterface $domain, |
|
75 | + Registry $registry |
|
76 | + ) { |
|
77 | + $this->currency_config = $currency_config; |
|
78 | + $this->template_config = $template_config; |
|
79 | + parent::__construct($domain, $assets, $registry); |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @throws DomainException |
|
85 | + * @throws DuplicateCollectionIdentifierException |
|
86 | + * @throws InvalidArgumentException |
|
87 | + * @throws InvalidDataTypeException |
|
88 | + * @throws InvalidEntityException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @since 4.9.62.p |
|
91 | + */ |
|
92 | + public function addAssets() |
|
93 | + { |
|
94 | + $this->addJavascriptFiles(); |
|
95 | + $this->addStylesheetFiles(); |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @throws DomainException |
|
101 | + * @throws DuplicateCollectionIdentifierException |
|
102 | + * @throws InvalidArgumentException |
|
103 | + * @throws InvalidDataTypeException |
|
104 | + * @throws InvalidEntityException |
|
105 | + * @throws InvalidInterfaceException |
|
106 | + * @since 4.9.62.p |
|
107 | + */ |
|
108 | + public function addJavascriptFiles() |
|
109 | + { |
|
110 | + $this->addJs(CoreAssetManager::JS_HANDLE_VENDOR); |
|
111 | + $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
|
112 | + $this->addJavascript( |
|
113 | + CoreAssetManager::JS_HANDLE_CORE, |
|
114 | + EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
115 | + [JqueryAssetManager::JS_HANDLE_JQUERY] |
|
116 | + )->setInlineDataCallback( |
|
117 | + function () { |
|
118 | + wp_localize_script( |
|
119 | + CoreAssetManager::JS_HANDLE_CORE, |
|
120 | + CoreAssetManager::JS_HANDLE_I18N, |
|
121 | + EE_Registry::$i18n_js_strings |
|
122 | + ); |
|
123 | + } |
|
124 | + ); |
|
125 | + $this->loadQtipJs(); |
|
126 | + $this->addVendorJavascript( |
|
127 | + CoreAssetManager::JS_HANDLE_RAMDA, |
|
128 | + [], |
|
129 | + true, |
|
130 | + CoreAssetManager::RAMDA_VERSION |
|
131 | + ); |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @throws DuplicateCollectionIdentifierException |
|
137 | + * @throws InvalidDataTypeException |
|
138 | + * @throws InvalidEntityException |
|
139 | + * @throws DomainException |
|
140 | + * @since 4.9.62.p |
|
141 | + */ |
|
142 | + public function addStylesheetFiles() |
|
143 | + { |
|
144 | + if ($this->template_config->enable_default_style && ! is_admin()) { |
|
145 | + $this->addStylesheet( |
|
146 | + CoreAssetManager::CSS_HANDLE_DEFAULT, |
|
147 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
148 | + ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
|
149 | + : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
150 | + ['dashicons'] |
|
151 | + ); |
|
152 | + //Load custom style sheet if available |
|
153 | + if ($this->template_config->custom_style_sheet !== null) { |
|
154 | + $this->addStylesheet( |
|
155 | + CoreAssetManager::CSS_HANDLE_CUSTOM, |
|
156 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
157 | + [CoreAssetManager::CSS_HANDLE_DEFAULT] |
|
158 | + ); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * Returns configuration data for the js Currency VO. |
|
166 | + * |
|
167 | + * @return array |
|
168 | + * @since 4.9.71.p |
|
169 | + */ |
|
170 | + private function getCurrencySettings() |
|
171 | + { |
|
172 | + return [ |
|
173 | + 'code' => $this->currency_config->code, |
|
174 | + 'singularLabel' => $this->currency_config->name, |
|
175 | + 'pluralLabel' => $this->currency_config->plural, |
|
176 | + 'sign' => $this->currency_config->sign, |
|
177 | + 'signB4' => $this->currency_config->sign_b4, |
|
178 | + 'decimalPlaces' => $this->currency_config->dec_plc, |
|
179 | + 'decimalMark' => $this->currency_config->dec_mrk, |
|
180 | + 'thousandsSeparator' => $this->currency_config->thsnds, |
|
181 | + ]; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * replacement: |
|
187 | + * EventEspresso\core\domain\services\assets\EspressoLegacyAdminAssetManager::loadQtipJs() |
|
188 | + * |
|
189 | + * @param JavascriptAsset $script |
|
190 | + * @deprecated $VID:$ |
|
191 | + */ |
|
192 | + public function loadQtipJs(JavascriptAsset $script = null) |
|
193 | + { |
|
194 | + // qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, |
|
195 | + // can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
196 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
197 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
198 | + } |
|
199 | + } |
|
200 | 200 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | const JS_HANDLE_VENDOR = 'eventespresso-vendor'; |
40 | 40 | |
41 | - const JS_HANDLE_RAMDA = 'ramda'; |
|
41 | + const JS_HANDLE_RAMDA = 'ramda'; |
|
42 | 42 | |
43 | 43 | const RAMDA_VERSION = '0.27.1'; |
44 | 44 | |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | $this->addJs(CoreAssetManager::JS_HANDLE_JS_CORE)->setHasInlineData(); |
112 | 112 | $this->addJavascript( |
113 | 113 | CoreAssetManager::JS_HANDLE_CORE, |
114 | - EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', |
|
114 | + EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', |
|
115 | 115 | [JqueryAssetManager::JS_HANDLE_JQUERY] |
116 | 116 | )->setInlineDataCallback( |
117 | - function () { |
|
117 | + function() { |
|
118 | 118 | wp_localize_script( |
119 | 119 | CoreAssetManager::JS_HANDLE_CORE, |
120 | 120 | CoreAssetManager::JS_HANDLE_I18N, |
@@ -144,16 +144,16 @@ discard block |
||
144 | 144 | if ($this->template_config->enable_default_style && ! is_admin()) { |
145 | 145 | $this->addStylesheet( |
146 | 146 | CoreAssetManager::CSS_HANDLE_DEFAULT, |
147 | - is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css') |
|
147 | + is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css') |
|
148 | 148 | ? EVENT_ESPRESSO_UPLOAD_URL . 'css/espresso_default.css' |
149 | - : EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
149 | + : EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
150 | 150 | ['dashicons'] |
151 | 151 | ); |
152 | 152 | //Load custom style sheet if available |
153 | 153 | if ($this->template_config->custom_style_sheet !== null) { |
154 | 154 | $this->addStylesheet( |
155 | 155 | CoreAssetManager::CSS_HANDLE_CUSTOM, |
156 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->template_config->custom_style_sheet, |
|
156 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->template_config->custom_style_sheet, |
|
157 | 157 | [CoreAssetManager::CSS_HANDLE_DEFAULT] |
158 | 158 | ); |
159 | 159 | } |
@@ -15,68 +15,68 @@ |
||
15 | 15 | class TicketUpdate extends EntityMutator |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Defines the mutation data modification closure. |
|
20 | - * |
|
21 | - * @param EEM_Ticket $model |
|
22 | - * @param Ticket $type |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | - try { |
|
39 | - /** @var EE_Ticket $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
18 | + /** |
|
19 | + * Defines the mutation data modification closure. |
|
20 | + * |
|
21 | + * @param EEM_Ticket $model |
|
22 | + * @param Ticket $type |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | + try { |
|
39 | + /** @var EE_Ticket $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - $datetimes = []; |
|
43 | - $prices = null; |
|
42 | + $datetimes = []; |
|
43 | + $prices = null; |
|
44 | 44 | |
45 | - $args = TicketMutation::prepareFields($input); |
|
45 | + $args = TicketMutation::prepareFields($input); |
|
46 | 46 | |
47 | - if (isset($args['datetimes'])) { |
|
48 | - $datetimes = $args['datetimes']; |
|
49 | - unset($args['datetimes']); |
|
50 | - } |
|
51 | - if (array_key_exists('prices', $args)) { |
|
52 | - $prices = $args['prices']; |
|
53 | - unset($args['prices']); |
|
54 | - } |
|
47 | + if (isset($args['datetimes'])) { |
|
48 | + $datetimes = $args['datetimes']; |
|
49 | + unset($args['datetimes']); |
|
50 | + } |
|
51 | + if (array_key_exists('prices', $args)) { |
|
52 | + $prices = $args['prices']; |
|
53 | + unset($args['prices']); |
|
54 | + } |
|
55 | 55 | |
56 | - $entity->save($args); |
|
56 | + $entity->save($args); |
|
57 | 57 | |
58 | - if (! empty($datetimes)) { |
|
59 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
60 | - } |
|
61 | - // if prices array is passed. |
|
62 | - if (is_array($prices)) { |
|
63 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
64 | - } |
|
58 | + if (! empty($datetimes)) { |
|
59 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
60 | + } |
|
61 | + // if prices array is passed. |
|
62 | + if (is_array($prices)) { |
|
63 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
64 | + } |
|
65 | 65 | |
66 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input); |
|
67 | - } catch (Exception $exception) { |
|
68 | - EntityMutator::handleExceptions( |
|
69 | - $exception, |
|
70 | - esc_html__( |
|
71 | - 'The ticket could not be deleted because of the following error(s)', |
|
72 | - 'event_espresso' |
|
73 | - ) |
|
74 | - ); |
|
75 | - } |
|
66 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_update', $entity, $input); |
|
67 | + } catch (Exception $exception) { |
|
68 | + EntityMutator::handleExceptions( |
|
69 | + $exception, |
|
70 | + esc_html__( |
|
71 | + 'The ticket could not be deleted because of the following error(s)', |
|
72 | + 'event_espresso' |
|
73 | + ) |
|
74 | + ); |
|
75 | + } |
|
76 | 76 | |
77 | - return [ |
|
78 | - 'id' => $entity->ID(), |
|
79 | - ]; |
|
80 | - }; |
|
81 | - } |
|
77 | + return [ |
|
78 | + 'id' => $entity->ID(), |
|
79 | + ]; |
|
80 | + }; |
|
81 | + } |
|
82 | 82 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws EE_Error |
35 | 35 | * @throws ReflectionException |
36 | 36 | */ |
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | 38 | try { |
39 | 39 | /** @var EE_Ticket $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $entity->save($args); |
57 | 57 | |
58 | - if (! empty($datetimes)) { |
|
58 | + if ( ! empty($datetimes)) { |
|
59 | 59 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
60 | 60 | } |
61 | 61 | // if prices array is passed. |
@@ -8,17 +8,17 @@ |
||
8 | 8 | class DatetimeBulkUpdate extends EntityMutator |
9 | 9 | { |
10 | 10 | |
11 | - /** |
|
12 | - * Defines the mutation data modification closure. |
|
13 | - * |
|
14 | - * @param EEM_Datetime $model |
|
15 | - * @param Datetime $type |
|
16 | - * @return callable |
|
17 | - */ |
|
18 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable |
|
19 | - { |
|
20 | - $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
21 | - $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | - return array($bulkMutator, 'updateEntities'); |
|
23 | - } |
|
11 | + /** |
|
12 | + * Defines the mutation data modification closure. |
|
13 | + * |
|
14 | + * @param EEM_Datetime $model |
|
15 | + * @param Datetime $type |
|
16 | + * @return callable |
|
17 | + */ |
|
18 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type): callable |
|
19 | + { |
|
20 | + $entityMutator = DatetimeUpdate::mutateAndGetPayload($model, $type); |
|
21 | + $bulkMutator = new BulkEntityMutator($entityMutator); |
|
22 | + return array($bulkMutator, 'updateEntities'); |
|
23 | + } |
|
24 | 24 | } |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
35 | 35 | * @return void |
36 | 36 | */ |
37 | - return static function ( |
|
37 | + return static function( |
|
38 | 38 | int $id, |
39 | 39 | array $input, |
40 | 40 | WP_Post_Type $post_type_object, |
@@ -14,73 +14,73 @@ |
||
14 | 14 | class EventUpdate extends EntityMutator |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Defines the mutation data modification closure. |
|
19 | - * |
|
20 | - * @param EEM_Event $model |
|
21 | - * @param Event $type |
|
22 | - * @return callable |
|
23 | - */ |
|
24 | - public static function mutateFields(EEM_Event $model, Event $type) |
|
25 | - { |
|
26 | - /** |
|
27 | - * Update additional data related to the entity. |
|
28 | - * |
|
29 | - * @param int $id The ID of the postObject being mutated |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | - * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - return static function ( |
|
38 | - int $id, |
|
39 | - array $input, |
|
40 | - WP_Post_Type $post_type_object, |
|
41 | - string $mutation_name, |
|
42 | - AppContext $context, |
|
43 | - ResolveInfo $info |
|
44 | - ) use ( |
|
45 | - $model, |
|
46 | - $type |
|
47 | - ) { |
|
48 | - try { |
|
49 | - // Make sure we are dealing with the right entity. |
|
50 | - if ( |
|
51 | - ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | - || $post_type_object->graphql_single_name !== $type->name() |
|
53 | - ) { |
|
54 | - return; |
|
55 | - } |
|
17 | + /** |
|
18 | + * Defines the mutation data modification closure. |
|
19 | + * |
|
20 | + * @param EEM_Event $model |
|
21 | + * @param Event $type |
|
22 | + * @return callable |
|
23 | + */ |
|
24 | + public static function mutateFields(EEM_Event $model, Event $type) |
|
25 | + { |
|
26 | + /** |
|
27 | + * Update additional data related to the entity. |
|
28 | + * |
|
29 | + * @param int $id The ID of the postObject being mutated |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param WP_Post_Type $post_type_object The Post Type Object for the type of post being mutated |
|
32 | + * @param string $mutation_name The name of the mutation (ex: create, update, delete) |
|
33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + return static function ( |
|
38 | + int $id, |
|
39 | + array $input, |
|
40 | + WP_Post_Type $post_type_object, |
|
41 | + string $mutation_name, |
|
42 | + AppContext $context, |
|
43 | + ResolveInfo $info |
|
44 | + ) use ( |
|
45 | + $model, |
|
46 | + $type |
|
47 | + ) { |
|
48 | + try { |
|
49 | + // Make sure we are dealing with the right entity. |
|
50 | + if ( |
|
51 | + ! property_exists($post_type_object, 'graphql_single_name') |
|
52 | + || $post_type_object->graphql_single_name !== $type->name() |
|
53 | + ) { |
|
54 | + return; |
|
55 | + } |
|
56 | 56 | |
57 | - /** @var EE_Event $entity */ |
|
58 | - $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | - $args = EventMutation::prepareFields($input); |
|
57 | + /** @var EE_Event $entity */ |
|
58 | + $entity = EntityMutator::getEntityFromID($model, $id); |
|
59 | + $args = EventMutation::prepareFields($input); |
|
60 | 60 | |
61 | - $venue = 'NO_VENUE_SET'; |
|
62 | - if (array_key_exists('venue', $args)) { |
|
63 | - $venue = $args['venue']; |
|
64 | - unset($args['venue']); |
|
65 | - } |
|
61 | + $venue = 'NO_VENUE_SET'; |
|
62 | + if (array_key_exists('venue', $args)) { |
|
63 | + $venue = $args['venue']; |
|
64 | + unset($args['venue']); |
|
65 | + } |
|
66 | 66 | |
67 | - // Update the entity |
|
68 | - $entity->save($args); |
|
67 | + // Update the entity |
|
68 | + $entity->save($args); |
|
69 | 69 | |
70 | - if ($venue !== 'NO_VENUE_SET') { |
|
71 | - EventMutation::setEventVenue($entity, $venue); |
|
72 | - } |
|
70 | + if ($venue !== 'NO_VENUE_SET') { |
|
71 | + EventMutation::setEventVenue($entity, $venue); |
|
72 | + } |
|
73 | 73 | |
74 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | - } catch (Exception $exception) { |
|
76 | - EntityMutator::handleExceptions( |
|
77 | - $exception, |
|
78 | - esc_html__( |
|
79 | - 'The event could not be updated because of the following error(s)', |
|
80 | - 'event_espresso' |
|
81 | - ) |
|
82 | - ); |
|
83 | - } |
|
84 | - }; |
|
85 | - } |
|
74 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
75 | + } catch (Exception $exception) { |
|
76 | + EntityMutator::handleExceptions( |
|
77 | + $exception, |
|
78 | + esc_html__( |
|
79 | + 'The event could not be updated because of the following error(s)', |
|
80 | + 'event_espresso' |
|
81 | + ) |
|
82 | + ); |
|
83 | + } |
|
84 | + }; |
|
85 | + } |
|
86 | 86 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @throws EE_Error |
35 | 35 | * @throws ReflectionException |
36 | 36 | */ |
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | 38 | try { |
39 | 39 | /** @var EE_Datetime $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // Update the entity |
51 | 51 | $entity->save($args); |
52 | 52 | |
53 | - if (! empty($tickets)) { |
|
53 | + if ( ! empty($tickets)) { |
|
54 | 54 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
55 | 55 | } |
56 | 56 |
@@ -15,69 +15,69 @@ |
||
15 | 15 | class DatetimeUpdate extends EntityMutator |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * Defines the mutation data modification closure. |
|
20 | - * |
|
21 | - * @param EEM_Datetime $model |
|
22 | - * @param Datetime $type |
|
23 | - * @return callable |
|
24 | - */ |
|
25 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | - { |
|
27 | - /** |
|
28 | - * Updates an entity. |
|
29 | - * |
|
30 | - * @param array $input The input for the mutation |
|
31 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | - * @return array |
|
34 | - * @throws EE_Error |
|
35 | - * @throws ReflectionException |
|
36 | - */ |
|
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | - try { |
|
39 | - /** @var EE_Datetime $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
18 | + /** |
|
19 | + * Defines the mutation data modification closure. |
|
20 | + * |
|
21 | + * @param EEM_Datetime $model |
|
22 | + * @param Datetime $type |
|
23 | + * @return callable |
|
24 | + */ |
|
25 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
26 | + { |
|
27 | + /** |
|
28 | + * Updates an entity. |
|
29 | + * |
|
30 | + * @param array $input The input for the mutation |
|
31 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
32 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
33 | + * @return array |
|
34 | + * @throws EE_Error |
|
35 | + * @throws ReflectionException |
|
36 | + */ |
|
37 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | + try { |
|
39 | + /** @var EE_Datetime $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - $tickets = []; |
|
43 | - $args = DatetimeMutation::prepareFields($input); |
|
42 | + $tickets = []; |
|
43 | + $args = DatetimeMutation::prepareFields($input); |
|
44 | 44 | |
45 | - if (isset($args['tickets'])) { |
|
46 | - $tickets = $args['tickets']; |
|
47 | - unset($args['tickets']); |
|
48 | - } |
|
45 | + if (isset($args['tickets'])) { |
|
46 | + $tickets = $args['tickets']; |
|
47 | + unset($args['tickets']); |
|
48 | + } |
|
49 | 49 | |
50 | - $venue = 'NO_VENUE_SET'; |
|
51 | - if (array_key_exists('venue', $args)) { |
|
52 | - $venue = $args['venue']; |
|
53 | - unset($args['venue']); |
|
54 | - } |
|
50 | + $venue = 'NO_VENUE_SET'; |
|
51 | + if (array_key_exists('venue', $args)) { |
|
52 | + $venue = $args['venue']; |
|
53 | + unset($args['venue']); |
|
54 | + } |
|
55 | 55 | |
56 | - // Update the entity |
|
57 | - $entity->save($args); |
|
56 | + // Update the entity |
|
57 | + $entity->save($args); |
|
58 | 58 | |
59 | - if (! empty($tickets)) { |
|
60 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | - } |
|
59 | + if (! empty($tickets)) { |
|
60 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
61 | + } |
|
62 | 62 | |
63 | - if ($venue !== 'NO_VENUE_SET') { |
|
64 | - DatetimeMutation::setVenue($entity, $venue); |
|
65 | - } |
|
63 | + if ($venue !== 'NO_VENUE_SET') { |
|
64 | + DatetimeMutation::setVenue($entity, $venue); |
|
65 | + } |
|
66 | 66 | |
67 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | - } catch (Exception $exception) { |
|
69 | - EntityMutator::handleExceptions( |
|
70 | - $exception, |
|
71 | - esc_html__( |
|
72 | - 'The datetime could not be updated because of the following error(s)', |
|
73 | - 'event_espresso' |
|
74 | - ) |
|
75 | - ); |
|
76 | - } |
|
67 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
68 | + } catch (Exception $exception) { |
|
69 | + EntityMutator::handleExceptions( |
|
70 | + $exception, |
|
71 | + esc_html__( |
|
72 | + 'The datetime could not be updated because of the following error(s)', |
|
73 | + 'event_espresso' |
|
74 | + ) |
|
75 | + ); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $entity->ID(), |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $entity->ID(), |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -13,68 +13,68 @@ |
||
13 | 13 | class TicketCreate extends EntityMutator |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Defines the mutation data modification closure. |
|
18 | - * |
|
19 | - * @param EEM_Ticket $model |
|
20 | - * @param Ticket $type |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Creates an entity. |
|
27 | - * |
|
28 | - * @param array $input The input for the mutation |
|
29 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | - $id = null; |
|
35 | - try { |
|
36 | - EntityMutator::checkPermissions($model); |
|
16 | + /** |
|
17 | + * Defines the mutation data modification closure. |
|
18 | + * |
|
19 | + * @param EEM_Ticket $model |
|
20 | + * @param Ticket $type |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Creates an entity. |
|
27 | + * |
|
28 | + * @param array $input The input for the mutation |
|
29 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | + $id = null; |
|
35 | + try { |
|
36 | + EntityMutator::checkPermissions($model); |
|
37 | 37 | |
38 | - $datetimes = []; |
|
39 | - $prices = []; |
|
38 | + $datetimes = []; |
|
39 | + $prices = []; |
|
40 | 40 | |
41 | - $args = TicketMutation::prepareFields($input); |
|
41 | + $args = TicketMutation::prepareFields($input); |
|
42 | 42 | |
43 | - if (isset($args['datetimes'])) { |
|
44 | - $datetimes = $args['datetimes']; |
|
45 | - unset($args['datetimes']); |
|
46 | - } |
|
47 | - if (isset($args['prices'])) { |
|
48 | - $prices = $args['prices']; |
|
49 | - unset($args['prices']); |
|
50 | - } |
|
43 | + if (isset($args['datetimes'])) { |
|
44 | + $datetimes = $args['datetimes']; |
|
45 | + unset($args['datetimes']); |
|
46 | + } |
|
47 | + if (isset($args['prices'])) { |
|
48 | + $prices = $args['prices']; |
|
49 | + unset($args['prices']); |
|
50 | + } |
|
51 | 51 | |
52 | - $entity = EE_Ticket::new_instance($args); |
|
53 | - $id = $entity->save(); |
|
54 | - EntityMutator::validateResults($id); |
|
52 | + $entity = EE_Ticket::new_instance($args); |
|
53 | + $id = $entity->save(); |
|
54 | + EntityMutator::validateResults($id); |
|
55 | 55 | |
56 | - if (! empty($datetimes)) { |
|
57 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
58 | - } |
|
59 | - // if prices are passed. |
|
60 | - if (! empty($prices)) { |
|
61 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
62 | - } |
|
56 | + if (! empty($datetimes)) { |
|
57 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
58 | + } |
|
59 | + // if prices are passed. |
|
60 | + if (! empty($prices)) { |
|
61 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
62 | + } |
|
63 | 63 | |
64 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input); |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'The ticket could not be created because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
64 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_ticket_create', $entity, $input); |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'The ticket could not be created because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | - return [ |
|
76 | - 'id' => $id, |
|
77 | - ]; |
|
78 | - }; |
|
79 | - } |
|
75 | + return [ |
|
76 | + 'id' => $id, |
|
77 | + ]; |
|
78 | + }; |
|
79 | + } |
|
80 | 80 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
33 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
34 | 34 | $id = null; |
35 | 35 | try { |
36 | 36 | EntityMutator::checkPermissions($model); |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $id = $entity->save(); |
54 | 54 | EntityMutator::validateResults($id); |
55 | 55 | |
56 | - if (! empty($datetimes)) { |
|
56 | + if ( ! empty($datetimes)) { |
|
57 | 57 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
58 | 58 | } |
59 | 59 | // if prices are passed. |
60 | - if (! empty($prices)) { |
|
60 | + if ( ! empty($prices)) { |
|
61 | 61 | TicketMutation::setRelatedPrices($entity, $prices); |
62 | 62 | } |
63 | 63 |
@@ -17,107 +17,107 @@ |
||
17 | 17 | class DatetimeDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Datetime $model |
|
24 | - * @param Datetime $type |
|
25 | - * @return callable |
|
26 | - */ |
|
27 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
28 | - { |
|
29 | - /** |
|
30 | - * Deletes an entity. |
|
31 | - * |
|
32 | - * @param array $input The input for the mutation |
|
33 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | - try { |
|
39 | - /** @var EE_Datetime $entity */ |
|
40 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Datetime $model |
|
24 | + * @param Datetime $type |
|
25 | + * @return callable |
|
26 | + */ |
|
27 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
28 | + { |
|
29 | + /** |
|
30 | + * Deletes an entity. |
|
31 | + * |
|
32 | + * @param array $input The input for the mutation |
|
33 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
34 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | + try { |
|
39 | + /** @var EE_Datetime $entity */ |
|
40 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
41 | 41 | |
42 | - // Delete the entity |
|
43 | - if (! empty($input['deletePermanently'])) { |
|
44 | - $result = DatetimeDelete::deleteDatetimeAndRelations($entity); |
|
45 | - } else { |
|
46 | - $result = DatetimeDelete::trashDatetimeAndRelations($entity); |
|
47 | - } |
|
48 | - EntityMutator::validateResults($result); |
|
42 | + // Delete the entity |
|
43 | + if (! empty($input['deletePermanently'])) { |
|
44 | + $result = DatetimeDelete::deleteDatetimeAndRelations($entity); |
|
45 | + } else { |
|
46 | + $result = DatetimeDelete::trashDatetimeAndRelations($entity); |
|
47 | + } |
|
48 | + EntityMutator::validateResults($result); |
|
49 | 49 | |
50 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input); |
|
51 | - } catch (Exception $exception) { |
|
52 | - EntityMutator::handleExceptions( |
|
53 | - $exception, |
|
54 | - esc_html__( |
|
55 | - 'The datetime could not be deleted because of the following error(s)', |
|
56 | - 'event_espresso' |
|
57 | - ) |
|
58 | - ); |
|
59 | - } |
|
50 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_delete', $entity, $input); |
|
51 | + } catch (Exception $exception) { |
|
52 | + EntityMutator::handleExceptions( |
|
53 | + $exception, |
|
54 | + esc_html__( |
|
55 | + 'The datetime could not be deleted because of the following error(s)', |
|
56 | + 'event_espresso' |
|
57 | + ) |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - return [ |
|
62 | - 'deleted' => $entity, |
|
63 | - ]; |
|
64 | - }; |
|
65 | - } |
|
61 | + return [ |
|
62 | + 'deleted' => $entity, |
|
63 | + ]; |
|
64 | + }; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Deletes a datetime permanently along with its relations. |
|
69 | - * |
|
70 | - * @param EE_Datetime $entity |
|
71 | - * @return bool | int |
|
72 | - * @throws ReflectionException |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws EE_Error |
|
77 | - */ |
|
78 | - public static function deleteDatetimeAndRelations(EE_Datetime $entity) |
|
79 | - { |
|
80 | - // all related tickets |
|
81 | - $tickets = $entity->tickets(); |
|
82 | - foreach ($tickets as $ticket) { |
|
83 | - // if the ticket is related to only one datetime |
|
84 | - if ($ticket->count_related('Datetime') === 1) { |
|
85 | - TicketDelete::deleteTicketAndRelations($ticket); |
|
86 | - } |
|
87 | - } |
|
67 | + /** |
|
68 | + * Deletes a datetime permanently along with its relations. |
|
69 | + * |
|
70 | + * @param EE_Datetime $entity |
|
71 | + * @return bool | int |
|
72 | + * @throws ReflectionException |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws EE_Error |
|
77 | + */ |
|
78 | + public static function deleteDatetimeAndRelations(EE_Datetime $entity) |
|
79 | + { |
|
80 | + // all related tickets |
|
81 | + $tickets = $entity->tickets(); |
|
82 | + foreach ($tickets as $ticket) { |
|
83 | + // if the ticket is related to only one datetime |
|
84 | + if ($ticket->count_related('Datetime') === 1) { |
|
85 | + TicketDelete::deleteTicketAndRelations($ticket); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - // Remove relations with tickets |
|
90 | - $entity->_remove_relations('Ticket'); |
|
91 | - // Now delete the datetime permanently |
|
92 | - return $entity->delete_permanently(); |
|
93 | - } |
|
89 | + // Remove relations with tickets |
|
90 | + $entity->_remove_relations('Ticket'); |
|
91 | + // Now delete the datetime permanently |
|
92 | + return $entity->delete_permanently(); |
|
93 | + } |
|
94 | 94 | |
95 | - /** |
|
96 | - * Trashes a datetime along with its lone relations. |
|
97 | - * |
|
98 | - * @param EE_Datetime $entity |
|
99 | - * @return bool | int |
|
100 | - * @throws ReflectionException |
|
101 | - * @throws InvalidArgumentException |
|
102 | - * @throws InvalidInterfaceException |
|
103 | - * @throws InvalidDataTypeException |
|
104 | - * @throws EE_Error |
|
105 | - */ |
|
106 | - public static function trashDatetimeAndRelations(EE_Datetime $entity) |
|
107 | - { |
|
108 | - // non trashed related tickets |
|
109 | - $tickets = $entity->tickets([[ |
|
110 | - 'TKT_deleted' => false, |
|
111 | - ]]); |
|
112 | - // loop though all tickets to check if we need to trash any |
|
113 | - foreach ($tickets as $ticket) { |
|
114 | - // if the ticket is related to only one datetime |
|
115 | - if ($ticket->count_related('Datetime') === 1) { |
|
116 | - // trash the ticket |
|
117 | - $ticket->delete(); |
|
118 | - } |
|
119 | - } |
|
120 | - // trash the datetime |
|
121 | - return $entity->delete(); |
|
122 | - } |
|
95 | + /** |
|
96 | + * Trashes a datetime along with its lone relations. |
|
97 | + * |
|
98 | + * @param EE_Datetime $entity |
|
99 | + * @return bool | int |
|
100 | + * @throws ReflectionException |
|
101 | + * @throws InvalidArgumentException |
|
102 | + * @throws InvalidInterfaceException |
|
103 | + * @throws InvalidDataTypeException |
|
104 | + * @throws EE_Error |
|
105 | + */ |
|
106 | + public static function trashDatetimeAndRelations(EE_Datetime $entity) |
|
107 | + { |
|
108 | + // non trashed related tickets |
|
109 | + $tickets = $entity->tickets([[ |
|
110 | + 'TKT_deleted' => false, |
|
111 | + ]]); |
|
112 | + // loop though all tickets to check if we need to trash any |
|
113 | + foreach ($tickets as $ticket) { |
|
114 | + // if the ticket is related to only one datetime |
|
115 | + if ($ticket->count_related('Datetime') === 1) { |
|
116 | + // trash the ticket |
|
117 | + $ticket->delete(); |
|
118 | + } |
|
119 | + } |
|
120 | + // trash the datetime |
|
121 | + return $entity->delete(); |
|
122 | + } |
|
123 | 123 | } |
@@ -34,13 +34,13 @@ |
||
34 | 34 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
35 | 35 | * @return array |
36 | 36 | */ |
37 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
37 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model, $type): array { |
|
38 | 38 | try { |
39 | 39 | /** @var EE_Datetime $entity */ |
40 | 40 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
41 | 41 | |
42 | 42 | // Delete the entity |
43 | - if (! empty($input['deletePermanently'])) { |
|
43 | + if ( ! empty($input['deletePermanently'])) { |
|
44 | 44 | $result = DatetimeDelete::deleteDatetimeAndRelations($entity); |
45 | 45 | } else { |
46 | 46 | $result = DatetimeDelete::trashDatetimeAndRelations($entity); |