Completed
Branch BUG-9871-email-validation (e62b1a)
by
unknown
350:41 queued 333:27
created

UpdateRegistrationService   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 23
rs 10
wmc 1
lcom 0
cbo 6

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateRegistrationAndTransaction() 0 14 1
1
<?php
2
namespace EventEspresso\core\domain\services\registration;
3
4
use EventEspresso\core\domain\services\DomainService;
5
6
if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
    exit('No direct script access allowed');
8
}
9
10
11
12
/**
13
 * Class UpdateRegistrationService
14
 * Description
15
 *
16
 * @package       Event Espresso
17
 * @author        Brent Christensen
18
 * @since         4.9.1
19
 */
20
class UpdateRegistrationService extends DomainService
21
{
22
23
    /**
24
     * @param \EE_Registration $registration
25
     * @return bool
26
     */
27
    public function updateRegistrationAndTransaction(\EE_Registration $registration)
28
    {
29
        $transaction = $registration->transaction();
30
        // reset transaction status back to incomplete
31
        $transaction->set_status(\EEM_Transaction::incomplete_status_code);
32
        // update transaction and all line item totals and subtotals
33
        $transaction->total_line_item()->recalculate_total_including_taxes();
34
        // maybe update status, but don't save transaction just yet
35
        $transaction->update_status_based_on_total_paid();
36
        /** @type \EE_Registration_Processor $registration_processor */
37
        $registration_processor = \EE_Registry::instance()->load_class('Registration_Processor');
38
        $registration_processor->update_registration_status_and_trigger_notifications($registration);
39
        return true;
40
    }
41
42
}
43
// End of file UpdateRegistrationService.php
44
// Location: /UpdateRegistrationService.php