|
1
|
|
|
<?php |
|
2
|
|
|
namespace EventEspresso\core\services\commands\registration; |
|
3
|
|
|
|
|
4
|
|
|
use EventEspresso\core\domain\services\ticket\CancelTicketLineItemService; |
|
5
|
|
|
use EventEspresso\core\exceptions\InvalidEntityException; |
|
6
|
|
|
use EventEspresso\core\services\commands\CommandHandler; |
|
7
|
|
|
use EventEspresso\core\services\commands\CommandInterface; |
|
8
|
|
|
|
|
9
|
|
|
if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
10
|
|
|
exit('No direct script access allowed'); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class CancelRegistrationAndTicketLineItemCommandHandler |
|
17
|
|
|
* sets registration status to cancelled and decrements the related ticket quantity |
|
18
|
|
|
* |
|
19
|
|
|
* @package Event Espresso |
|
20
|
|
|
* @author Brent Christensen |
|
21
|
|
|
* @since 4.9.0 |
|
22
|
|
|
*/ |
|
23
|
|
|
class CancelRegistrationAndTicketLineItemCommandHandler extends CommandHandler |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var CancelTicketLineItemService $cancel_ticket_line_item_service |
|
29
|
|
|
*/ |
|
30
|
|
|
private $cancel_ticket_line_item_service; |
|
31
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Command constructor |
|
36
|
|
|
* |
|
37
|
|
|
* @param CancelTicketLineItemService $cancel_ticket_line_item_service |
|
38
|
|
|
*/ |
|
39
|
|
|
public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service) |
|
40
|
|
|
{ |
|
41
|
|
|
$this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param \EventEspresso\core\services\commands\CommandInterface $command |
|
48
|
|
|
* @return boolean |
|
49
|
|
|
*/ |
|
50
|
|
|
public function handle(CommandInterface $command) |
|
51
|
|
|
{ |
|
52
|
|
|
/** @var CancelRegistrationAndTicketLineItemCommand $command */ |
|
53
|
|
|
if ( ! $command instanceof CancelRegistrationAndTicketLineItemCommand) { |
|
54
|
|
|
throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand'); |
|
55
|
|
|
} |
|
56
|
|
|
$registration = $command->registration(); |
|
57
|
|
|
$this->cancel_ticket_line_item_service->forRegistration($registration); |
|
58
|
|
|
// cancel original registration |
|
59
|
|
|
$registration->set_status(\EEM_Registration::status_id_cancelled); |
|
60
|
|
|
$registration->save(); |
|
61
|
|
|
return true; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
} |
|
67
|
|
|
// End of file CancelRegistrationAndTicketLineItemCommandHandler.php |
|
68
|
|
|
// Location: /CancelRegistrationAndTicketLineItemCommandHandler.php |