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

CancelRegistrationService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
namespace EventEspresso\core\domain\services\registration;
3
4
use EventEspresso\core\domain\services\ticket\CancelTicketLineItemService;
5
6
if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
    exit('No direct script access allowed');
8
}
9
10
11
12
/**
13
 * Class CancelRegistrationService
14
 * Decrements and cancels a registration's related ticket line item quantity,
15
 * then sets the registration status to EEM_Registration::status_id_cancelled
16
 *
17
 * @package       Event Espresso
18
 * @author        Brent Christensen
19
 * @since         4.9.1
20
 */
21
class CancelRegistrationService
22
{
23
24
    /**
25
     * @var CancelTicketLineItemService $cancel_ticket_line_item_service
26
     */
27
    private $cancel_ticket_line_item_service;
28
29
30
31
    /**
32
     * Command constructor
33
     *
34
     * @param CancelTicketLineItemService $cancel_ticket_line_item_service
35
     */
36
    public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
37
    {
38
        $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
39
    }
40
41
42
43
    /**
44
     * @param \EE_Registration $registration
45
     * @throws \EE_Error
46
     */
47
    public function cancelRegistrationAndTicketLineItem(\EE_Registration $registration)
48
    {
49
        // first cancel the original line item for the registration's ticket
50
        $this->cancel_ticket_line_item_service->forRegistration($registration);
51
        $this->cancelRegistrationOnly($registration);
52
    }
53
54
55
56
    /**
57
     * @param \EE_Registration $registration
58
     * @throws \EE_Error
59
     */
60
    public function cancelRegistrationOnly(\EE_Registration $registration)
61
    {
62
        // now cancel the registration itself
63
        $registration->set_status(\EEM_Registration::status_id_cancelled);
64
        $registration->save();
65
    }
66
67
68
69
}
70
// End of file CancelRegistrationService.php
71
// Location: /CancelRegistrationService.php