@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ) { |
80 | 80 | // grab the related ticket object for this line_item |
81 | 81 | $this->ticket = $ticket_line_item->ticket(); |
82 | - if (! $this->ticket instanceof EE_Ticket) { |
|
82 | + if ( ! $this->ticket instanceof EE_Ticket) { |
|
83 | 83 | throw new InvalidEntityException( |
84 | 84 | is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
85 | 85 | 'EE_Ticket', |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function getCapCheck() |
105 | 105 | { |
106 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
106 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
107 | 107 | return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
108 | 108 | } |
109 | 109 | return $this->cap_check; |
@@ -24,151 +24,151 @@ |
||
24 | 24 | class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @var EE_Transaction $transaction |
|
29 | - */ |
|
30 | - private $transaction; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var EE_Ticket $ticket |
|
34 | - */ |
|
35 | - private $ticket; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Line_Item $ticket_line_item |
|
39 | - */ |
|
40 | - private $ticket_line_item; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var int $reg_count |
|
44 | - */ |
|
45 | - private $reg_count; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var int $reg_group_size |
|
49 | - */ |
|
50 | - private $reg_group_size; |
|
51 | - |
|
52 | - /** |
|
53 | - * @var string $reg_status |
|
54 | - */ |
|
55 | - private $reg_status; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var EE_Registration $registration |
|
59 | - */ |
|
60 | - protected $registration; |
|
61 | - |
|
62 | - |
|
63 | - /** |
|
64 | - * CreateRegistrationCommand constructor. |
|
65 | - * |
|
66 | - * @param EE_Transaction $transaction |
|
67 | - * @param EE_Line_Item $ticket_line_item |
|
68 | - * @param int $reg_count |
|
69 | - * @param int $reg_group_size |
|
70 | - * @param string $reg_status |
|
71 | - * @throws InvalidEntityException |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - EE_Transaction $transaction, |
|
75 | - EE_Line_Item $ticket_line_item, |
|
76 | - $reg_count = 1, |
|
77 | - $reg_group_size = 0, |
|
78 | - $reg_status = EEM_Registration::status_id_incomplete |
|
79 | - ) { |
|
80 | - // grab the related ticket object for this line_item |
|
81 | - $this->ticket = $ticket_line_item->ticket(); |
|
82 | - if (! $this->ticket instanceof EE_Ticket) { |
|
83 | - throw new InvalidEntityException( |
|
84 | - is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
85 | - 'EE_Ticket', |
|
86 | - sprintf( |
|
87 | - esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
88 | - $ticket_line_item->ID() |
|
89 | - ) |
|
90 | - ); |
|
91 | - } |
|
92 | - $this->transaction = $transaction; |
|
93 | - $this->ticket_line_item = $ticket_line_item; |
|
94 | - $this->reg_count = absint($reg_count); |
|
95 | - $this->reg_group_size = absint($reg_group_size); |
|
96 | - $this->reg_status = $reg_status; |
|
97 | - } |
|
98 | - |
|
99 | - |
|
100 | - /** |
|
101 | - * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
102 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
103 | - */ |
|
104 | - public function getCapCheck() |
|
105 | - { |
|
106 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
107 | - return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
108 | - } |
|
109 | - return $this->cap_check; |
|
110 | - } |
|
111 | - |
|
112 | - |
|
113 | - /** |
|
114 | - * @return EE_Transaction |
|
115 | - */ |
|
116 | - public function transaction() |
|
117 | - { |
|
118 | - return $this->transaction; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return EE_Ticket |
|
124 | - */ |
|
125 | - public function ticket() |
|
126 | - { |
|
127 | - return $this->ticket; |
|
128 | - } |
|
129 | - |
|
130 | - |
|
131 | - /** |
|
132 | - * @return EE_Line_Item |
|
133 | - */ |
|
134 | - public function ticketLineItem() |
|
135 | - { |
|
136 | - return $this->ticket_line_item; |
|
137 | - } |
|
138 | - |
|
139 | - |
|
140 | - /** |
|
141 | - * @return int |
|
142 | - */ |
|
143 | - public function regCount() |
|
144 | - { |
|
145 | - return $this->reg_count; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * @return int |
|
151 | - */ |
|
152 | - public function regGroupSize() |
|
153 | - { |
|
154 | - return $this->reg_group_size; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function regStatus() |
|
162 | - { |
|
163 | - return $this->reg_status; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * @return EE_Registration |
|
169 | - */ |
|
170 | - public function registration() |
|
171 | - { |
|
172 | - return $this->registration; |
|
173 | - } |
|
27 | + /** |
|
28 | + * @var EE_Transaction $transaction |
|
29 | + */ |
|
30 | + private $transaction; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var EE_Ticket $ticket |
|
34 | + */ |
|
35 | + private $ticket; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Line_Item $ticket_line_item |
|
39 | + */ |
|
40 | + private $ticket_line_item; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var int $reg_count |
|
44 | + */ |
|
45 | + private $reg_count; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var int $reg_group_size |
|
49 | + */ |
|
50 | + private $reg_group_size; |
|
51 | + |
|
52 | + /** |
|
53 | + * @var string $reg_status |
|
54 | + */ |
|
55 | + private $reg_status; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var EE_Registration $registration |
|
59 | + */ |
|
60 | + protected $registration; |
|
61 | + |
|
62 | + |
|
63 | + /** |
|
64 | + * CreateRegistrationCommand constructor. |
|
65 | + * |
|
66 | + * @param EE_Transaction $transaction |
|
67 | + * @param EE_Line_Item $ticket_line_item |
|
68 | + * @param int $reg_count |
|
69 | + * @param int $reg_group_size |
|
70 | + * @param string $reg_status |
|
71 | + * @throws InvalidEntityException |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + EE_Transaction $transaction, |
|
75 | + EE_Line_Item $ticket_line_item, |
|
76 | + $reg_count = 1, |
|
77 | + $reg_group_size = 0, |
|
78 | + $reg_status = EEM_Registration::status_id_incomplete |
|
79 | + ) { |
|
80 | + // grab the related ticket object for this line_item |
|
81 | + $this->ticket = $ticket_line_item->ticket(); |
|
82 | + if (! $this->ticket instanceof EE_Ticket) { |
|
83 | + throw new InvalidEntityException( |
|
84 | + is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket), |
|
85 | + 'EE_Ticket', |
|
86 | + sprintf( |
|
87 | + esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'), |
|
88 | + $ticket_line_item->ID() |
|
89 | + ) |
|
90 | + ); |
|
91 | + } |
|
92 | + $this->transaction = $transaction; |
|
93 | + $this->ticket_line_item = $ticket_line_item; |
|
94 | + $this->reg_count = absint($reg_count); |
|
95 | + $this->reg_group_size = absint($reg_group_size); |
|
96 | + $this->reg_status = $reg_status; |
|
97 | + } |
|
98 | + |
|
99 | + |
|
100 | + /** |
|
101 | + * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface |
|
102 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
103 | + */ |
|
104 | + public function getCapCheck() |
|
105 | + { |
|
106 | + if (! $this->cap_check instanceof CapCheckInterface) { |
|
107 | + return new CapCheck('ee_edit_registrations', 'create_new_registration'); |
|
108 | + } |
|
109 | + return $this->cap_check; |
|
110 | + } |
|
111 | + |
|
112 | + |
|
113 | + /** |
|
114 | + * @return EE_Transaction |
|
115 | + */ |
|
116 | + public function transaction() |
|
117 | + { |
|
118 | + return $this->transaction; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return EE_Ticket |
|
124 | + */ |
|
125 | + public function ticket() |
|
126 | + { |
|
127 | + return $this->ticket; |
|
128 | + } |
|
129 | + |
|
130 | + |
|
131 | + /** |
|
132 | + * @return EE_Line_Item |
|
133 | + */ |
|
134 | + public function ticketLineItem() |
|
135 | + { |
|
136 | + return $this->ticket_line_item; |
|
137 | + } |
|
138 | + |
|
139 | + |
|
140 | + /** |
|
141 | + * @return int |
|
142 | + */ |
|
143 | + public function regCount() |
|
144 | + { |
|
145 | + return $this->reg_count; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * @return int |
|
151 | + */ |
|
152 | + public function regGroupSize() |
|
153 | + { |
|
154 | + return $this->reg_group_size; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function regStatus() |
|
162 | + { |
|
163 | + return $this->reg_status; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * @return EE_Registration |
|
169 | + */ |
|
170 | + public function registration() |
|
171 | + { |
|
172 | + return $this->registration; |
|
173 | + } |
|
174 | 174 | } |
@@ -15,22 +15,22 @@ |
||
15 | 15 | class AddActionHook implements CommandBusMiddlewareInterface |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @param CommandInterface $command |
|
20 | - * @param Closure $next |
|
21 | - * @return mixed |
|
22 | - */ |
|
23 | - public function handle(CommandInterface $command, Closure $next) |
|
24 | - { |
|
25 | - do_action( |
|
26 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
27 | - $command |
|
28 | - ); |
|
29 | - $results = $next($command); |
|
30 | - do_action( |
|
31 | - 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
32 | - $command |
|
33 | - ); |
|
34 | - return $results; |
|
35 | - } |
|
18 | + /** |
|
19 | + * @param CommandInterface $command |
|
20 | + * @param Closure $next |
|
21 | + * @return mixed |
|
22 | + */ |
|
23 | + public function handle(CommandInterface $command, Closure $next) |
|
24 | + { |
|
25 | + do_action( |
|
26 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before', |
|
27 | + $command |
|
28 | + ); |
|
29 | + $results = $next($command); |
|
30 | + do_action( |
|
31 | + 'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after', |
|
32 | + $command |
|
33 | + ); |
|
34 | + return $results; |
|
35 | + } |
|
36 | 36 | } |
@@ -24,37 +24,37 @@ |
||
24 | 24 | class CapChecker implements CommandBusMiddlewareInterface |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * @type CapabilitiesCheckerInterface $capabilities_checker |
|
29 | - */ |
|
30 | - private $capabilities_checker; |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * CapChecker constructor |
|
35 | - * |
|
36 | - * @param CapabilitiesCheckerInterface $capabilities_checker |
|
37 | - */ |
|
38 | - public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
39 | - { |
|
40 | - $this->capabilities_checker = $capabilities_checker; |
|
41 | - } |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @param CommandInterface $command |
|
46 | - * @param Closure $next |
|
47 | - * @return mixed |
|
48 | - * @throws InvalidClassException |
|
49 | - * @throws InsufficientPermissionsException |
|
50 | - */ |
|
51 | - public function handle(CommandInterface $command, Closure $next) |
|
52 | - { |
|
53 | - if ($command instanceof CommandRequiresCapCheckInterface) { |
|
54 | - $this->capabilities_checker->processCapCheck( |
|
55 | - $command->getCapCheck() |
|
56 | - ); |
|
57 | - } |
|
58 | - return $next($command); |
|
59 | - } |
|
27 | + /** |
|
28 | + * @type CapabilitiesCheckerInterface $capabilities_checker |
|
29 | + */ |
|
30 | + private $capabilities_checker; |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * CapChecker constructor |
|
35 | + * |
|
36 | + * @param CapabilitiesCheckerInterface $capabilities_checker |
|
37 | + */ |
|
38 | + public function __construct(CapabilitiesCheckerInterface $capabilities_checker) |
|
39 | + { |
|
40 | + $this->capabilities_checker = $capabilities_checker; |
|
41 | + } |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @param CommandInterface $command |
|
46 | + * @param Closure $next |
|
47 | + * @return mixed |
|
48 | + * @throws InvalidClassException |
|
49 | + * @throws InsufficientPermissionsException |
|
50 | + */ |
|
51 | + public function handle(CommandInterface $command, Closure $next) |
|
52 | + { |
|
53 | + if ($command instanceof CommandRequiresCapCheckInterface) { |
|
54 | + $this->capabilities_checker->processCapCheck( |
|
55 | + $command->getCapCheck() |
|
56 | + ); |
|
57 | + } |
|
58 | + return $next($command); |
|
59 | + } |
|
60 | 60 | } |
@@ -16,112 +16,112 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Transaction $transaction |
|
21 | - */ |
|
22 | - private $transaction; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket $ticket |
|
26 | - */ |
|
27 | - private $ticket; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var \EE_Line_Item $ticket_line_item |
|
31 | - */ |
|
32 | - protected $ticket_line_item; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var int $quantity |
|
36 | - */ |
|
37 | - protected $quantity; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * @param \EE_Registration $registration |
|
42 | - * @param int $quantity |
|
43 | - */ |
|
44 | - public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
45 | - { |
|
46 | - new self( |
|
47 | - $registration->transaction(), |
|
48 | - $registration->ticket(), |
|
49 | - 1, |
|
50 | - $registration->ticket_line_item() |
|
51 | - ); |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param \EE_Line_Item $ticket_line_item |
|
57 | - * @param int $quantity |
|
58 | - */ |
|
59 | - public static function fromTicketLineItem( |
|
60 | - \EE_Line_Item $ticket_line_item, |
|
61 | - $quantity = 1 |
|
62 | - ) { |
|
63 | - new self( |
|
64 | - $ticket_line_item->transaction(), |
|
65 | - $ticket_line_item->ticket(), |
|
66 | - $quantity, |
|
67 | - $ticket_line_item |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - /** |
|
73 | - * CancelTicketLineItemCommand constructor. |
|
74 | - * |
|
75 | - * @param \EE_Transaction $transaction |
|
76 | - * @param \EE_Ticket $ticket |
|
77 | - * @param int $quantity |
|
78 | - * @param \EE_Line_Item $ticket_line_item |
|
79 | - */ |
|
80 | - public function __construct( |
|
81 | - \EE_Transaction $transaction, |
|
82 | - \EE_Ticket $ticket, |
|
83 | - $quantity = 1, |
|
84 | - \EE_Line_Item $ticket_line_item = null |
|
85 | - ) { |
|
86 | - $this->transaction = $transaction; |
|
87 | - $this->ticket = $ticket; |
|
88 | - $this->quantity = min(1, absint($quantity)); |
|
89 | - $this->ticket_line_item = $ticket_line_item; |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * @return \EE_Transaction |
|
95 | - */ |
|
96 | - public function transaction() |
|
97 | - { |
|
98 | - return $this->transaction; |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @return \EE_Ticket |
|
104 | - */ |
|
105 | - public function ticket() |
|
106 | - { |
|
107 | - return $this->ticket; |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return \EE_Line_Item |
|
113 | - */ |
|
114 | - public function ticketLineItem() |
|
115 | - { |
|
116 | - return $this->ticket_line_item; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @return int |
|
122 | - */ |
|
123 | - public function quantity() |
|
124 | - { |
|
125 | - return $this->quantity; |
|
126 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Transaction $transaction |
|
21 | + */ |
|
22 | + private $transaction; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket $ticket |
|
26 | + */ |
|
27 | + private $ticket; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var \EE_Line_Item $ticket_line_item |
|
31 | + */ |
|
32 | + protected $ticket_line_item; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var int $quantity |
|
36 | + */ |
|
37 | + protected $quantity; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * @param \EE_Registration $registration |
|
42 | + * @param int $quantity |
|
43 | + */ |
|
44 | + public static function fromRegistration(\EE_Registration $registration, $quantity = 1) |
|
45 | + { |
|
46 | + new self( |
|
47 | + $registration->transaction(), |
|
48 | + $registration->ticket(), |
|
49 | + 1, |
|
50 | + $registration->ticket_line_item() |
|
51 | + ); |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param \EE_Line_Item $ticket_line_item |
|
57 | + * @param int $quantity |
|
58 | + */ |
|
59 | + public static function fromTicketLineItem( |
|
60 | + \EE_Line_Item $ticket_line_item, |
|
61 | + $quantity = 1 |
|
62 | + ) { |
|
63 | + new self( |
|
64 | + $ticket_line_item->transaction(), |
|
65 | + $ticket_line_item->ticket(), |
|
66 | + $quantity, |
|
67 | + $ticket_line_item |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + /** |
|
73 | + * CancelTicketLineItemCommand constructor. |
|
74 | + * |
|
75 | + * @param \EE_Transaction $transaction |
|
76 | + * @param \EE_Ticket $ticket |
|
77 | + * @param int $quantity |
|
78 | + * @param \EE_Line_Item $ticket_line_item |
|
79 | + */ |
|
80 | + public function __construct( |
|
81 | + \EE_Transaction $transaction, |
|
82 | + \EE_Ticket $ticket, |
|
83 | + $quantity = 1, |
|
84 | + \EE_Line_Item $ticket_line_item = null |
|
85 | + ) { |
|
86 | + $this->transaction = $transaction; |
|
87 | + $this->ticket = $ticket; |
|
88 | + $this->quantity = min(1, absint($quantity)); |
|
89 | + $this->ticket_line_item = $ticket_line_item; |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * @return \EE_Transaction |
|
95 | + */ |
|
96 | + public function transaction() |
|
97 | + { |
|
98 | + return $this->transaction; |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @return \EE_Ticket |
|
104 | + */ |
|
105 | + public function ticket() |
|
106 | + { |
|
107 | + return $this->ticket; |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return \EE_Line_Item |
|
113 | + */ |
|
114 | + public function ticketLineItem() |
|
115 | + { |
|
116 | + return $this->ticket_line_item; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @return int |
|
122 | + */ |
|
123 | + public function quantity() |
|
124 | + { |
|
125 | + return $this->quantity; |
|
126 | + } |
|
127 | 127 | } |
@@ -16,77 +16,77 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Transaction $transaction |
|
21 | - */ |
|
22 | - private $transaction; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var \EE_Ticket $ticket |
|
26 | - */ |
|
27 | - private $ticket; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var int $quantity |
|
31 | - */ |
|
32 | - private $quantity = 1; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var \EE_Line_Item $ticket_line_item |
|
36 | - */ |
|
37 | - protected $ticket_line_item; |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * CreateTicketLineItemCommand constructor. |
|
42 | - * |
|
43 | - * @param \EE_Transaction $transaction |
|
44 | - * @param \EE_Ticket $ticket |
|
45 | - * @param int $quantity |
|
46 | - */ |
|
47 | - public function __construct( |
|
48 | - \EE_Transaction $transaction, |
|
49 | - \EE_Ticket $ticket, |
|
50 | - $quantity = 1 |
|
51 | - ) { |
|
52 | - $this->transaction = $transaction; |
|
53 | - $this->ticket = $ticket; |
|
54 | - $this->quantity = $quantity; |
|
55 | - } |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * @return \EE_Transaction |
|
60 | - */ |
|
61 | - public function transaction() |
|
62 | - { |
|
63 | - return $this->transaction; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return \EE_Ticket |
|
69 | - */ |
|
70 | - public function ticket() |
|
71 | - { |
|
72 | - return $this->ticket; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return int |
|
78 | - */ |
|
79 | - public function quantity() |
|
80 | - { |
|
81 | - return $this->quantity; |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * @return \EE_Line_Item |
|
87 | - */ |
|
88 | - public function ticketLineItem() |
|
89 | - { |
|
90 | - return $this->ticket_line_item; |
|
91 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Transaction $transaction |
|
21 | + */ |
|
22 | + private $transaction; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var \EE_Ticket $ticket |
|
26 | + */ |
|
27 | + private $ticket; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var int $quantity |
|
31 | + */ |
|
32 | + private $quantity = 1; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var \EE_Line_Item $ticket_line_item |
|
36 | + */ |
|
37 | + protected $ticket_line_item; |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * CreateTicketLineItemCommand constructor. |
|
42 | + * |
|
43 | + * @param \EE_Transaction $transaction |
|
44 | + * @param \EE_Ticket $ticket |
|
45 | + * @param int $quantity |
|
46 | + */ |
|
47 | + public function __construct( |
|
48 | + \EE_Transaction $transaction, |
|
49 | + \EE_Ticket $ticket, |
|
50 | + $quantity = 1 |
|
51 | + ) { |
|
52 | + $this->transaction = $transaction; |
|
53 | + $this->ticket = $ticket; |
|
54 | + $this->quantity = $quantity; |
|
55 | + } |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * @return \EE_Transaction |
|
60 | + */ |
|
61 | + public function transaction() |
|
62 | + { |
|
63 | + return $this->transaction; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return \EE_Ticket |
|
69 | + */ |
|
70 | + public function ticket() |
|
71 | + { |
|
72 | + return $this->ticket; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return int |
|
78 | + */ |
|
79 | + public function quantity() |
|
80 | + { |
|
81 | + return $this->quantity; |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * @return \EE_Line_Item |
|
87 | + */ |
|
88 | + public function ticketLineItem() |
|
89 | + { |
|
90 | + return $this->ticket_line_item; |
|
91 | + } |
|
92 | 92 | } |
@@ -14,10 +14,10 @@ |
||
14 | 14 | abstract class FormHtmlFilter |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @param $html |
|
19 | - * @param EE_Form_Section_Validatable $form_section |
|
20 | - * @return string |
|
21 | - */ |
|
22 | - abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
17 | + /** |
|
18 | + * @param $html |
|
19 | + * @param EE_Form_Section_Validatable $form_section |
|
20 | + * @return string |
|
21 | + */ |
|
22 | + abstract public function filterHtml($html, EE_Form_Section_Validatable $form_section); |
|
23 | 23 | } |
@@ -7,57 +7,57 @@ |
||
7 | 7 | class ChangesIn40833 extends ChangesInBase |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * Adds hooks so requests to 4.8.29 don't have the checkin endpoints |
|
12 | - */ |
|
13 | - public function setHooks() |
|
14 | - { |
|
15 | - // set a hook to remove the checkout/checkout endpoints if the request |
|
16 | - // is for lower than 4.8.33 |
|
17 | - add_filter( |
|
18 | - 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
19 | - array($this, 'removeCheckinRoutesEarlierThan4833'), |
|
20 | - 10, |
|
21 | - 2 |
|
22 | - ); |
|
23 | - add_filter( |
|
24 | - 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return', |
|
25 | - array($this, 'dontAddHeadersFromEeNotices'), |
|
26 | - 10, |
|
27 | - 2 |
|
28 | - ); |
|
29 | - } |
|
10 | + /** |
|
11 | + * Adds hooks so requests to 4.8.29 don't have the checkin endpoints |
|
12 | + */ |
|
13 | + public function setHooks() |
|
14 | + { |
|
15 | + // set a hook to remove the checkout/checkout endpoints if the request |
|
16 | + // is for lower than 4.8.33 |
|
17 | + add_filter( |
|
18 | + 'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes', |
|
19 | + array($this, 'removeCheckinRoutesEarlierThan4833'), |
|
20 | + 10, |
|
21 | + 2 |
|
22 | + ); |
|
23 | + add_filter( |
|
24 | + 'FHEE__EventEspresso\core\libraries\rest_api\controllers\Base___get_headers_from_ee_notices__return', |
|
25 | + array($this, 'dontAddHeadersFromEeNotices'), |
|
26 | + 10, |
|
27 | + 2 |
|
28 | + ); |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * Removes the checkin and checkout endpoints from the index for requests |
|
34 | - * to api versions lowers than 4.8.33 |
|
35 | - * |
|
36 | - * @param array $routes_on_this_version |
|
37 | - * @param string $version |
|
38 | - * @return array like $routes_on_this_version |
|
39 | - */ |
|
40 | - public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version) |
|
41 | - { |
|
42 | - if ($this->appliesToVersion($version)) { |
|
43 | - unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']); |
|
44 | - } |
|
45 | - return $routes_on_this_version; |
|
46 | - } |
|
32 | + /** |
|
33 | + * Removes the checkin and checkout endpoints from the index for requests |
|
34 | + * to api versions lowers than 4.8.33 |
|
35 | + * |
|
36 | + * @param array $routes_on_this_version |
|
37 | + * @param string $version |
|
38 | + * @return array like $routes_on_this_version |
|
39 | + */ |
|
40 | + public function removeCheckinRoutesEarlierThan4833($routes_on_this_version, $version) |
|
41 | + { |
|
42 | + if ($this->appliesToVersion($version)) { |
|
43 | + unset($routes_on_this_version['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)']); |
|
44 | + } |
|
45 | + return $routes_on_this_version; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * We just added headers for notices in this version |
|
51 | - * |
|
52 | - * @param array $headers_from_ee_notices |
|
53 | - * @param string $requested_version |
|
54 | - * @return array |
|
55 | - */ |
|
56 | - public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version) |
|
57 | - { |
|
58 | - if ($this->appliesToVersion($requested_version)) { |
|
59 | - return array(); |
|
60 | - } |
|
61 | - return $headers_from_ee_notices; |
|
62 | - } |
|
49 | + /** |
|
50 | + * We just added headers for notices in this version |
|
51 | + * |
|
52 | + * @param array $headers_from_ee_notices |
|
53 | + * @param string $requested_version |
|
54 | + * @return array |
|
55 | + */ |
|
56 | + public function dontAddHeadersFromEeNotices($headers_from_ee_notices, $requested_version) |
|
57 | + { |
|
58 | + if ($this->appliesToVersion($requested_version)) { |
|
59 | + return array(); |
|
60 | + } |
|
61 | + return $headers_from_ee_notices; |
|
62 | + } |
|
63 | 63 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $force = false; |
57 | 57 | } |
58 | 58 | $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
59 | - if (! $reg instanceof EE_Registration) { |
|
59 | + if ( ! $reg instanceof EE_Registration) { |
|
60 | 60 | return $this->sendResponse( |
61 | 61 | new WP_Error( |
62 | 62 | 'rest_registration_toggle_checkin_invalid_id', |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | ) |
72 | 72 | ); |
73 | 73 | } |
74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
74 | + if ( ! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | 75 | return $this->sendResponse( |
76 | 76 | new WP_Error( |
77 | 77 | 'rest_user_cannot_toggle_checkin', |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
87 | 87 | if ($success === false) { |
88 | 88 | // check if we know they can't check in because they're not approved and we aren't forcing |
89 | - if (! $reg->is_approved() && ! $force) { |
|
89 | + if ( ! $reg->is_approved() && ! $force) { |
|
90 | 90 | // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
91 | 91 | return $this->sendResponse( |
92 | 92 | new WP_Error( |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | ), |
119 | 119 | ) |
120 | 120 | ); |
121 | - if (! $checkin instanceof EE_Checkin) { |
|
121 | + if ( ! $checkin instanceof EE_Checkin) { |
|
122 | 122 | return $this->sendResponse( |
123 | 123 | new WP_Error( |
124 | 124 | 'rest_toggle_checkin_error', |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | } |
138 | 138 | $get_request = new WP_REST_Request( |
139 | 139 | 'GET', |
140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
140 | + '/'.EED_Core_Rest_Api::ee_api_namespace.'v'.$version.'/checkins/'.$checkin->ID() |
|
141 | 141 | ); |
142 | 142 | $get_request->set_url_params( |
143 | 143 | array( |
@@ -26,124 +26,124 @@ |
||
26 | 26 | class Checkin extends Base |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * @param WP_REST_Request $request |
|
31 | - * @param string $version |
|
32 | - * @return WP_Error|WP_REST_Response |
|
33 | - */ |
|
34 | - public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
35 | - { |
|
36 | - $controller = new Checkin(); |
|
37 | - return $controller->createCheckinCheckoutObject($request, $version); |
|
38 | - } |
|
29 | + /** |
|
30 | + * @param WP_REST_Request $request |
|
31 | + * @param string $version |
|
32 | + * @return WP_Error|WP_REST_Response |
|
33 | + */ |
|
34 | + public static function handleRequestToggleCheckin(WP_REST_Request $request, $version) |
|
35 | + { |
|
36 | + $controller = new Checkin(); |
|
37 | + return $controller->createCheckinCheckoutObject($request, $version); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * Toggles whether the user is checked in or not. |
|
43 | - * |
|
44 | - * @param WP_REST_Request $request |
|
45 | - * @param string $version |
|
46 | - * @return WP_Error|WP_REST_Response |
|
47 | - */ |
|
48 | - protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
49 | - { |
|
50 | - $reg_id = $request->get_param('REG_ID'); |
|
51 | - $dtt_id = $request->get_param('DTT_ID'); |
|
52 | - $force = $request->get_param('force'); |
|
53 | - if ($force == 'true') { |
|
54 | - $force = true; |
|
55 | - } else { |
|
56 | - $force = false; |
|
57 | - } |
|
58 | - $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
59 | - if (! $reg instanceof EE_Registration) { |
|
60 | - return $this->sendResponse( |
|
61 | - new WP_Error( |
|
62 | - 'rest_registration_toggle_checkin_invalid_id', |
|
63 | - sprintf( |
|
64 | - esc_html__( |
|
65 | - 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
66 | - 'event_espresso' |
|
67 | - ), |
|
68 | - $reg_id |
|
69 | - ), |
|
70 | - array('status' => 422) |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
74 | - if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | - return $this->sendResponse( |
|
76 | - new WP_Error( |
|
77 | - 'rest_user_cannot_toggle_checkin', |
|
78 | - sprintf( |
|
79 | - esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
80 | - $reg_id |
|
81 | - ), |
|
82 | - array('status' => 403) |
|
83 | - ) |
|
84 | - ); |
|
85 | - } |
|
86 | - $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
87 | - if ($success === false) { |
|
88 | - // check if we know they can't check in because they're not approved and we aren't forcing |
|
89 | - if (! $reg->is_approved() && ! $force) { |
|
90 | - // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
91 | - return $this->sendResponse( |
|
92 | - new WP_Error( |
|
93 | - 'rest_toggle_checkin_failed', |
|
94 | - esc_html__( |
|
95 | - // @codingStandardsIgnoreStart |
|
96 | - 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
97 | - // @codingStandardsIgnoreEnd |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ) |
|
101 | - ); |
|
102 | - } |
|
103 | - return $this->sendResponse( |
|
104 | - new WP_Error( |
|
105 | - 'rest_toggle_checkin_failed_not_forceable', |
|
106 | - esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
107 | - ) |
|
108 | - ); |
|
109 | - } |
|
110 | - $checkin = EEM_Checkin::instance()->get_one( |
|
111 | - array( |
|
112 | - array( |
|
113 | - 'REG_ID' => $reg_id, |
|
114 | - 'DTT_ID' => $dtt_id, |
|
115 | - ), |
|
116 | - 'order_by' => array( |
|
117 | - 'CHK_timestamp' => 'DESC', |
|
118 | - ), |
|
119 | - ) |
|
120 | - ); |
|
121 | - if (! $checkin instanceof EE_Checkin) { |
|
122 | - return $this->sendResponse( |
|
123 | - new WP_Error( |
|
124 | - 'rest_toggle_checkin_error', |
|
125 | - sprintf( |
|
126 | - esc_html__( |
|
127 | - // @codingStandardsIgnoreStart |
|
128 | - 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
129 | - // @codingStandardsIgnoreEnd |
|
130 | - 'event_espresso' |
|
131 | - ), |
|
132 | - $reg_id, |
|
133 | - $dtt_id |
|
134 | - ) |
|
135 | - ) |
|
136 | - ); |
|
137 | - } |
|
138 | - $get_request = new WP_REST_Request( |
|
139 | - 'GET', |
|
140 | - '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
141 | - ); |
|
142 | - $get_request->set_url_params( |
|
143 | - array( |
|
144 | - 'id' => $checkin->ID(), |
|
145 | - ) |
|
146 | - ); |
|
147 | - return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
148 | - } |
|
41 | + /** |
|
42 | + * Toggles whether the user is checked in or not. |
|
43 | + * |
|
44 | + * @param WP_REST_Request $request |
|
45 | + * @param string $version |
|
46 | + * @return WP_Error|WP_REST_Response |
|
47 | + */ |
|
48 | + protected function createCheckinCheckoutObject(WP_REST_Request $request, $version) |
|
49 | + { |
|
50 | + $reg_id = $request->get_param('REG_ID'); |
|
51 | + $dtt_id = $request->get_param('DTT_ID'); |
|
52 | + $force = $request->get_param('force'); |
|
53 | + if ($force == 'true') { |
|
54 | + $force = true; |
|
55 | + } else { |
|
56 | + $force = false; |
|
57 | + } |
|
58 | + $reg = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
59 | + if (! $reg instanceof EE_Registration) { |
|
60 | + return $this->sendResponse( |
|
61 | + new WP_Error( |
|
62 | + 'rest_registration_toggle_checkin_invalid_id', |
|
63 | + sprintf( |
|
64 | + esc_html__( |
|
65 | + 'You cannot checkin registration with ID %1$s because it doesn\'t exist.', |
|
66 | + 'event_espresso' |
|
67 | + ), |
|
68 | + $reg_id |
|
69 | + ), |
|
70 | + array('status' => 422) |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | + if (! EE_Capabilities::instance()->current_user_can('ee_edit_checkin', 'rest_api_checkin_endpoint', $reg_id)) { |
|
75 | + return $this->sendResponse( |
|
76 | + new WP_Error( |
|
77 | + 'rest_user_cannot_toggle_checkin', |
|
78 | + sprintf( |
|
79 | + esc_html__('You are not allowed to checkin registration with ID %1$s.', 'event_espresso'), |
|
80 | + $reg_id |
|
81 | + ), |
|
82 | + array('status' => 403) |
|
83 | + ) |
|
84 | + ); |
|
85 | + } |
|
86 | + $success = $reg->toggle_checkin_status($dtt_id, ! $force); |
|
87 | + if ($success === false) { |
|
88 | + // check if we know they can't check in because they're not approved and we aren't forcing |
|
89 | + if (! $reg->is_approved() && ! $force) { |
|
90 | + // rely on EE_Error::add_error messages to have been added to give more data about why it failed |
|
91 | + return $this->sendResponse( |
|
92 | + new WP_Error( |
|
93 | + 'rest_toggle_checkin_failed', |
|
94 | + esc_html__( |
|
95 | + // @codingStandardsIgnoreStart |
|
96 | + 'Registration check-in failed because the registration is not approved. You may attempt to force checking in though.', |
|
97 | + // @codingStandardsIgnoreEnd |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ) |
|
101 | + ); |
|
102 | + } |
|
103 | + return $this->sendResponse( |
|
104 | + new WP_Error( |
|
105 | + 'rest_toggle_checkin_failed_not_forceable', |
|
106 | + esc_html__('Registration checkin failed. Please see additional error data.', 'event_espresso') |
|
107 | + ) |
|
108 | + ); |
|
109 | + } |
|
110 | + $checkin = EEM_Checkin::instance()->get_one( |
|
111 | + array( |
|
112 | + array( |
|
113 | + 'REG_ID' => $reg_id, |
|
114 | + 'DTT_ID' => $dtt_id, |
|
115 | + ), |
|
116 | + 'order_by' => array( |
|
117 | + 'CHK_timestamp' => 'DESC', |
|
118 | + ), |
|
119 | + ) |
|
120 | + ); |
|
121 | + if (! $checkin instanceof EE_Checkin) { |
|
122 | + return $this->sendResponse( |
|
123 | + new WP_Error( |
|
124 | + 'rest_toggle_checkin_error', |
|
125 | + sprintf( |
|
126 | + esc_html__( |
|
127 | + // @codingStandardsIgnoreStart |
|
128 | + 'Supposedly we created a new checkin object for registration %1$s at datetime %2$s, but we can\'t find it.', |
|
129 | + // @codingStandardsIgnoreEnd |
|
130 | + 'event_espresso' |
|
131 | + ), |
|
132 | + $reg_id, |
|
133 | + $dtt_id |
|
134 | + ) |
|
135 | + ) |
|
136 | + ); |
|
137 | + } |
|
138 | + $get_request = new WP_REST_Request( |
|
139 | + 'GET', |
|
140 | + '/' . EED_Core_Rest_Api::ee_api_namespace . 'v' . $version . '/checkins/' . $checkin->ID() |
|
141 | + ); |
|
142 | + $get_request->set_url_params( |
|
143 | + array( |
|
144 | + 'id' => $checkin->ID(), |
|
145 | + ) |
|
146 | + ); |
|
147 | + return Read::handleRequestGetOne($get_request, $version, 'Checkin'); |
|
148 | + } |
|
149 | 149 | } |
@@ -13,5 +13,5 @@ |
||
13 | 13 | */ |
14 | 14 | abstract class JobHandler implements JobHandlerInterface |
15 | 15 | { |
16 | - // so far no common methods or properties |
|
16 | + // so far no common methods or properties |
|
17 | 17 | } |