@@ -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 |
@@ -19,355 +19,355 @@ |
||
19 | 19 | class RegistrantData |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var int |
|
24 | - */ |
|
25 | - private $attendee_counter = 0; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - private $registrant_data = []; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var bool |
|
34 | - */ |
|
35 | - private $copy_primary = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var array |
|
39 | - */ |
|
40 | - private $required_questions = []; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Registration[] |
|
44 | - */ |
|
45 | - private $registrations = []; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Answer[][] |
|
49 | - */ |
|
50 | - private $registrant_answers = []; |
|
51 | - |
|
52 | - /** |
|
53 | - * array for tracking reg form data for the primary registrant |
|
54 | - * |
|
55 | - * @var array |
|
56 | - */ |
|
57 | - private $primary_registrant_data; |
|
58 | - |
|
59 | - /** |
|
60 | - * the attendee object created for the primary registrant |
|
61 | - * |
|
62 | - * @var EE_Attendee |
|
63 | - */ |
|
64 | - private $primary_registrant; |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * RegistrantData constructor. |
|
69 | - */ |
|
70 | - public function __construct() |
|
71 | - { |
|
72 | - $this->primary_registrant_data = ['line_item_id' => null,]; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param EE_Registration $registration |
|
78 | - * @throws EE_Error |
|
79 | - */ |
|
80 | - public function initializeRegistrantData(EE_Registration $registration): void |
|
81 | - { |
|
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 ] = []; |
|
86 | - $this->attendee_counter++; |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @return int |
|
92 | - */ |
|
93 | - public function attendeeCount(): int |
|
94 | - { |
|
95 | - return $this->attendee_counter; |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - public function copyPrimary(): bool |
|
103 | - { |
|
104 | - return $this->copy_primary; |
|
105 | - } |
|
106 | - |
|
107 | - |
|
108 | - /** |
|
109 | - * @param bool $copy_primary |
|
110 | - */ |
|
111 | - public function setCopyPrimary(bool $copy_primary): void |
|
112 | - { |
|
113 | - $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @param string $reg_url_link |
|
119 | - * @return array|null |
|
120 | - */ |
|
121 | - public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
122 | - { |
|
123 | - return $this->registrations[ $reg_url_link ] ?? null; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * @param string $reg_url_link |
|
129 | - * @return array|null |
|
130 | - */ |
|
131 | - public function getRegistrantData(string $reg_url_link): ?array |
|
132 | - { |
|
133 | - return $this->registrant_data[ $reg_url_link ] ?? null; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param string $reg_url_link |
|
139 | - * @param string $key |
|
140 | - * @param mixed $value |
|
141 | - */ |
|
142 | - public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
143 | - { |
|
144 | - $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
145 | - } |
|
146 | - |
|
147 | - |
|
148 | - /** |
|
149 | - * ensures that all attendees at least have data for first name, last name, and email address |
|
150 | - * |
|
151 | - * @param string $reg_url_link |
|
152 | - * @throws EE_Error |
|
153 | - * @throws ReflectionException |
|
154 | - */ |
|
155 | - public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
156 | - { |
|
157 | - if ($this->currentRegistrantIsPrimary()) { |
|
158 | - return; |
|
159 | - } |
|
160 | - // bare minimum critical details include first name, last name, email address |
|
161 | - $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
162 | - // add address info to critical details? |
|
163 | - if ( |
|
164 | - apply_filters( |
|
165 | - 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
166 | - false |
|
167 | - ) |
|
168 | - ) { |
|
169 | - $critical_attendee_details += [ |
|
170 | - 'ATT_address', |
|
171 | - 'ATT_address2', |
|
172 | - 'ATT_city', |
|
173 | - 'STA_ID', |
|
174 | - 'CNT_ISO', |
|
175 | - 'ATT_zip', |
|
176 | - 'ATT_phone', |
|
177 | - ]; |
|
178 | - } |
|
179 | - foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
180 | - if ( |
|
181 | - ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | - || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
183 | - ) { |
|
184 | - $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
185 | - $critical_attendee_detail |
|
186 | - ); |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - |
|
192 | - /** |
|
193 | - * @param string $reg_url_link |
|
194 | - * @param array $registrant_data |
|
195 | - */ |
|
196 | - public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
197 | - { |
|
198 | - $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function getRequiredQuestions(): array |
|
206 | - { |
|
207 | - return $this->required_questions; |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * @param string $identifier |
|
213 | - * @param string $required_question |
|
214 | - */ |
|
215 | - public function addRequiredQuestion(string $identifier, string $required_question): void |
|
216 | - { |
|
217 | - $this->required_questions[ $identifier ] = $required_question; |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @return EE_Answer[] |
|
223 | - */ |
|
224 | - public function registrantAnswers(string $reg_url_link): array |
|
225 | - { |
|
226 | - return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * @param string $reg_url_link |
|
232 | - * @param string $identifier the answer cache ID |
|
233 | - * @param EE_Answer $answer |
|
234 | - */ |
|
235 | - public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
236 | - { |
|
237 | - $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
238 | - } |
|
239 | - |
|
240 | - |
|
241 | - /** |
|
242 | - * @param string $reg_url_link |
|
243 | - * @param string $identifier |
|
244 | - * @return EE_Answer|null |
|
245 | - */ |
|
246 | - public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
247 | - { |
|
248 | - return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
249 | - } |
|
250 | - |
|
251 | - |
|
252 | - |
|
253 | - /** |
|
254 | - * @param string $reg_url_link |
|
255 | - * @param string $identifier |
|
256 | - * @return bool |
|
257 | - */ |
|
258 | - public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
259 | - { |
|
260 | - $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
261 | - return $registrant_answer instanceof EE_Answer; |
|
262 | - } |
|
263 | - |
|
264 | - |
|
265 | - /** |
|
266 | - * @return array |
|
267 | - */ |
|
268 | - public function primaryRegistrantData(): array |
|
269 | - { |
|
270 | - return $this->primary_registrant_data; |
|
271 | - } |
|
272 | - |
|
273 | - |
|
274 | - /** |
|
275 | - * @param string $key |
|
276 | - * @param mixed $value |
|
277 | - */ |
|
278 | - public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
279 | - { |
|
280 | - $this->primary_registrant_data[ $key ] = $value; |
|
281 | - } |
|
282 | - |
|
283 | - |
|
284 | - /** |
|
285 | - * @param string $key |
|
286 | - * @return mixed |
|
287 | - */ |
|
288 | - public function getPrimaryRegistrantDataValue(string $key) |
|
289 | - { |
|
290 | - return $this->primary_registrant_data[ $key ] ?? null; |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @param array $primary_registrant_data |
|
296 | - */ |
|
297 | - public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
298 | - { |
|
299 | - $this->primary_registrant_data = $primary_registrant_data; |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * @return EE_Attendee |
|
305 | - */ |
|
306 | - public function primaryRegistrant(): EE_Attendee |
|
307 | - { |
|
308 | - return $this->primary_registrant; |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * @return bool |
|
314 | - */ |
|
315 | - public function primaryRegistrantIsValid(): bool |
|
316 | - { |
|
317 | - return $this->primary_registrant instanceof EE_Attendee; |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - /** |
|
322 | - * @param EE_Attendee $primary_registrant |
|
323 | - */ |
|
324 | - public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
325 | - { |
|
326 | - $this->primary_registrant = $primary_registrant; |
|
327 | - } |
|
328 | - |
|
329 | - |
|
330 | - /** |
|
331 | - * @param string $reg_url_link |
|
332 | - * @return bool |
|
333 | - */ |
|
334 | - public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
335 | - { |
|
336 | - return $this->attendeeCount() === 1 |
|
337 | - || ( |
|
338 | - $this->attendeeCount() === 1 |
|
339 | - && $reg_url_link !== '' |
|
340 | - && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
341 | - ); |
|
342 | - } |
|
343 | - |
|
344 | - |
|
345 | - /** |
|
346 | - * @return bool |
|
347 | - */ |
|
348 | - public function currentRegistrantIsNotPrimary(): bool |
|
349 | - { |
|
350 | - return $this->attendeeCount() > 1; |
|
351 | - } |
|
352 | - |
|
353 | - |
|
354 | - /** |
|
355 | - * @param string $reg_url_link |
|
356 | - * @param string $form_input |
|
357 | - * @param mixed $input_value |
|
358 | - * @return mixed|null |
|
359 | - */ |
|
360 | - public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
361 | - { |
|
362 | - // store a bit of data about the primary attendee |
|
363 | - if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
364 | - $this->primary_registrant_data[ $form_input ] = $input_value; |
|
365 | - return $input_value; |
|
366 | - } |
|
367 | - // or copy value from primary if incoming value is not set |
|
368 | - if ($input_value === null && $this->copyPrimary()) { |
|
369 | - $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
370 | - } |
|
371 | - return $input_value; |
|
372 | - } |
|
22 | + /** |
|
23 | + * @var int |
|
24 | + */ |
|
25 | + private $attendee_counter = 0; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + private $registrant_data = []; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var bool |
|
34 | + */ |
|
35 | + private $copy_primary = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var array |
|
39 | + */ |
|
40 | + private $required_questions = []; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Registration[] |
|
44 | + */ |
|
45 | + private $registrations = []; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Answer[][] |
|
49 | + */ |
|
50 | + private $registrant_answers = []; |
|
51 | + |
|
52 | + /** |
|
53 | + * array for tracking reg form data for the primary registrant |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + private $primary_registrant_data; |
|
58 | + |
|
59 | + /** |
|
60 | + * the attendee object created for the primary registrant |
|
61 | + * |
|
62 | + * @var EE_Attendee |
|
63 | + */ |
|
64 | + private $primary_registrant; |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * RegistrantData constructor. |
|
69 | + */ |
|
70 | + public function __construct() |
|
71 | + { |
|
72 | + $this->primary_registrant_data = ['line_item_id' => null,]; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param EE_Registration $registration |
|
78 | + * @throws EE_Error |
|
79 | + */ |
|
80 | + public function initializeRegistrantData(EE_Registration $registration): void |
|
81 | + { |
|
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 ] = []; |
|
86 | + $this->attendee_counter++; |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @return int |
|
92 | + */ |
|
93 | + public function attendeeCount(): int |
|
94 | + { |
|
95 | + return $this->attendee_counter; |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function copyPrimary(): bool |
|
103 | + { |
|
104 | + return $this->copy_primary; |
|
105 | + } |
|
106 | + |
|
107 | + |
|
108 | + /** |
|
109 | + * @param bool $copy_primary |
|
110 | + */ |
|
111 | + public function setCopyPrimary(bool $copy_primary): void |
|
112 | + { |
|
113 | + $this->copy_primary = filter_var($copy_primary, FILTER_VALIDATE_BOOLEAN); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @param string $reg_url_link |
|
119 | + * @return array|null |
|
120 | + */ |
|
121 | + public function getRegistrant(string $reg_url_link): ?EE_Registration |
|
122 | + { |
|
123 | + return $this->registrations[ $reg_url_link ] ?? null; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * @param string $reg_url_link |
|
129 | + * @return array|null |
|
130 | + */ |
|
131 | + public function getRegistrantData(string $reg_url_link): ?array |
|
132 | + { |
|
133 | + return $this->registrant_data[ $reg_url_link ] ?? null; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param string $reg_url_link |
|
139 | + * @param string $key |
|
140 | + * @param mixed $value |
|
141 | + */ |
|
142 | + public function addRegistrantDataValue(string $reg_url_link, string $key, $value): void |
|
143 | + { |
|
144 | + $this->registrant_data[ $reg_url_link ][ $key ] = $value; |
|
145 | + } |
|
146 | + |
|
147 | + |
|
148 | + /** |
|
149 | + * ensures that all attendees at least have data for first name, last name, and email address |
|
150 | + * |
|
151 | + * @param string $reg_url_link |
|
152 | + * @throws EE_Error |
|
153 | + * @throws ReflectionException |
|
154 | + */ |
|
155 | + public function ensureCriticalRegistrantDataIsSet(string $reg_url_link): void |
|
156 | + { |
|
157 | + if ($this->currentRegistrantIsPrimary()) { |
|
158 | + return; |
|
159 | + } |
|
160 | + // bare minimum critical details include first name, last name, email address |
|
161 | + $critical_attendee_details = ['ATT_fname', 'ATT_lname', 'ATT_email']; |
|
162 | + // add address info to critical details? |
|
163 | + if ( |
|
164 | + apply_filters( |
|
165 | + 'FHEE__EE_SPCO_Reg_Step_Attendee_Information__merge_address_details_with_critical_attendee_details', |
|
166 | + false |
|
167 | + ) |
|
168 | + ) { |
|
169 | + $critical_attendee_details += [ |
|
170 | + 'ATT_address', |
|
171 | + 'ATT_address2', |
|
172 | + 'ATT_city', |
|
173 | + 'STA_ID', |
|
174 | + 'CNT_ISO', |
|
175 | + 'ATT_zip', |
|
176 | + 'ATT_phone', |
|
177 | + ]; |
|
178 | + } |
|
179 | + foreach ($critical_attendee_details as $critical_attendee_detail) { |
|
180 | + if ( |
|
181 | + ! isset($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
182 | + || empty($this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ]) |
|
183 | + ) { |
|
184 | + $this->registrant_data[ $reg_url_link ][ $critical_attendee_detail ] = $this->primary_registrant->get( |
|
185 | + $critical_attendee_detail |
|
186 | + ); |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + |
|
192 | + /** |
|
193 | + * @param string $reg_url_link |
|
194 | + * @param array $registrant_data |
|
195 | + */ |
|
196 | + public function setRegistrantData(string $reg_url_link, array $registrant_data): void |
|
197 | + { |
|
198 | + $this->registrant_data[ $reg_url_link ] = $registrant_data; |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function getRequiredQuestions(): array |
|
206 | + { |
|
207 | + return $this->required_questions; |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * @param string $identifier |
|
213 | + * @param string $required_question |
|
214 | + */ |
|
215 | + public function addRequiredQuestion(string $identifier, string $required_question): void |
|
216 | + { |
|
217 | + $this->required_questions[ $identifier ] = $required_question; |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @return EE_Answer[] |
|
223 | + */ |
|
224 | + public function registrantAnswers(string $reg_url_link): array |
|
225 | + { |
|
226 | + return $this->registrant_answers[ $reg_url_link ] ?? []; |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * @param string $reg_url_link |
|
232 | + * @param string $identifier the answer cache ID |
|
233 | + * @param EE_Answer $answer |
|
234 | + */ |
|
235 | + public function addRegistrantAnswer(string $reg_url_link, string $identifier, EE_Answer $answer): void |
|
236 | + { |
|
237 | + $this->registrant_answers[ $reg_url_link ][ $identifier ] = $answer; |
|
238 | + } |
|
239 | + |
|
240 | + |
|
241 | + /** |
|
242 | + * @param string $reg_url_link |
|
243 | + * @param string $identifier |
|
244 | + * @return EE_Answer|null |
|
245 | + */ |
|
246 | + public function getRegistrantAnswer(string $reg_url_link, string $identifier): ?EE_Answer |
|
247 | + { |
|
248 | + return $this->registrant_answers[ $reg_url_link ][ $identifier ] ?? null; |
|
249 | + } |
|
250 | + |
|
251 | + |
|
252 | + |
|
253 | + /** |
|
254 | + * @param string $reg_url_link |
|
255 | + * @param string $identifier |
|
256 | + * @return bool |
|
257 | + */ |
|
258 | + public function registrantAnswerIsObject(string $reg_url_link, string $identifier): bool |
|
259 | + { |
|
260 | + $registrant_answer = $this->getRegistrantAnswer($reg_url_link, $identifier); |
|
261 | + return $registrant_answer instanceof EE_Answer; |
|
262 | + } |
|
263 | + |
|
264 | + |
|
265 | + /** |
|
266 | + * @return array |
|
267 | + */ |
|
268 | + public function primaryRegistrantData(): array |
|
269 | + { |
|
270 | + return $this->primary_registrant_data; |
|
271 | + } |
|
272 | + |
|
273 | + |
|
274 | + /** |
|
275 | + * @param string $key |
|
276 | + * @param mixed $value |
|
277 | + */ |
|
278 | + public function addPrimaryRegistrantDataValue(string $key, $value): void |
|
279 | + { |
|
280 | + $this->primary_registrant_data[ $key ] = $value; |
|
281 | + } |
|
282 | + |
|
283 | + |
|
284 | + /** |
|
285 | + * @param string $key |
|
286 | + * @return mixed |
|
287 | + */ |
|
288 | + public function getPrimaryRegistrantDataValue(string $key) |
|
289 | + { |
|
290 | + return $this->primary_registrant_data[ $key ] ?? null; |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @param array $primary_registrant_data |
|
296 | + */ |
|
297 | + public function setPrimaryRegistrantData(array $primary_registrant_data): void |
|
298 | + { |
|
299 | + $this->primary_registrant_data = $primary_registrant_data; |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * @return EE_Attendee |
|
305 | + */ |
|
306 | + public function primaryRegistrant(): EE_Attendee |
|
307 | + { |
|
308 | + return $this->primary_registrant; |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * @return bool |
|
314 | + */ |
|
315 | + public function primaryRegistrantIsValid(): bool |
|
316 | + { |
|
317 | + return $this->primary_registrant instanceof EE_Attendee; |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + /** |
|
322 | + * @param EE_Attendee $primary_registrant |
|
323 | + */ |
|
324 | + public function setPrimaryRegistrant(EE_Attendee $primary_registrant): void |
|
325 | + { |
|
326 | + $this->primary_registrant = $primary_registrant; |
|
327 | + } |
|
328 | + |
|
329 | + |
|
330 | + /** |
|
331 | + * @param string $reg_url_link |
|
332 | + * @return bool |
|
333 | + */ |
|
334 | + public function currentRegistrantIsPrimary(string $reg_url_link = ''): bool |
|
335 | + { |
|
336 | + return $this->attendeeCount() === 1 |
|
337 | + || ( |
|
338 | + $this->attendeeCount() === 1 |
|
339 | + && $reg_url_link !== '' |
|
340 | + && $this->getPrimaryRegistrantDataValue('reg_url_link') === $reg_url_link |
|
341 | + ); |
|
342 | + } |
|
343 | + |
|
344 | + |
|
345 | + /** |
|
346 | + * @return bool |
|
347 | + */ |
|
348 | + public function currentRegistrantIsNotPrimary(): bool |
|
349 | + { |
|
350 | + return $this->attendeeCount() > 1; |
|
351 | + } |
|
352 | + |
|
353 | + |
|
354 | + /** |
|
355 | + * @param string $reg_url_link |
|
356 | + * @param string $form_input |
|
357 | + * @param mixed $input_value |
|
358 | + * @return mixed|null |
|
359 | + */ |
|
360 | + public function saveOrCopyPrimaryRegistrantData(string $reg_url_link, string $form_input, $input_value) |
|
361 | + { |
|
362 | + // store a bit of data about the primary attendee |
|
363 | + if (! empty($input_value) && $this->currentRegistrantIsPrimary($reg_url_link)) { |
|
364 | + $this->primary_registrant_data[ $form_input ] = $input_value; |
|
365 | + return $input_value; |
|
366 | + } |
|
367 | + // or copy value from primary if incoming value is not set |
|
368 | + if ($input_value === null && $this->copyPrimary()) { |
|
369 | + $input_value = $this->getPrimaryRegistrantDataValue($form_input); |
|
370 | + } |
|
371 | + return $input_value; |
|
372 | + } |
|
373 | 373 | } |
@@ -22,472 +22,472 @@ |
||
22 | 22 | class EE_SPCO_Reg_Step_Attendee_Information extends EE_SPCO_Reg_Step |
23 | 23 | { |
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 | - /** @var RegFormDependencyHandler $dependency_handler */ |
|
116 | - $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
117 | - $dependency_handler->registerDependencies(); |
|
118 | - // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
119 | - return LoaderFactory::getShared(RegForm::class, [$this]); |
|
120 | - } |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * looking for hooks? |
|
125 | - * this method has been replaced by: |
|
126 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
127 | - * |
|
128 | - * @deprecated $VID:$ |
|
129 | - */ |
|
130 | - private function _registrations_reg_form() |
|
131 | - { |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * looking for hooks? |
|
137 | - * this method has been replaced by: |
|
138 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
139 | - * |
|
140 | - * @deprecated $VID:$ |
|
141 | - */ |
|
142 | - private function _additional_attendee_reg_info_input() |
|
143 | - { |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * looking for hooks? |
|
149 | - * this method has been replaced by: |
|
150 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
151 | - * |
|
152 | - * @deprecated $VID:$ |
|
153 | - */ |
|
154 | - private function _question_group_reg_form() |
|
155 | - { |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * looking for hooks? |
|
161 | - * this method has been replaced by: |
|
162 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
163 | - * |
|
164 | - * @deprecated $VID:$ |
|
165 | - */ |
|
166 | - private function _question_group_header() |
|
167 | - { |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * looking for hooks? |
|
173 | - * this method has been replaced by: |
|
174 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
175 | - * |
|
176 | - * @deprecated $VID:$ |
|
177 | - */ |
|
178 | - private function _copy_attendee_info_form() |
|
179 | - { |
|
180 | - } |
|
181 | - |
|
182 | - |
|
183 | - /** |
|
184 | - * looking for hooks? |
|
185 | - * this method has been replaced by: |
|
186 | - * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
187 | - * |
|
188 | - * @deprecated $VID:$ |
|
189 | - */ |
|
190 | - private function _auto_copy_attendee_info() |
|
191 | - { |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * looking for hooks? |
|
197 | - * this method has been replaced by: |
|
198 | - * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
199 | - * |
|
200 | - * @deprecated $VID:$ |
|
201 | - */ |
|
202 | - private function _copy_attendee_info_inputs() |
|
203 | - { |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * looking for hooks? |
|
209 | - * this method has been replaced by: |
|
210 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
211 | - * |
|
212 | - * @deprecated $VID:$ |
|
213 | - */ |
|
214 | - private function _additional_primary_registrant_inputs() |
|
215 | - { |
|
216 | - } |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * looking for hooks? |
|
221 | - * this method has been replaced by: |
|
222 | - * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
223 | - * |
|
224 | - * @param EE_Registration $registration |
|
225 | - * @param EE_Question $question |
|
226 | - * @return EE_Form_Input_Base |
|
227 | - * @throws EE_Error |
|
228 | - * @throws ReflectionException |
|
229 | - * @deprecated $VID:$ |
|
230 | - */ |
|
231 | - public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
232 | - { |
|
233 | - /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
234 | - $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
235 | - return $reg_form_question_factory->create($registration, $question); |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * looking for hooks? |
|
241 | - * this method has been replaced by: |
|
242 | - * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
243 | - * |
|
244 | - * @deprecated $VID:$ |
|
245 | - */ |
|
246 | - private function _generate_question_input() |
|
247 | - { |
|
248 | - } |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * looking for hooks? |
|
253 | - * this method has been replaced by: |
|
254 | - * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
255 | - * |
|
256 | - * @param array|null $countries_list |
|
257 | - * @param EE_Question|null $question |
|
258 | - * @param EE_Registration|null $registration |
|
259 | - * @param EE_Answer|null $answer |
|
260 | - * @return array 2d keys are country IDs, values are their names |
|
261 | - * @throws EE_Error |
|
262 | - * @throws ReflectionException |
|
263 | - * @deprecated $VID:$ |
|
264 | - */ |
|
265 | - public function use_cached_countries_for_form_input( |
|
266 | - array $countries_list = null, |
|
267 | - EE_Question $question = null, |
|
268 | - EE_Registration $registration = null, |
|
269 | - EE_Answer $answer = null |
|
270 | - ): array { |
|
271 | - /** @var CountryOptions $country_options */ |
|
272 | - $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
273 | - return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - /** |
|
278 | - * looking for hooks? |
|
279 | - * this method has been replaced by: |
|
280 | - * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
281 | - * |
|
282 | - * @param array|null $states_list |
|
283 | - * @param EE_Question|null $question |
|
284 | - * @param EE_Registration|null $registration |
|
285 | - * @param EE_Answer|null $answer |
|
286 | - * @return array 2d keys are state IDs, values are their names |
|
287 | - * @throws EE_Error |
|
288 | - * @throws ReflectionException |
|
289 | - * @deprecated $VID:$ |
|
290 | - */ |
|
291 | - public function use_cached_states_for_form_input( |
|
292 | - array $states_list = null, |
|
293 | - EE_Question $question = null, |
|
294 | - EE_Registration $registration = null, |
|
295 | - EE_Answer $answer = null |
|
296 | - ): array { |
|
297 | - /** @var StateOptions $state_options */ |
|
298 | - $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
299 | - return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /********************************************************************************************************/ |
|
304 | - /**************************************** PROCESS REG STEP ****************************************/ |
|
305 | - /********************************************************************************************************/ |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * @return bool |
|
310 | - * @throws EE_Error |
|
311 | - * @throws InvalidArgumentException |
|
312 | - * @throws ReflectionException |
|
313 | - * @throws RuntimeException |
|
314 | - * @throws InvalidDataTypeException |
|
315 | - * @throws InvalidInterfaceException |
|
316 | - */ |
|
317 | - public function process_reg_step(): bool |
|
318 | - { |
|
319 | - // grab validated data from form |
|
320 | - $valid_data = $this->checkout->current_step->valid_data(); |
|
321 | - // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
322 | - if (empty($valid_data)) { |
|
323 | - return $this->inValidDataError(); |
|
324 | - } |
|
325 | - if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
326 | - return $this->inValidTransactionError(); |
|
327 | - } |
|
328 | - // get cached registrations |
|
329 | - $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
330 | - // verify we got the goods |
|
331 | - if (empty($registrations)) { |
|
332 | - return $this->noRegistrationsError(); |
|
333 | - } |
|
334 | - /** @var RegFormHandler $reg_form_handler */ |
|
335 | - $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
336 | - // extract attendee info from form data and save to model objects |
|
337 | - if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
338 | - // return immediately if the previous step exited early due to errors |
|
339 | - return false; |
|
340 | - } |
|
341 | - // if first pass thru SPCO, |
|
342 | - // then let's check processed registrations against the total number of tickets in the cart |
|
343 | - $registrations_processed = $reg_form_handler->attendeeCount(); |
|
344 | - if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
345 | - return $this->registrationProcessingError($registrations_processed); |
|
346 | - } |
|
347 | - // mark this reg step as completed |
|
348 | - $this->set_completed(); |
|
349 | - $this->_set_success_message( |
|
350 | - esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
351 | - ); |
|
352 | - // do action in case a plugin wants to do something with the data submitted in step 1. |
|
353 | - // passes EE_Single_Page_Checkout, and it's posted data |
|
354 | - do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
355 | - return true; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * @return bool |
|
361 | - * @since $VID:$ |
|
362 | - */ |
|
363 | - private function inValidDataError(): bool |
|
364 | - { |
|
365 | - EE_Error::add_error( |
|
366 | - esc_html__('No valid question responses were received.', 'event_espresso'), |
|
367 | - __FILE__, |
|
368 | - __FUNCTION__, |
|
369 | - __LINE__ |
|
370 | - ); |
|
371 | - return false; |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - /** |
|
376 | - * @return bool |
|
377 | - * @since $VID:$ |
|
378 | - */ |
|
379 | - private function inValidTransactionError(): bool |
|
380 | - { |
|
381 | - EE_Error::add_error( |
|
382 | - esc_html__( |
|
383 | - 'A valid transaction could not be initiated for processing your registrations.', |
|
384 | - 'event_espresso' |
|
385 | - ), |
|
386 | - __FILE__, |
|
387 | - __FUNCTION__, |
|
388 | - __LINE__ |
|
389 | - ); |
|
390 | - return false; |
|
391 | - } |
|
392 | - |
|
393 | - |
|
394 | - /** |
|
395 | - * @return bool |
|
396 | - * @since $VID:$ |
|
397 | - */ |
|
398 | - private function noRegistrationsError(): bool |
|
399 | - { |
|
400 | - // combine the old translated string with a new one, in order to not break translations |
|
401 | - $error_message = esc_html__( |
|
402 | - 'Your form data could not be applied to any valid registrations.', |
|
403 | - 'event_espresso' |
|
404 | - ); |
|
405 | - $error_message .= sprintf( |
|
406 | - esc_html_x( |
|
407 | - '%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.', |
|
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 | - 'event_espresso' |
|
410 | - ), |
|
411 | - '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
412 | - '</a>', |
|
413 | - '<br />' |
|
414 | - ); |
|
415 | - EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
416 | - return false; |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - /** |
|
421 | - * @param int $registrations_processed |
|
422 | - * @return bool |
|
423 | - * @since $VID:$ |
|
424 | - */ |
|
425 | - private function registrationProcessingError(int $registrations_processed): bool |
|
426 | - { |
|
427 | - // generate a correctly translated string for all possible singular/plural combinations |
|
428 | - if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
429 | - $error_msg = sprintf( |
|
430 | - esc_html_x( |
|
431 | - 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
432 | - 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
433 | - 'event_espresso' |
|
434 | - ), |
|
435 | - $this->checkout->total_ticket_count, |
|
436 | - $registrations_processed |
|
437 | - ); |
|
438 | - } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
439 | - $error_msg = sprintf( |
|
440 | - esc_html_x( |
|
441 | - 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
442 | - 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
443 | - 'event_espresso' |
|
444 | - ), |
|
445 | - $this->checkout->total_ticket_count, |
|
446 | - $registrations_processed |
|
447 | - ); |
|
448 | - } else { |
|
449 | - $error_msg = sprintf( |
|
450 | - esc_html__( |
|
451 | - 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
452 | - 'event_espresso' |
|
453 | - ), |
|
454 | - $this->checkout->total_ticket_count, |
|
455 | - $registrations_processed |
|
456 | - ); |
|
457 | - } |
|
458 | - EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
459 | - return false; |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * update_reg_step |
|
465 | - * this is the final step after a user revisits the site to edit their attendee information |
|
466 | - * this gets called AFTER the process_reg_step() method above |
|
467 | - * |
|
468 | - * @return bool |
|
469 | - * @throws EE_Error |
|
470 | - * @throws InvalidArgumentException |
|
471 | - * @throws ReflectionException |
|
472 | - * @throws RuntimeException |
|
473 | - * @throws InvalidDataTypeException |
|
474 | - * @throws InvalidInterfaceException |
|
475 | - */ |
|
476 | - public function update_reg_step(): bool |
|
477 | - { |
|
478 | - // save everything |
|
479 | - if ($this->process_reg_step()) { |
|
480 | - $this->checkout->redirect = true; |
|
481 | - $this->checkout->redirect_url = add_query_arg( |
|
482 | - [ |
|
483 | - 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
484 | - 'revisit' => true, |
|
485 | - ], |
|
486 | - $this->checkout->thank_you_page_url |
|
487 | - ); |
|
488 | - $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
489 | - return true; |
|
490 | - } |
|
491 | - return false; |
|
492 | - } |
|
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 | + /** @var RegFormDependencyHandler $dependency_handler */ |
|
116 | + $dependency_handler = LoaderFactory::getShared(RegFormDependencyHandler::class); |
|
117 | + $dependency_handler->registerDependencies(); |
|
118 | + // TODO detect if event has a reg form UUID and swap this out for form generated by new reg form builder |
|
119 | + return LoaderFactory::getShared(RegForm::class, [$this]); |
|
120 | + } |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * looking for hooks? |
|
125 | + * this method has been replaced by: |
|
126 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::getRegForm() |
|
127 | + * |
|
128 | + * @deprecated $VID:$ |
|
129 | + */ |
|
130 | + private function _registrations_reg_form() |
|
131 | + { |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * looking for hooks? |
|
137 | + * this method has been replaced by: |
|
138 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalAttendeeRegInfoInput() |
|
139 | + * |
|
140 | + * @deprecated $VID:$ |
|
141 | + */ |
|
142 | + private function _additional_attendee_reg_info_input() |
|
143 | + { |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * looking for hooks? |
|
149 | + * this method has been replaced by: |
|
150 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupRegForm() |
|
151 | + * |
|
152 | + * @deprecated $VID:$ |
|
153 | + */ |
|
154 | + private function _question_group_reg_form() |
|
155 | + { |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * looking for hooks? |
|
161 | + * this method has been replaced by: |
|
162 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::questionGroupHeader() |
|
163 | + * |
|
164 | + * @deprecated $VID:$ |
|
165 | + */ |
|
166 | + private function _question_group_header() |
|
167 | + { |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * looking for hooks? |
|
173 | + * this method has been replaced by: |
|
174 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
175 | + * |
|
176 | + * @deprecated $VID:$ |
|
177 | + */ |
|
178 | + private function _copy_attendee_info_form() |
|
179 | + { |
|
180 | + } |
|
181 | + |
|
182 | + |
|
183 | + /** |
|
184 | + * looking for hooks? |
|
185 | + * this method has been replaced by: |
|
186 | + * EventEspresso\core\domain\services\registration\form\v1\AutoCopyAttendeeInfoForm |
|
187 | + * |
|
188 | + * @deprecated $VID:$ |
|
189 | + */ |
|
190 | + private function _auto_copy_attendee_info() |
|
191 | + { |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * looking for hooks? |
|
197 | + * this method has been replaced by: |
|
198 | + * EventEspresso\core\domain\services\registration\form\v1\CopyAttendeeInfoForm |
|
199 | + * |
|
200 | + * @deprecated $VID:$ |
|
201 | + */ |
|
202 | + private function _copy_attendee_info_inputs() |
|
203 | + { |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * looking for hooks? |
|
209 | + * this method has been replaced by: |
|
210 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::additionalPrimaryRegistrantInputs() |
|
211 | + * |
|
212 | + * @deprecated $VID:$ |
|
213 | + */ |
|
214 | + private function _additional_primary_registrant_inputs() |
|
215 | + { |
|
216 | + } |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * looking for hooks? |
|
221 | + * this method has been replaced by: |
|
222 | + * EventEspresso\core\domain\services\registration\form\v1\RegFormQuestionFactory::create() |
|
223 | + * |
|
224 | + * @param EE_Registration $registration |
|
225 | + * @param EE_Question $question |
|
226 | + * @return EE_Form_Input_Base |
|
227 | + * @throws EE_Error |
|
228 | + * @throws ReflectionException |
|
229 | + * @deprecated $VID:$ |
|
230 | + */ |
|
231 | + public function reg_form_question(EE_Registration $registration, EE_Question $question): EE_Form_Input_Base |
|
232 | + { |
|
233 | + /** @var RegFormQuestionFactory $reg_form_question_factory */ |
|
234 | + $reg_form_question_factory = LoaderFactory::getShared(RegFormQuestionFactory::class); |
|
235 | + return $reg_form_question_factory->create($registration, $question); |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * looking for hooks? |
|
241 | + * this method has been replaced by: |
|
242 | + * EventEspresso\core\domain\services\registration\form\v1\RegForm::generateQuestionInput() |
|
243 | + * |
|
244 | + * @deprecated $VID:$ |
|
245 | + */ |
|
246 | + private function _generate_question_input() |
|
247 | + { |
|
248 | + } |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * looking for hooks? |
|
253 | + * this method has been replaced by: |
|
254 | + * EventEspresso\core\domain\services\registration\form\v1\CountryOptions::forLegacyFormInput() |
|
255 | + * |
|
256 | + * @param array|null $countries_list |
|
257 | + * @param EE_Question|null $question |
|
258 | + * @param EE_Registration|null $registration |
|
259 | + * @param EE_Answer|null $answer |
|
260 | + * @return array 2d keys are country IDs, values are their names |
|
261 | + * @throws EE_Error |
|
262 | + * @throws ReflectionException |
|
263 | + * @deprecated $VID:$ |
|
264 | + */ |
|
265 | + public function use_cached_countries_for_form_input( |
|
266 | + array $countries_list = null, |
|
267 | + EE_Question $question = null, |
|
268 | + EE_Registration $registration = null, |
|
269 | + EE_Answer $answer = null |
|
270 | + ): array { |
|
271 | + /** @var CountryOptions $country_options */ |
|
272 | + $country_options = LoaderFactory::getShared(CountryOptions::class, [$this->checkout->action]); |
|
273 | + return $country_options->forLegacyFormInput($countries_list, $question, $registration, $answer); |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + /** |
|
278 | + * looking for hooks? |
|
279 | + * this method has been replaced by: |
|
280 | + * EventEspresso\core\domain\services\registration\form\v1\StateOptions::forLegacyFormInput() |
|
281 | + * |
|
282 | + * @param array|null $states_list |
|
283 | + * @param EE_Question|null $question |
|
284 | + * @param EE_Registration|null $registration |
|
285 | + * @param EE_Answer|null $answer |
|
286 | + * @return array 2d keys are state IDs, values are their names |
|
287 | + * @throws EE_Error |
|
288 | + * @throws ReflectionException |
|
289 | + * @deprecated $VID:$ |
|
290 | + */ |
|
291 | + public function use_cached_states_for_form_input( |
|
292 | + array $states_list = null, |
|
293 | + EE_Question $question = null, |
|
294 | + EE_Registration $registration = null, |
|
295 | + EE_Answer $answer = null |
|
296 | + ): array { |
|
297 | + /** @var StateOptions $state_options */ |
|
298 | + $state_options = LoaderFactory::getShared(StateOptions::class, [$this->checkout->action]); |
|
299 | + return $state_options->forLegacyFormInput($states_list, $question, $registration, $answer); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /********************************************************************************************************/ |
|
304 | + /**************************************** PROCESS REG STEP ****************************************/ |
|
305 | + /********************************************************************************************************/ |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * @return bool |
|
310 | + * @throws EE_Error |
|
311 | + * @throws InvalidArgumentException |
|
312 | + * @throws ReflectionException |
|
313 | + * @throws RuntimeException |
|
314 | + * @throws InvalidDataTypeException |
|
315 | + * @throws InvalidInterfaceException |
|
316 | + */ |
|
317 | + public function process_reg_step(): bool |
|
318 | + { |
|
319 | + // grab validated data from form |
|
320 | + $valid_data = $this->checkout->current_step->valid_data(); |
|
321 | + // if we don't have any $valid_data then something went TERRIBLY WRONG !!! |
|
322 | + if (empty($valid_data)) { |
|
323 | + return $this->inValidDataError(); |
|
324 | + } |
|
325 | + if (! $this->checkout->transaction instanceof EE_Transaction || ! $this->checkout->continue_reg) { |
|
326 | + return $this->inValidTransactionError(); |
|
327 | + } |
|
328 | + // get cached registrations |
|
329 | + $registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params); |
|
330 | + // verify we got the goods |
|
331 | + if (empty($registrations)) { |
|
332 | + return $this->noRegistrationsError(); |
|
333 | + } |
|
334 | + /** @var RegFormHandler $reg_form_handler */ |
|
335 | + $reg_form_handler = LoaderFactory::getNew(RegFormHandler::class, [$this->checkout]); |
|
336 | + // extract attendee info from form data and save to model objects |
|
337 | + if (! $reg_form_handler->processRegistrations($registrations, $valid_data)) { |
|
338 | + // return immediately if the previous step exited early due to errors |
|
339 | + return false; |
|
340 | + } |
|
341 | + // if first pass thru SPCO, |
|
342 | + // then let's check processed registrations against the total number of tickets in the cart |
|
343 | + $registrations_processed = $reg_form_handler->attendeeCount(); |
|
344 | + if (! $this->checkout->revisit && $registrations_processed !== $this->checkout->total_ticket_count) { |
|
345 | + return $this->registrationProcessingError($registrations_processed); |
|
346 | + } |
|
347 | + // mark this reg step as completed |
|
348 | + $this->set_completed(); |
|
349 | + $this->_set_success_message( |
|
350 | + esc_html__('The Attendee Information Step has been successfully completed.', 'event_espresso') |
|
351 | + ); |
|
352 | + // do action in case a plugin wants to do something with the data submitted in step 1. |
|
353 | + // passes EE_Single_Page_Checkout, and it's posted data |
|
354 | + do_action('AHEE__EE_Single_Page_Checkout__process_attendee_information__end', $this, $valid_data); |
|
355 | + return true; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * @return bool |
|
361 | + * @since $VID:$ |
|
362 | + */ |
|
363 | + private function inValidDataError(): bool |
|
364 | + { |
|
365 | + EE_Error::add_error( |
|
366 | + esc_html__('No valid question responses were received.', 'event_espresso'), |
|
367 | + __FILE__, |
|
368 | + __FUNCTION__, |
|
369 | + __LINE__ |
|
370 | + ); |
|
371 | + return false; |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + /** |
|
376 | + * @return bool |
|
377 | + * @since $VID:$ |
|
378 | + */ |
|
379 | + private function inValidTransactionError(): bool |
|
380 | + { |
|
381 | + EE_Error::add_error( |
|
382 | + esc_html__( |
|
383 | + 'A valid transaction could not be initiated for processing your registrations.', |
|
384 | + 'event_espresso' |
|
385 | + ), |
|
386 | + __FILE__, |
|
387 | + __FUNCTION__, |
|
388 | + __LINE__ |
|
389 | + ); |
|
390 | + return false; |
|
391 | + } |
|
392 | + |
|
393 | + |
|
394 | + /** |
|
395 | + * @return bool |
|
396 | + * @since $VID:$ |
|
397 | + */ |
|
398 | + private function noRegistrationsError(): bool |
|
399 | + { |
|
400 | + // combine the old translated string with a new one, in order to not break translations |
|
401 | + $error_message = esc_html__( |
|
402 | + 'Your form data could not be applied to any valid registrations.', |
|
403 | + 'event_espresso' |
|
404 | + ); |
|
405 | + $error_message .= sprintf( |
|
406 | + esc_html_x( |
|
407 | + '%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.', |
|
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 | + 'event_espresso' |
|
410 | + ), |
|
411 | + '<a href="' . get_post_type_archive_link('espresso_events') . '" >', |
|
412 | + '</a>', |
|
413 | + '<br />' |
|
414 | + ); |
|
415 | + EE_Error::add_error($error_message, __FILE__, __FUNCTION__, __LINE__); |
|
416 | + return false; |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + /** |
|
421 | + * @param int $registrations_processed |
|
422 | + * @return bool |
|
423 | + * @since $VID:$ |
|
424 | + */ |
|
425 | + private function registrationProcessingError(int $registrations_processed): bool |
|
426 | + { |
|
427 | + // generate a correctly translated string for all possible singular/plural combinations |
|
428 | + if ($this->checkout->total_ticket_count === 1 && $registrations_processed !== 1) { |
|
429 | + $error_msg = sprintf( |
|
430 | + esc_html_x( |
|
431 | + 'There was %1$d ticket in the Event Queue, but %2$ds registrations were processed', |
|
432 | + 'There was 1 ticket in the Event Queue, but 2 registrations were processed', |
|
433 | + 'event_espresso' |
|
434 | + ), |
|
435 | + $this->checkout->total_ticket_count, |
|
436 | + $registrations_processed |
|
437 | + ); |
|
438 | + } elseif ($this->checkout->total_ticket_count !== 1 && $registrations_processed === 1) { |
|
439 | + $error_msg = sprintf( |
|
440 | + esc_html_x( |
|
441 | + 'There was a total of %1$d tickets in the Event Queue, but only %2$ds registration was processed', |
|
442 | + 'There was a total of 2 tickets in the Event Queue, but only 1 registration was processed', |
|
443 | + 'event_espresso' |
|
444 | + ), |
|
445 | + $this->checkout->total_ticket_count, |
|
446 | + $registrations_processed |
|
447 | + ); |
|
448 | + } else { |
|
449 | + $error_msg = sprintf( |
|
450 | + esc_html__( |
|
451 | + 'There was a total of 2 tickets in the Event Queue, but 2 registrations were processed', |
|
452 | + 'event_espresso' |
|
453 | + ), |
|
454 | + $this->checkout->total_ticket_count, |
|
455 | + $registrations_processed |
|
456 | + ); |
|
457 | + } |
|
458 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
459 | + return false; |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * update_reg_step |
|
465 | + * this is the final step after a user revisits the site to edit their attendee information |
|
466 | + * this gets called AFTER the process_reg_step() method above |
|
467 | + * |
|
468 | + * @return bool |
|
469 | + * @throws EE_Error |
|
470 | + * @throws InvalidArgumentException |
|
471 | + * @throws ReflectionException |
|
472 | + * @throws RuntimeException |
|
473 | + * @throws InvalidDataTypeException |
|
474 | + * @throws InvalidInterfaceException |
|
475 | + */ |
|
476 | + public function update_reg_step(): bool |
|
477 | + { |
|
478 | + // save everything |
|
479 | + if ($this->process_reg_step()) { |
|
480 | + $this->checkout->redirect = true; |
|
481 | + $this->checkout->redirect_url = add_query_arg( |
|
482 | + [ |
|
483 | + 'e_reg_url_link' => $this->checkout->reg_url_link, |
|
484 | + 'revisit' => true, |
|
485 | + ], |
|
486 | + $this->checkout->thank_you_page_url |
|
487 | + ); |
|
488 | + $this->checkout->json_response->set_redirect_url($this->checkout->redirect_url); |
|
489 | + return true; |
|
490 | + } |
|
491 | + return false; |
|
492 | + } |
|
493 | 493 | } |
@@ -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 | ); |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class AttendeesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * AttendeesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * AttendeesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'AttendeesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'AttendeesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class TicketsConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * TicketsConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * TicketsConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'TicketsConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'TicketsConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -17,31 +17,31 @@ |
||
17 | 17 | class DatetimesConnectionOrderbyInput extends InputBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * DatetimesConnectionOrderbyInput constructor. |
|
22 | - */ |
|
23 | - public function __construct() |
|
24 | - { |
|
25 | - $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
26 | - $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | - parent::__construct(); |
|
28 | - } |
|
20 | + /** |
|
21 | + * DatetimesConnectionOrderbyInput constructor. |
|
22 | + */ |
|
23 | + public function __construct() |
|
24 | + { |
|
25 | + $this->setName($this->namespace . 'DatetimesConnectionOrderbyInput'); |
|
26 | + $this->setDescription(esc_html__('Options for ordering the connection', 'event_espresso')); |
|
27 | + parent::__construct(); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @return GraphQLFieldInterface[] |
|
33 | - */ |
|
34 | - protected function getFields(): array |
|
35 | - { |
|
36 | - return [ |
|
37 | - new GraphQLField( |
|
38 | - 'field', |
|
39 | - ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
40 | - ), |
|
41 | - new GraphQLField( |
|
42 | - 'order', |
|
43 | - 'OrderEnum' |
|
44 | - ), |
|
45 | - ]; |
|
46 | - } |
|
31 | + /** |
|
32 | + * @return GraphQLFieldInterface[] |
|
33 | + */ |
|
34 | + protected function getFields(): array |
|
35 | + { |
|
36 | + return [ |
|
37 | + new GraphQLField( |
|
38 | + 'field', |
|
39 | + ['non_null' => $this->namespace . 'DatetimesConnectionOrderbyEnum'] |
|
40 | + ), |
|
41 | + new GraphQLField( |
|
42 | + 'order', |
|
43 | + 'OrderEnum' |
|
44 | + ), |
|
45 | + ]; |
|
46 | + } |
|
47 | 47 | } |
@@ -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 | } |
@@ -14,63 +14,63 @@ |
||
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 | - // Update the entity |
|
62 | - $entity->save($args); |
|
61 | + // Update the entity |
|
62 | + $entity->save($args); |
|
63 | 63 | |
64 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'The datetime could not be updated because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - }; |
|
75 | - } |
|
64 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_event_update', $entity, $input); |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'The datetime could not be updated because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | + }; |
|
75 | + } |
|
76 | 76 | } |
@@ -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, |
@@ -15,59 +15,59 @@ |
||
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 | - // Update the entity |
|
51 | - $entity->save($args); |
|
50 | + // Update the entity |
|
51 | + $entity->save($args); |
|
52 | 52 | |
53 | - if (! empty($tickets)) { |
|
54 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
55 | - } |
|
53 | + if (! empty($tickets)) { |
|
54 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
55 | + } |
|
56 | 56 | |
57 | - do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
58 | - } catch (Exception $exception) { |
|
59 | - EntityMutator::handleExceptions( |
|
60 | - $exception, |
|
61 | - esc_html__( |
|
62 | - 'The datetime could not be updated because of the following error(s)', |
|
63 | - 'event_espresso' |
|
64 | - ) |
|
65 | - ); |
|
66 | - } |
|
57 | + do_action('AHEE__EventEspresso_core_domain_services_graphql_mutators_datetime_update', $entity, $input); |
|
58 | + } catch (Exception $exception) { |
|
59 | + EntityMutator::handleExceptions( |
|
60 | + $exception, |
|
61 | + esc_html__( |
|
62 | + 'The datetime could not be updated because of the following error(s)', |
|
63 | + 'event_espresso' |
|
64 | + ) |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | - return [ |
|
69 | - 'id' => $entity->ID(), |
|
70 | - ]; |
|
71 | - }; |
|
72 | - } |
|
68 | + return [ |
|
69 | + 'id' => $entity->ID(), |
|
70 | + ]; |
|
71 | + }; |
|
72 | + } |
|
73 | 73 | } |
@@ -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 |