Completed
Pull Request — master (#972)
by Darren
11:19
created
core/libraries/messages/data_class/EE_Messages_incoming_data.core.php 2 patches
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -18,519 +18,519 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * user id for logged in user when data collected
23
-     *
24
-     * @var string $user_id
25
-     */
26
-    public $user_id;
27
-
28
-    /**
29
-     * IP Address of browser used
30
-     *
31
-     * @var string $ip_address
32
-     */
33
-    public $ip_address;
34
-
35
-    /**
36
-     * browser
37
-     *
38
-     * @var string $user_agent
39
-     */
40
-    public $user_agent;
41
-
42
-    /**
43
-     * Unix timestamp
44
-     *
45
-     * @var string $init_access
46
-     */
47
-    public $init_access;
48
-
49
-    /**
50
-     * Unix timestamp
51
-     *
52
-     * @var string $last_access
53
-     */
54
-    public $last_access;
55
-
56
-    /**
57
-     * The registrations details from the cart
58
-     *
59
-     * @var array $reg_info
60
-     */
61
-    public $reg_info;
62
-
63
-    /**
64
-     * Some data handlers can set what reg status all the registrations are filtered by.
65
-     * The status should match a EEM_Registration status constant.
66
-     *
67
-     * @var string $filtered_reg_status
68
-     */
69
-    public $filtered_reg_status;
70
-
71
-    /**
72
-     * will hold an array of events assembled from $reg_info
73
-     *
74
-     * @var EE_Event[] $events
75
-     */
76
-    public $events;
77
-
78
-    /**
79
-     * holds an array of datetimes assembled from the incoming data.
80
-     *
81
-     * @var EE_Datetime[] $datetimes
82
-     */
83
-    public $datetimes;
84
-
85
-    /**
86
-     * holds an array of tickets assembled from the incoming data.
87
-     *
88
-     * @var EE_Ticket[] $tickets
89
-     */
90
-    public $tickets;
91
-
92
-    /**
93
-     * holds an array with a key of parent line item and values are an array of children of that line item.
94
-     *
95
-     * @since 4.5.0
96
-     * @var EE_Line_Item[] $line_items_with_children
97
-     */
98
-    public $line_items_with_children;
99
-
100
-    /**
101
-     * will hold an array of attendees assembled from the $reg_info
102
-     *
103
-     * @var EE_Attendee[] $attendees
104
-     */
105
-    public $attendees;
106
-
107
-    /**
108
-     * will hold an array of cached registration objects and info assembled from reg_info
109
-     *
110
-     * @var array $registrations
111
-     */
112
-    public $registrations;
113
-
114
-    /**
115
-     * will hold an array of answers assembled from the $reg_info
116
-     *
117
-     * @var EE_Answer[] $answers
118
-     */
119
-    public $answers;
120
-
121
-    /**
122
-     * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
123
-     *
124
-     * @var EE_Question[] $questions
125
-     */
126
-    public $questions;
127
-
128
-    /**
129
-     * Will hold billing data assembled from $billing_info (if present)
130
-     *
131
-     * @var mixed (array|null) $billing
132
-     */
133
-    public $billing;
134
-
135
-    /**
136
-     * The total amount of tax for the transaction
137
-     *
138
-     * @var float $taxes
139
-     */
140
-    public $taxes;
141
-
142
-    /**
143
-     * Holds the line items related to taxes
144
-     *
145
-     * @since 4.5.0
146
-     * @var EE_Line_Item[] $tax_line_items
147
-     */
148
-    public $tax_line_items;
149
-
150
-    /**
151
-     * Hold the line items which aren't taxes and don't relate
152
-     * to tickets. So: promotions and miscellaneous charges
153
-     *
154
-     * @since 4.5
155
-     * @var EE_Line_Item[] $additional_line_items
156
-     */
157
-    public $additional_line_items;
158
-
159
-    /**
160
-     * Holds the grand total EE_Line_Item
161
-     *
162
-     * @var EE_Line_Item $grand_total_line_item
163
-     */
164
-    public $grand_total_line_item;
165
-
166
-    /**
167
-     * holds the grand total price object
168
-     * currently not used.
169
-     *
170
-     * @var null $grand_total_price_object
171
-     */
172
-    public $grand_total_price_object;
173
-
174
-    /**
175
-     * total number of tickets
176
-     *
177
-     * @var int $total_ticket_count
178
-     */
179
-    public $total_ticket_count;
180
-
181
-    /**
182
-     * Will hold the final transaction object (EE_Transaction)
183
-     *
184
-     * @var EE_Transaction $txn
185
-     */
186
-    public $txn;
187
-
188
-    /**
189
-     * Holds the payments related to a transaction
190
-     *
191
-     * @since 4.5.0
192
-     * @var EE_Payment[] $payments
193
-     */
194
-    public $payments;
195
-
196
-    /**
197
-     * Holds the first related payment related for a transaction
198
-     *
199
-     * @since 4.5.0
200
-     * @var EE_Payment $payment
201
-     */
202
-    public $payment;
203
-
204
-    /**
205
-     * Will hold the label for the txn status
206
-     *
207
-     * @var string $txn_status
208
-     */
209
-    public $txn_status;
210
-
211
-    /**
212
-     * Will hold the final registration object (EE_Registration)
213
-     *
214
-     * @var EE_Registration[] $reg_objs
215
-     */
216
-    public $reg_objs;
217
-
218
-    /**
219
-     * Will hold an array of primary attendee data (if present)
220
-     *
221
-     * @var array $primary_attendee_data
222
-     */
223
-    public $primary_attendee_data;
224
-
225
-    /**
226
-     * This is just an internal object used for passing around the incoming data.
227
-     *
228
-     * @var mixed $_data
229
-     */
230
-    protected $_data;
231
-
232
-    /**
233
-     * This is just an internal object used for passing around the incoming data.
234
-     *
235
-     * @var mixed $incoming_data
236
-     */
237
-    public $incoming_data;
238
-
239
-    /**
240
-     * hold objects that might be created
241
-     *
242
-     * @type EE_Registration $reg_obj
243
-     */
244
-    public $reg_obj;
245
-
246
-
247
-    /**
248
-     * constructor
249
-     *
250
-     * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
251
-     *                    data object.  But here parent will be generic because we don't know what's coming in.
252
-     */
253
-    public function __construct($data)
254
-    {
255
-        $this->_data = $data;
256
-        $this->_setup_data();
257
-    }
258
-
259
-
260
-    /**
261
-     * Every child class has to setup the data object !
262
-     *
263
-     * @return void
264
-     */
265
-    abstract protected function _setup_data();
266
-
267
-
268
-    /**
269
-     * Returns database safe representation of the data later used to when instantiating this object.
270
-     *
271
-     * @param mixed $data The incoming data to be prepped.
272
-     * @return mixed   The prepped data for db
273
-     */
274
-    public static function convert_data_for_persistent_storage($data)
275
-    {
276
-        return $data;
277
-    }
278
-
279
-
280
-    /**
281
-     * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
282
-     * can be sent into this method and converted back into the format used for instantiating with this data handler.
283
-     *
284
-     * @param $data
285
-     * @return mixed
286
-     */
287
-    public static function convert_data_from_persistent_storage($data)
288
-    {
289
-        return $data;
290
-    }
291
-
292
-
293
-    /**
294
-     * only purpose is to return the data
295
-     *
296
-     * @access public
297
-     * @return mixed the formatted data object!
298
-     */
299
-    public function data()
300
-    {
301
-        return $this->_data;
302
-    }
303
-
304
-
305
-    /**
306
-     * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
307
-     * is that $this->reg_objs be set.
308
-     *
309
-     * @throws EE_Error
310
-     * @throws InvalidDataTypeException
311
-     * @throws InvalidInterfaceException
312
-     * @throws InvalidArgumentException
313
-     * @throws EntityNotFoundException
314
-     */
315
-    protected function _assemble_data()
316
-    {
317
-        // verify that reg_objs is set
318
-        if (! is_array($this->reg_objs)
319
-            && ! reset($this->reg_objs) instanceof EE_Registration
320
-        ) {
321
-            throw new EE_Error(
322
-                esc_html__(
323
-                    'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
324
-                    'event_espresso'
325
-                )
326
-            );
327
-        }
328
-
329
-        // get all attendee and events associated with the registrations in this transaction
330
-        $events             = $event_setup = $evtcache = $tickets = $datetimes = array();
331
-        $answers            = $questions = $attendees = $line_items = $registrations = array();
332
-        $total_ticket_count = 0;
333
-
334
-        if (! empty($this->reg_objs)) {
335
-            $event_attendee_count = array();
336
-            /** @var EE_Registration $reg */
337
-            foreach ($this->reg_objs as $reg) {
338
-                if ($this->_skip_registration_for_processing($reg)
339
-                ) {
340
-                    continue;
341
-                }
342
-
343
-                $evt_id = $reg->event_ID();
344
-                /** @type EE_Ticket $ticket */
345
-                $ticket          = $reg->get_first_related('Ticket');
346
-                $attendee = $reg->attendee();
347
-                $event = $reg->event();
348
-                // if none of the following entities are available, then we can't setup other data reliably,
349
-                // so let's just skip.
350
-                if (! $ticket instanceof EE_Ticket
351
-                    || ! $attendee instanceof EE_Attendee
352
-                    || ! $event instanceof EE_Event
353
-                ) {
354
-                    continue;
355
-                }
356
-                $relateddatetime = $ticket->datetimes();
357
-                $total_ticket_count++;
358
-                $tickets[ $ticket->ID() ]['ticket']                        = $ticket;
359
-                $tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
360
-                                                                           && isset($tickets[ $ticket->ID() ]['count'])
361
-                    ? $tickets[ $ticket->ID() ]['count'] + 1
362
-                    : 1;
363
-                $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
364
-                $tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
365
-                $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
366
-                $tickets[ $ticket->ID() ]['EE_Event']                      = $event;
367
-                $evtcache[ $evt_id ]                                       = $event;
368
-                $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
369
-                $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
370
-                $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
371
-                $event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
372
-                    ? $event_attendee_count[ $evt_id ] + 1
373
-                    : 0;
374
-                $attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
375
-                $attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
376
-                $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
377
-                // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
378
-                $attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
379
-                $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
380
-                $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
381
-
382
-                // registrations
383
-                $registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
384
-                $registrations[ $reg->ID() ]['evt_obj'] = $event;
385
-                $registrations[ $reg->ID() ]['reg_obj'] = $reg;
386
-                $registrations[ $reg->ID() ]['att_obj'] = $attendee;
387
-
388
-                // set up answer objects
389
-                $rel_ans = $reg->get_many_related('Answer');
390
-                foreach ($rel_ans as $ansid => $answer) {
391
-                    if (! isset($questions[ $ansid ])) {
392
-                        $questions[ $ansid ] = $answer->get_first_related('Question');
393
-                    }
394
-                    $answers[ $ansid ]                               = $answer;
395
-                    $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
396
-                }
397
-                /**
398
-                 * @var int $dtt_id
399
-                 * @var EE_Datetime $datetime
400
-                 */
401
-                foreach ($relateddatetime as $dtt_id => $datetime) {
402
-                    $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
403
-                    $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
404
-
405
-                    if (isset($datetimes[ $dtt_id ])) {
406
-                        continue; // already have this info in the datetimes array.
407
-                    }
408
-
409
-                    $datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
410
-                    $datetimes[ $dtt_id ]['datetime']             = $datetime;
411
-                    $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
412
-                    $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
413
-                }
414
-            }
415
-
416
-            // let's loop through the unique event=>reg items and setup data on them
417
-
418
-            if (! empty($eventsetup)) {
419
-                foreach ($eventsetup as $evt_id => $items) {
420
-                    $ticket_line_items_for_event = array();
421
-                    if ($this->txn instanceof EE_Transaction) {
422
-                        $ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
423
-                            array(
424
-                                array(
425
-                                    'Ticket.Datetime.EVT_ID' => $evt_id,
426
-                                    'TXN_ID'                 => $this->txn->ID(),
427
-                                ),
428
-                                'default_where_conditions' => 'none',
429
-                            )
430
-                        );
431
-                    }
432
-                    $events[ $evt_id ] = array(
433
-                        'ID'              => $evt_id,
434
-                        'event'           => $evtcache[ $evt_id ],
435
-                        'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
436
-                        'total_attendees' => $event_attendee_count[ $evt_id ],
437
-                        'reg_objs'        => $items['reg_objs'],
438
-                        'tkt_objs'        => $items['tkt_objs'],
439
-                        'att_objs'        => $items['att_objs'],
440
-                        'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
441
-                        'line_items'      => $ticket_line_items_for_event,
442
-                    );
443
-
444
-                    // make sure the tickets have the line items setup for them.
445
-                    foreach ($ticket_line_items_for_event as $line_id => $line_item) {
446
-                        // only add the ticket line items if we already have this ticket in the $tickets array.
447
-                        if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
448
-                            $tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
449
-                            $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
450
-                            $line_items[ $line_item->ID() ]['children']              = $line_item->children();
451
-                            $line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
452
-                        }
453
-                    }
454
-                }
455
-            }
456
-
457
-            $this->grand_total_line_item = $this->txn instanceof EE_Transaction
458
-                ? $this->txn->total_line_item()
459
-                : null;
460
-        }
461
-
462
-        // lets set the attendees and events properties
463
-        $this->attendees                = $attendees;
464
-        $this->events                   = $events;
465
-        $this->tickets                  = $tickets;
466
-        $this->line_items_with_children = $line_items;
467
-        $this->datetimes                = $datetimes;
468
-        $this->questions                = $questions;
469
-        $this->answers                  = $answers;
470
-        $this->total_ticket_count       = $total_ticket_count;
471
-        $this->registrations            = $registrations;
472
-
473
-        if ($this->txn instanceof EE_Transaction) {
474
-            $this->tax_line_items        = $this->txn->tax_items();
475
-            $this->additional_line_items = $this->txn->non_ticket_line_items();
476
-            $this->payments              = $this->txn->payments();
477
-
478
-            // setup primary registration if we have a single transaction object to work with
479
-
480
-            // let's get just the primary_attendee_data!  First we get the primary registration object.
481
-            $primary_reg = $this->txn->primary_registration();
482
-            // verify
483
-            if ($primary_reg instanceof EE_Registration) {
484
-                // get attendee object
485
-                if ($primary_reg->attendee() instanceof EE_Attendee) {
486
-                    // now we can setup the primary_attendee_data array
487
-                    $this->primary_attendee_data = array(
488
-                        'registration_id' => $primary_reg->ID(),
489
-                        'att_obj'         => $primary_reg->attendee(),
490
-                        'reg_obj'         => $primary_reg,
491
-                        'primary_att_obj' => $primary_reg->attendee(),
492
-                        'primary_reg_obj' => $primary_reg,
493
-                    );
494
-                } else {
495
-                    EE_Error::add_error(
496
-                        esc_html__(
497
-                            'Incoming data does not have a valid Attendee object for the primary registrant.',
498
-                            'event_espresso'
499
-                        ),
500
-                        __FILE__,
501
-                        __FUNCTION__,
502
-                        __LINE__
503
-                    );
504
-                }
505
-            } else {
506
-                EE_Error::add_error(
507
-                    esc_html__(
508
-                        'Incoming data does not have a valid Registration object for the primary registrant.',
509
-                        'event_espresso'
510
-                    ),
511
-                    __FILE__,
512
-                    __FUNCTION__,
513
-                    __LINE__
514
-                );
515
-            }
516
-        }
517
-    }
518
-
519
-    /**
520
-     * This simply considers whether the given registration should be processed or not based on comparison with the
521
-     * filtered_reg_status property.
522
-     *
523
-     * @param EE_Registration $registration
524
-     * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
525
-     *               processing
526
-     */
527
-    protected function _skip_registration_for_processing(EE_Registration $registration)
528
-    {
529
-        if (empty($this->filtered_reg_status)) {
530
-            return false;
531
-        }
532
-
533
-        // if we made it here then we just compare the filtered_reg_status with the registration status and return that
534
-        return $this->filtered_reg_status !== $registration->status_ID();
535
-    }
21
+	/**
22
+	 * user id for logged in user when data collected
23
+	 *
24
+	 * @var string $user_id
25
+	 */
26
+	public $user_id;
27
+
28
+	/**
29
+	 * IP Address of browser used
30
+	 *
31
+	 * @var string $ip_address
32
+	 */
33
+	public $ip_address;
34
+
35
+	/**
36
+	 * browser
37
+	 *
38
+	 * @var string $user_agent
39
+	 */
40
+	public $user_agent;
41
+
42
+	/**
43
+	 * Unix timestamp
44
+	 *
45
+	 * @var string $init_access
46
+	 */
47
+	public $init_access;
48
+
49
+	/**
50
+	 * Unix timestamp
51
+	 *
52
+	 * @var string $last_access
53
+	 */
54
+	public $last_access;
55
+
56
+	/**
57
+	 * The registrations details from the cart
58
+	 *
59
+	 * @var array $reg_info
60
+	 */
61
+	public $reg_info;
62
+
63
+	/**
64
+	 * Some data handlers can set what reg status all the registrations are filtered by.
65
+	 * The status should match a EEM_Registration status constant.
66
+	 *
67
+	 * @var string $filtered_reg_status
68
+	 */
69
+	public $filtered_reg_status;
70
+
71
+	/**
72
+	 * will hold an array of events assembled from $reg_info
73
+	 *
74
+	 * @var EE_Event[] $events
75
+	 */
76
+	public $events;
77
+
78
+	/**
79
+	 * holds an array of datetimes assembled from the incoming data.
80
+	 *
81
+	 * @var EE_Datetime[] $datetimes
82
+	 */
83
+	public $datetimes;
84
+
85
+	/**
86
+	 * holds an array of tickets assembled from the incoming data.
87
+	 *
88
+	 * @var EE_Ticket[] $tickets
89
+	 */
90
+	public $tickets;
91
+
92
+	/**
93
+	 * holds an array with a key of parent line item and values are an array of children of that line item.
94
+	 *
95
+	 * @since 4.5.0
96
+	 * @var EE_Line_Item[] $line_items_with_children
97
+	 */
98
+	public $line_items_with_children;
99
+
100
+	/**
101
+	 * will hold an array of attendees assembled from the $reg_info
102
+	 *
103
+	 * @var EE_Attendee[] $attendees
104
+	 */
105
+	public $attendees;
106
+
107
+	/**
108
+	 * will hold an array of cached registration objects and info assembled from reg_info
109
+	 *
110
+	 * @var array $registrations
111
+	 */
112
+	public $registrations;
113
+
114
+	/**
115
+	 * will hold an array of answers assembled from the $reg_info
116
+	 *
117
+	 * @var EE_Answer[] $answers
118
+	 */
119
+	public $answers;
120
+
121
+	/**
122
+	 * will hold an array of questions assembled from the $reg_info (indexed by Answer ID);
123
+	 *
124
+	 * @var EE_Question[] $questions
125
+	 */
126
+	public $questions;
127
+
128
+	/**
129
+	 * Will hold billing data assembled from $billing_info (if present)
130
+	 *
131
+	 * @var mixed (array|null) $billing
132
+	 */
133
+	public $billing;
134
+
135
+	/**
136
+	 * The total amount of tax for the transaction
137
+	 *
138
+	 * @var float $taxes
139
+	 */
140
+	public $taxes;
141
+
142
+	/**
143
+	 * Holds the line items related to taxes
144
+	 *
145
+	 * @since 4.5.0
146
+	 * @var EE_Line_Item[] $tax_line_items
147
+	 */
148
+	public $tax_line_items;
149
+
150
+	/**
151
+	 * Hold the line items which aren't taxes and don't relate
152
+	 * to tickets. So: promotions and miscellaneous charges
153
+	 *
154
+	 * @since 4.5
155
+	 * @var EE_Line_Item[] $additional_line_items
156
+	 */
157
+	public $additional_line_items;
158
+
159
+	/**
160
+	 * Holds the grand total EE_Line_Item
161
+	 *
162
+	 * @var EE_Line_Item $grand_total_line_item
163
+	 */
164
+	public $grand_total_line_item;
165
+
166
+	/**
167
+	 * holds the grand total price object
168
+	 * currently not used.
169
+	 *
170
+	 * @var null $grand_total_price_object
171
+	 */
172
+	public $grand_total_price_object;
173
+
174
+	/**
175
+	 * total number of tickets
176
+	 *
177
+	 * @var int $total_ticket_count
178
+	 */
179
+	public $total_ticket_count;
180
+
181
+	/**
182
+	 * Will hold the final transaction object (EE_Transaction)
183
+	 *
184
+	 * @var EE_Transaction $txn
185
+	 */
186
+	public $txn;
187
+
188
+	/**
189
+	 * Holds the payments related to a transaction
190
+	 *
191
+	 * @since 4.5.0
192
+	 * @var EE_Payment[] $payments
193
+	 */
194
+	public $payments;
195
+
196
+	/**
197
+	 * Holds the first related payment related for a transaction
198
+	 *
199
+	 * @since 4.5.0
200
+	 * @var EE_Payment $payment
201
+	 */
202
+	public $payment;
203
+
204
+	/**
205
+	 * Will hold the label for the txn status
206
+	 *
207
+	 * @var string $txn_status
208
+	 */
209
+	public $txn_status;
210
+
211
+	/**
212
+	 * Will hold the final registration object (EE_Registration)
213
+	 *
214
+	 * @var EE_Registration[] $reg_objs
215
+	 */
216
+	public $reg_objs;
217
+
218
+	/**
219
+	 * Will hold an array of primary attendee data (if present)
220
+	 *
221
+	 * @var array $primary_attendee_data
222
+	 */
223
+	public $primary_attendee_data;
224
+
225
+	/**
226
+	 * This is just an internal object used for passing around the incoming data.
227
+	 *
228
+	 * @var mixed $_data
229
+	 */
230
+	protected $_data;
231
+
232
+	/**
233
+	 * This is just an internal object used for passing around the incoming data.
234
+	 *
235
+	 * @var mixed $incoming_data
236
+	 */
237
+	public $incoming_data;
238
+
239
+	/**
240
+	 * hold objects that might be created
241
+	 *
242
+	 * @type EE_Registration $reg_obj
243
+	 */
244
+	public $reg_obj;
245
+
246
+
247
+	/**
248
+	 * constructor
249
+	 *
250
+	 * @param mixed $data incoming data object|array.  Suggested that child classes use type hinting for expected
251
+	 *                    data object.  But here parent will be generic because we don't know what's coming in.
252
+	 */
253
+	public function __construct($data)
254
+	{
255
+		$this->_data = $data;
256
+		$this->_setup_data();
257
+	}
258
+
259
+
260
+	/**
261
+	 * Every child class has to setup the data object !
262
+	 *
263
+	 * @return void
264
+	 */
265
+	abstract protected function _setup_data();
266
+
267
+
268
+	/**
269
+	 * Returns database safe representation of the data later used to when instantiating this object.
270
+	 *
271
+	 * @param mixed $data The incoming data to be prepped.
272
+	 * @return mixed   The prepped data for db
273
+	 */
274
+	public static function convert_data_for_persistent_storage($data)
275
+	{
276
+		return $data;
277
+	}
278
+
279
+
280
+	/**
281
+	 * Data that has been stored in persistent storage that was prepped by _convert_data_for_persistent_storage
282
+	 * can be sent into this method and converted back into the format used for instantiating with this data handler.
283
+	 *
284
+	 * @param $data
285
+	 * @return mixed
286
+	 */
287
+	public static function convert_data_from_persistent_storage($data)
288
+	{
289
+		return $data;
290
+	}
291
+
292
+
293
+	/**
294
+	 * only purpose is to return the data
295
+	 *
296
+	 * @access public
297
+	 * @return mixed the formatted data object!
298
+	 */
299
+	public function data()
300
+	{
301
+		return $this->_data;
302
+	}
303
+
304
+
305
+	/**
306
+	 * This helper method can be used by any incoming data handlers to setup the data correctly.  All that is required
307
+	 * is that $this->reg_objs be set.
308
+	 *
309
+	 * @throws EE_Error
310
+	 * @throws InvalidDataTypeException
311
+	 * @throws InvalidInterfaceException
312
+	 * @throws InvalidArgumentException
313
+	 * @throws EntityNotFoundException
314
+	 */
315
+	protected function _assemble_data()
316
+	{
317
+		// verify that reg_objs is set
318
+		if (! is_array($this->reg_objs)
319
+			&& ! reset($this->reg_objs) instanceof EE_Registration
320
+		) {
321
+			throw new EE_Error(
322
+				esc_html__(
323
+					'In order to assemble the data correctly, the "reg_objs" property must be an array of EE_Registration objects',
324
+					'event_espresso'
325
+				)
326
+			);
327
+		}
328
+
329
+		// get all attendee and events associated with the registrations in this transaction
330
+		$events             = $event_setup = $evtcache = $tickets = $datetimes = array();
331
+		$answers            = $questions = $attendees = $line_items = $registrations = array();
332
+		$total_ticket_count = 0;
333
+
334
+		if (! empty($this->reg_objs)) {
335
+			$event_attendee_count = array();
336
+			/** @var EE_Registration $reg */
337
+			foreach ($this->reg_objs as $reg) {
338
+				if ($this->_skip_registration_for_processing($reg)
339
+				) {
340
+					continue;
341
+				}
342
+
343
+				$evt_id = $reg->event_ID();
344
+				/** @type EE_Ticket $ticket */
345
+				$ticket          = $reg->get_first_related('Ticket');
346
+				$attendee = $reg->attendee();
347
+				$event = $reg->event();
348
+				// if none of the following entities are available, then we can't setup other data reliably,
349
+				// so let's just skip.
350
+				if (! $ticket instanceof EE_Ticket
351
+					|| ! $attendee instanceof EE_Attendee
352
+					|| ! $event instanceof EE_Event
353
+				) {
354
+					continue;
355
+				}
356
+				$relateddatetime = $ticket->datetimes();
357
+				$total_ticket_count++;
358
+				$tickets[ $ticket->ID() ]['ticket']                        = $ticket;
359
+				$tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
360
+																		   && isset($tickets[ $ticket->ID() ]['count'])
361
+					? $tickets[ $ticket->ID() ]['count'] + 1
362
+					: 1;
363
+				$tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
364
+				$tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
365
+				$tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
366
+				$tickets[ $ticket->ID() ]['EE_Event']                      = $event;
367
+				$evtcache[ $evt_id ]                                       = $event;
368
+				$eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
369
+				$eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
370
+				$eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
371
+				$event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
372
+					? $event_attendee_count[ $evt_id ] + 1
373
+					: 0;
374
+				$attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
375
+				$attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
376
+				$attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
377
+				// $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
378
+				$attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
379
+				$attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
380
+				$attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
381
+
382
+				// registrations
383
+				$registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
384
+				$registrations[ $reg->ID() ]['evt_obj'] = $event;
385
+				$registrations[ $reg->ID() ]['reg_obj'] = $reg;
386
+				$registrations[ $reg->ID() ]['att_obj'] = $attendee;
387
+
388
+				// set up answer objects
389
+				$rel_ans = $reg->get_many_related('Answer');
390
+				foreach ($rel_ans as $ansid => $answer) {
391
+					if (! isset($questions[ $ansid ])) {
392
+						$questions[ $ansid ] = $answer->get_first_related('Question');
393
+					}
394
+					$answers[ $ansid ]                               = $answer;
395
+					$registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
396
+				}
397
+				/**
398
+				 * @var int $dtt_id
399
+				 * @var EE_Datetime $datetime
400
+				 */
401
+				foreach ($relateddatetime as $dtt_id => $datetime) {
402
+					$eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
403
+					$registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
404
+
405
+					if (isset($datetimes[ $dtt_id ])) {
406
+						continue; // already have this info in the datetimes array.
407
+					}
408
+
409
+					$datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
410
+					$datetimes[ $dtt_id ]['datetime']             = $datetime;
411
+					$datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
412
+					$datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
413
+				}
414
+			}
415
+
416
+			// let's loop through the unique event=>reg items and setup data on them
417
+
418
+			if (! empty($eventsetup)) {
419
+				foreach ($eventsetup as $evt_id => $items) {
420
+					$ticket_line_items_for_event = array();
421
+					if ($this->txn instanceof EE_Transaction) {
422
+						$ticket_line_items_for_event = EEM_Line_Item::instance()->get_all(
423
+							array(
424
+								array(
425
+									'Ticket.Datetime.EVT_ID' => $evt_id,
426
+									'TXN_ID'                 => $this->txn->ID(),
427
+								),
428
+								'default_where_conditions' => 'none',
429
+							)
430
+						);
431
+					}
432
+					$events[ $evt_id ] = array(
433
+						'ID'              => $evt_id,
434
+						'event'           => $evtcache[ $evt_id ],
435
+						'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
436
+						'total_attendees' => $event_attendee_count[ $evt_id ],
437
+						'reg_objs'        => $items['reg_objs'],
438
+						'tkt_objs'        => $items['tkt_objs'],
439
+						'att_objs'        => $items['att_objs'],
440
+						'dtt_objs'        => isset($items['dtt_objs']) ? $items['dtt_objs'] : array(),
441
+						'line_items'      => $ticket_line_items_for_event,
442
+					);
443
+
444
+					// make sure the tickets have the line items setup for them.
445
+					foreach ($ticket_line_items_for_event as $line_id => $line_item) {
446
+						// only add the ticket line items if we already have this ticket in the $tickets array.
447
+						if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
448
+							$tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
449
+							$tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
450
+							$line_items[ $line_item->ID() ]['children']              = $line_item->children();
451
+							$line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
452
+						}
453
+					}
454
+				}
455
+			}
456
+
457
+			$this->grand_total_line_item = $this->txn instanceof EE_Transaction
458
+				? $this->txn->total_line_item()
459
+				: null;
460
+		}
461
+
462
+		// lets set the attendees and events properties
463
+		$this->attendees                = $attendees;
464
+		$this->events                   = $events;
465
+		$this->tickets                  = $tickets;
466
+		$this->line_items_with_children = $line_items;
467
+		$this->datetimes                = $datetimes;
468
+		$this->questions                = $questions;
469
+		$this->answers                  = $answers;
470
+		$this->total_ticket_count       = $total_ticket_count;
471
+		$this->registrations            = $registrations;
472
+
473
+		if ($this->txn instanceof EE_Transaction) {
474
+			$this->tax_line_items        = $this->txn->tax_items();
475
+			$this->additional_line_items = $this->txn->non_ticket_line_items();
476
+			$this->payments              = $this->txn->payments();
477
+
478
+			// setup primary registration if we have a single transaction object to work with
479
+
480
+			// let's get just the primary_attendee_data!  First we get the primary registration object.
481
+			$primary_reg = $this->txn->primary_registration();
482
+			// verify
483
+			if ($primary_reg instanceof EE_Registration) {
484
+				// get attendee object
485
+				if ($primary_reg->attendee() instanceof EE_Attendee) {
486
+					// now we can setup the primary_attendee_data array
487
+					$this->primary_attendee_data = array(
488
+						'registration_id' => $primary_reg->ID(),
489
+						'att_obj'         => $primary_reg->attendee(),
490
+						'reg_obj'         => $primary_reg,
491
+						'primary_att_obj' => $primary_reg->attendee(),
492
+						'primary_reg_obj' => $primary_reg,
493
+					);
494
+				} else {
495
+					EE_Error::add_error(
496
+						esc_html__(
497
+							'Incoming data does not have a valid Attendee object for the primary registrant.',
498
+							'event_espresso'
499
+						),
500
+						__FILE__,
501
+						__FUNCTION__,
502
+						__LINE__
503
+					);
504
+				}
505
+			} else {
506
+				EE_Error::add_error(
507
+					esc_html__(
508
+						'Incoming data does not have a valid Registration object for the primary registrant.',
509
+						'event_espresso'
510
+					),
511
+					__FILE__,
512
+					__FUNCTION__,
513
+					__LINE__
514
+				);
515
+			}
516
+		}
517
+	}
518
+
519
+	/**
520
+	 * This simply considers whether the given registration should be processed or not based on comparison with the
521
+	 * filtered_reg_status property.
522
+	 *
523
+	 * @param EE_Registration $registration
524
+	 * @return bool  returning true means we DO want to skip processing.  returning false means we DON'T want to skip
525
+	 *               processing
526
+	 */
527
+	protected function _skip_registration_for_processing(EE_Registration $registration)
528
+	{
529
+		if (empty($this->filtered_reg_status)) {
530
+			return false;
531
+		}
532
+
533
+		// if we made it here then we just compare the filtered_reg_status with the registration status and return that
534
+		return $this->filtered_reg_status !== $registration->status_ID();
535
+	}
536 536
 }
Please login to merge, or discard this patch.
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
     protected function _assemble_data()
316 316
     {
317 317
         // verify that reg_objs is set
318
-        if (! is_array($this->reg_objs)
318
+        if ( ! is_array($this->reg_objs)
319 319
             && ! reset($this->reg_objs) instanceof EE_Registration
320 320
         ) {
321 321
             throw new EE_Error(
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
         $answers            = $questions = $attendees = $line_items = $registrations = array();
332 332
         $total_ticket_count = 0;
333 333
 
334
-        if (! empty($this->reg_objs)) {
334
+        if ( ! empty($this->reg_objs)) {
335 335
             $event_attendee_count = array();
336 336
             /** @var EE_Registration $reg */
337 337
             foreach ($this->reg_objs as $reg) {
@@ -342,12 +342,12 @@  discard block
 block discarded – undo
342 342
 
343 343
                 $evt_id = $reg->event_ID();
344 344
                 /** @type EE_Ticket $ticket */
345
-                $ticket          = $reg->get_first_related('Ticket');
345
+                $ticket = $reg->get_first_related('Ticket');
346 346
                 $attendee = $reg->attendee();
347 347
                 $event = $reg->event();
348 348
                 // if none of the following entities are available, then we can't setup other data reliably,
349 349
                 // so let's just skip.
350
-                if (! $ticket instanceof EE_Ticket
350
+                if ( ! $ticket instanceof EE_Ticket
351 351
                     || ! $attendee instanceof EE_Attendee
352 352
                     || ! $event instanceof EE_Event
353 353
                 ) {
@@ -355,67 +355,67 @@  discard block
 block discarded – undo
355 355
                 }
356 356
                 $relateddatetime = $ticket->datetimes();
357 357
                 $total_ticket_count++;
358
-                $tickets[ $ticket->ID() ]['ticket']                        = $ticket;
359
-                $tickets[ $ticket->ID() ]['count']                         = is_array($tickets[ $ticket->ID() ])
360
-                                                                           && isset($tickets[ $ticket->ID() ]['count'])
361
-                    ? $tickets[ $ticket->ID() ]['count'] + 1
358
+                $tickets[$ticket->ID()]['ticket']                        = $ticket;
359
+                $tickets[$ticket->ID()]['count']                         = is_array($tickets[$ticket->ID()])
360
+                                                                           && isset($tickets[$ticket->ID()]['count'])
361
+                    ? $tickets[$ticket->ID()]['count'] + 1
362 362
                     : 1;
363
-                $tickets[ $ticket->ID() ]['att_objs'][ $attendee->ID() ] = $attendee;
364
-                $tickets[ $ticket->ID() ]['dtt_objs']                      = $relateddatetime;
365
-                $tickets[ $ticket->ID() ]['reg_objs'][ $reg->ID() ]          = $reg;
366
-                $tickets[ $ticket->ID() ]['EE_Event']                      = $event;
367
-                $evtcache[ $evt_id ]                                       = $event;
368
-                $eventsetup[ $evt_id ]['reg_objs'][ $reg->ID() ]             = $reg;
369
-                $eventsetup[ $evt_id ]['tkt_objs'][ $ticket->ID() ]          = $ticket;
370
-                $eventsetup[ $evt_id ]['att_objs'][ $attendee->ID() ]    = $attendee;
371
-                $event_attendee_count[ $evt_id ]                           = isset($event_attendee_count[ $evt_id ])
372
-                    ? $event_attendee_count[ $evt_id ] + 1
363
+                $tickets[$ticket->ID()]['att_objs'][$attendee->ID()] = $attendee;
364
+                $tickets[$ticket->ID()]['dtt_objs']                      = $relateddatetime;
365
+                $tickets[$ticket->ID()]['reg_objs'][$reg->ID()]          = $reg;
366
+                $tickets[$ticket->ID()]['EE_Event']                      = $event;
367
+                $evtcache[$evt_id]                                       = $event;
368
+                $eventsetup[$evt_id]['reg_objs'][$reg->ID()]             = $reg;
369
+                $eventsetup[$evt_id]['tkt_objs'][$ticket->ID()]          = $ticket;
370
+                $eventsetup[$evt_id]['att_objs'][$attendee->ID()] = $attendee;
371
+                $event_attendee_count[$evt_id]                           = isset($event_attendee_count[$evt_id])
372
+                    ? $event_attendee_count[$evt_id] + 1
373 373
                     : 0;
374
-                $attendees[ $reg->attendee_ID() ]['line_ref'][]            = $evt_id;
375
-                $attendees[ $reg->attendee_ID() ]['att_obj']               = $attendee;
376
-                $attendees[ $reg->attendee_ID() ]['reg_objs'][ $reg->ID() ]  = $reg;
374
+                $attendees[$reg->attendee_ID()]['line_ref'][]            = $evt_id;
375
+                $attendees[$reg->attendee_ID()]['att_obj']               = $attendee;
376
+                $attendees[$reg->attendee_ID()]['reg_objs'][$reg->ID()]  = $reg;
377 377
                 // $attendees[ $reg->attendee_ID() ]['registration_id'] = $reg->ID();
378
-                $attendees[ $reg->attendee_ID() ]['attendee_email']          = $attendee->email();
379
-                $attendees[ $reg->attendee_ID() ]['tkt_objs'][ $ticket->ID() ] = $ticket;
380
-                $attendees[ $reg->attendee_ID() ]['evt_objs'][ $evt_id ]       = $event;
378
+                $attendees[$reg->attendee_ID()]['attendee_email']          = $attendee->email();
379
+                $attendees[$reg->attendee_ID()]['tkt_objs'][$ticket->ID()] = $ticket;
380
+                $attendees[$reg->attendee_ID()]['evt_objs'][$evt_id]       = $event;
381 381
 
382 382
                 // registrations
383
-                $registrations[ $reg->ID() ]['tkt_obj'] = $ticket;
384
-                $registrations[ $reg->ID() ]['evt_obj'] = $event;
385
-                $registrations[ $reg->ID() ]['reg_obj'] = $reg;
386
-                $registrations[ $reg->ID() ]['att_obj'] = $attendee;
383
+                $registrations[$reg->ID()]['tkt_obj'] = $ticket;
384
+                $registrations[$reg->ID()]['evt_obj'] = $event;
385
+                $registrations[$reg->ID()]['reg_obj'] = $reg;
386
+                $registrations[$reg->ID()]['att_obj'] = $attendee;
387 387
 
388 388
                 // set up answer objects
389 389
                 $rel_ans = $reg->get_many_related('Answer');
390 390
                 foreach ($rel_ans as $ansid => $answer) {
391
-                    if (! isset($questions[ $ansid ])) {
392
-                        $questions[ $ansid ] = $answer->get_first_related('Question');
391
+                    if ( ! isset($questions[$ansid])) {
392
+                        $questions[$ansid] = $answer->get_first_related('Question');
393 393
                     }
394
-                    $answers[ $ansid ]                               = $answer;
395
-                    $registrations[ $reg->ID() ]['ans_objs'][ $ansid ] = $answer;
394
+                    $answers[$ansid] = $answer;
395
+                    $registrations[$reg->ID()]['ans_objs'][$ansid] = $answer;
396 396
                 }
397 397
                 /**
398 398
                  * @var int $dtt_id
399 399
                  * @var EE_Datetime $datetime
400 400
                  */
401 401
                 foreach ($relateddatetime as $dtt_id => $datetime) {
402
-                    $eventsetup[ $evt_id ]['dtt_objs'][ $dtt_id ]       = $datetime;
403
-                    $registrations[ $reg->ID() ]['dtt_objs'][ $dtt_id ] = $datetime;
402
+                    $eventsetup[$evt_id]['dtt_objs'][$dtt_id]       = $datetime;
403
+                    $registrations[$reg->ID()]['dtt_objs'][$dtt_id] = $datetime;
404 404
 
405
-                    if (isset($datetimes[ $dtt_id ])) {
405
+                    if (isset($datetimes[$dtt_id])) {
406 406
                         continue; // already have this info in the datetimes array.
407 407
                     }
408 408
 
409
-                    $datetimes[ $dtt_id ]['tkt_objs'][]           = $ticket;
410
-                    $datetimes[ $dtt_id ]['datetime']             = $datetime;
411
-                    $datetimes[ $dtt_id ]['evt_objs'][ $evt_id ]    = $event;
412
-                    $datetimes[ $dtt_id ]['reg_objs'][ $reg->ID() ] = $reg;
409
+                    $datetimes[$dtt_id]['tkt_objs'][]           = $ticket;
410
+                    $datetimes[$dtt_id]['datetime']             = $datetime;
411
+                    $datetimes[$dtt_id]['evt_objs'][$evt_id]    = $event;
412
+                    $datetimes[$dtt_id]['reg_objs'][$reg->ID()] = $reg;
413 413
                 }
414 414
             }
415 415
 
416 416
             // let's loop through the unique event=>reg items and setup data on them
417 417
 
418
-            if (! empty($eventsetup)) {
418
+            if ( ! empty($eventsetup)) {
419 419
                 foreach ($eventsetup as $evt_id => $items) {
420 420
                     $ticket_line_items_for_event = array();
421 421
                     if ($this->txn instanceof EE_Transaction) {
@@ -429,11 +429,11 @@  discard block
 block discarded – undo
429 429
                             )
430 430
                         );
431 431
                     }
432
-                    $events[ $evt_id ] = array(
432
+                    $events[$evt_id] = array(
433 433
                         'ID'              => $evt_id,
434
-                        'event'           => $evtcache[ $evt_id ],
435
-                        'name'            => $evtcache[ $evt_id ] instanceof EE_Event ? $evtcache[ $evt_id ]->name() : '',
436
-                        'total_attendees' => $event_attendee_count[ $evt_id ],
434
+                        'event'           => $evtcache[$evt_id],
435
+                        'name'            => $evtcache[$evt_id] instanceof EE_Event ? $evtcache[$evt_id]->name() : '',
436
+                        'total_attendees' => $event_attendee_count[$evt_id],
437 437
                         'reg_objs'        => $items['reg_objs'],
438 438
                         'tkt_objs'        => $items['tkt_objs'],
439 439
                         'att_objs'        => $items['att_objs'],
@@ -444,11 +444,11 @@  discard block
 block discarded – undo
444 444
                     // make sure the tickets have the line items setup for them.
445 445
                     foreach ($ticket_line_items_for_event as $line_id => $line_item) {
446 446
                         // only add the ticket line items if we already have this ticket in the $tickets array.
447
-                        if ($line_item instanceof EE_Line_Item && isset($tickets[ $line_item->ticket()->ID() ])) {
448
-                            $tickets[ $line_item->ticket()->ID() ]['line_item']      = $line_item;
449
-                            $tickets[ $line_item->ticket()->ID() ]['sub_line_items'] = $line_item->children();
450
-                            $line_items[ $line_item->ID() ]['children']              = $line_item->children();
451
-                            $line_items[ $line_item->ID() ]['EE_Ticket']             = $line_item->ticket();
447
+                        if ($line_item instanceof EE_Line_Item && isset($tickets[$line_item->ticket()->ID()])) {
448
+                            $tickets[$line_item->ticket()->ID()]['line_item']      = $line_item;
449
+                            $tickets[$line_item->ticket()->ID()]['sub_line_items'] = $line_item->children();
450
+                            $line_items[$line_item->ID()]['children']              = $line_item->children();
451
+                            $line_items[$line_item->ID()]['EE_Ticket']             = $line_item->ticket();
452 452
                         }
453 453
                     }
454 454
                 }
Please login to merge, or discard this patch.