@@ -36,421 +36,421 @@ |
||
36 | 36 | class Ticket extends TypeBase |
37 | 37 | { |
38 | 38 | |
39 | - /** |
|
40 | - * Ticket constructor. |
|
41 | - * |
|
42 | - * @param EEM_Ticket $ticket_model |
|
43 | - */ |
|
44 | - public function __construct(EEM_Ticket $ticket_model) |
|
45 | - { |
|
46 | - $this->setName($this->namespace . 'Ticket'); |
|
47 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
48 | - $this->setIsCustomPostType(false); |
|
49 | - parent::__construct($ticket_model); |
|
50 | - } |
|
39 | + /** |
|
40 | + * Ticket constructor. |
|
41 | + * |
|
42 | + * @param EEM_Ticket $ticket_model |
|
43 | + */ |
|
44 | + public function __construct(EEM_Ticket $ticket_model) |
|
45 | + { |
|
46 | + $this->setName($this->namespace . 'Ticket'); |
|
47 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
48 | + $this->setIsCustomPostType(false); |
|
49 | + parent::__construct($ticket_model); |
|
50 | + } |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * @return GraphQLFieldInterface[] |
|
55 | - */ |
|
56 | - public function getFields(): array |
|
57 | - { |
|
58 | - $fields = [ |
|
59 | - new GraphQLField( |
|
60 | - 'id', |
|
61 | - ['non_null' => 'ID'], |
|
62 | - null, |
|
63 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
64 | - ), |
|
65 | - new GraphQLOutputField( |
|
66 | - 'dbId', |
|
67 | - ['non_null' => 'Int'], |
|
68 | - 'ID', |
|
69 | - esc_html__('Ticket ID', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLOutputField( |
|
72 | - 'cacheId', |
|
73 | - ['non_null' => 'String'], |
|
74 | - null, |
|
75 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLInputField( |
|
78 | - 'datetimes', |
|
79 | - ['list_of' => 'ID'], |
|
80 | - null, |
|
81 | - sprintf( |
|
82 | - '%1$s %2$s', |
|
83 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
84 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
85 | - ) |
|
86 | - ), |
|
87 | - new GraphQLField( |
|
88 | - 'description', |
|
89 | - 'String', |
|
90 | - 'description', |
|
91 | - esc_html__('Description of Ticket', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLField( |
|
94 | - 'endDate', |
|
95 | - 'String', |
|
96 | - 'end_date', |
|
97 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
98 | - [$this, 'formatDatetime'] |
|
99 | - ), |
|
100 | - new GraphQLOutputField( |
|
101 | - 'event', |
|
102 | - $this->namespace . 'Event', |
|
103 | - null, |
|
104 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
105 | - ), |
|
106 | - new GraphQLField( |
|
107 | - 'isDefault', |
|
108 | - 'Boolean', |
|
109 | - 'is_default', |
|
110 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
111 | - ), |
|
112 | - new GraphQLOutputField( |
|
113 | - 'isExpired', |
|
114 | - 'Boolean', |
|
115 | - 'is_expired', |
|
116 | - esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
117 | - ), |
|
118 | - new GraphQLOutputField( |
|
119 | - 'isFree', |
|
120 | - 'Boolean', |
|
121 | - 'is_free', |
|
122 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
123 | - ), |
|
124 | - new GraphQLOutputField( |
|
125 | - 'isOnSale', |
|
126 | - 'Boolean', |
|
127 | - 'is_on_sale', |
|
128 | - esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
129 | - ), |
|
130 | - new GraphQLOutputField( |
|
131 | - 'isPending', |
|
132 | - 'Boolean', |
|
133 | - 'is_pending', |
|
134 | - esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
135 | - ), |
|
136 | - new GraphQLField( |
|
137 | - 'isRequired', |
|
138 | - 'Boolean', |
|
139 | - 'required', |
|
140 | - esc_html__( |
|
141 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
142 | - 'event_espresso' |
|
143 | - ) |
|
144 | - ), |
|
145 | - new GraphQLOutputField( |
|
146 | - 'isSoldOut', |
|
147 | - 'Boolean', |
|
148 | - null, |
|
149 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
150 | - null, |
|
151 | - [$this, 'getIsSoldOut'] |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'isTaxable', |
|
155 | - 'Boolean', |
|
156 | - 'taxable', |
|
157 | - esc_html__( |
|
158 | - 'Flag indicating whether there is tax applied on this ticket', |
|
159 | - 'event_espresso' |
|
160 | - ) |
|
161 | - ), |
|
162 | - new GraphQLField( |
|
163 | - 'isTrashed', |
|
164 | - 'Boolean', |
|
165 | - 'deleted', |
|
166 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'max', |
|
170 | - 'Int', |
|
171 | - 'max', |
|
172 | - esc_html__( |
|
173 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - [$this, 'parseInfiniteValue'] |
|
177 | - ), |
|
178 | - new GraphQLField( |
|
179 | - 'min', |
|
180 | - 'Int', |
|
181 | - 'min', |
|
182 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
183 | - ), |
|
184 | - new GraphQLField( |
|
185 | - 'name', |
|
186 | - 'String', |
|
187 | - 'name', |
|
188 | - esc_html__('Ticket Name', 'event_espresso') |
|
189 | - ), |
|
190 | - new GraphQLField( |
|
191 | - 'order', |
|
192 | - 'Int', |
|
193 | - 'order', |
|
194 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
195 | - ), |
|
196 | - new GraphQLOutputField( |
|
197 | - 'parent', |
|
198 | - $this->name(), |
|
199 | - null, |
|
200 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
201 | - ), |
|
202 | - new GraphQLInputField( |
|
203 | - 'parent', |
|
204 | - 'ID', |
|
205 | - null, |
|
206 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
207 | - ), |
|
208 | - new GraphQLField( |
|
209 | - 'price', |
|
210 | - 'Float', |
|
211 | - 'price', |
|
212 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
213 | - ), |
|
214 | - new GraphQLInputField( |
|
215 | - 'prices', |
|
216 | - ['list_of' => 'ID'], |
|
217 | - null, |
|
218 | - sprintf( |
|
219 | - '%1$s %2$s', |
|
220 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
221 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
222 | - ) |
|
223 | - ), |
|
224 | - new GraphQLField( |
|
225 | - 'quantity', |
|
226 | - 'Int', |
|
227 | - 'qty', |
|
228 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
229 | - [$this, 'parseInfiniteValue'] |
|
230 | - ), |
|
231 | - new GraphQLOutputField( |
|
232 | - 'registrationCount', |
|
233 | - 'Int', |
|
234 | - null, |
|
235 | - esc_html__('Number of registrations for the ticket', 'event_espresso'), |
|
236 | - null, |
|
237 | - [$this, 'getRegistrationCount'] |
|
238 | - ), |
|
239 | - new GraphQLField( |
|
240 | - 'reserved', |
|
241 | - 'Int', |
|
242 | - 'reserved', |
|
243 | - esc_html__( |
|
244 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
245 | - 'event_espresso' |
|
246 | - ) |
|
247 | - ), |
|
248 | - new GraphQLField( |
|
249 | - 'reverseCalculate', |
|
250 | - 'Boolean', |
|
251 | - 'reverse_calculate', |
|
252 | - esc_html__( |
|
253 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
254 | - 'event_espresso' |
|
255 | - ) |
|
256 | - ), |
|
257 | - new GraphQLField( |
|
258 | - 'row', |
|
259 | - 'Int', |
|
260 | - 'row', |
|
261 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
262 | - ), |
|
263 | - new GraphQLField( |
|
264 | - 'sold', |
|
265 | - 'Int', |
|
266 | - 'sold', |
|
267 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
268 | - ), |
|
269 | - new GraphQLOutputField( |
|
270 | - 'status', |
|
271 | - $this->namespace . 'TicketStatusEnum', |
|
272 | - 'ticket_status', |
|
273 | - esc_html__('Ticket status', 'event_espresso') |
|
274 | - ), |
|
275 | - new GraphQLField( |
|
276 | - 'startDate', |
|
277 | - 'String', |
|
278 | - 'start_date', |
|
279 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
280 | - [$this, 'formatDatetime'] |
|
281 | - ), |
|
282 | - new GraphQLField( |
|
283 | - 'uses', |
|
284 | - 'Int', |
|
285 | - 'uses', |
|
286 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
287 | - [$this, 'parseInfiniteValue'] |
|
288 | - ), |
|
289 | - new GraphQLField( |
|
290 | - 'visibility', |
|
291 | - $this->namespace . 'TicketVisibilityEnum', |
|
292 | - 'visibility', |
|
293 | - esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
294 | - ), |
|
295 | - new GraphQLOutputField( |
|
296 | - 'wpUser', |
|
297 | - 'User', |
|
298 | - null, |
|
299 | - esc_html__('Ticket Creator', 'event_espresso') |
|
300 | - ), |
|
301 | - new GraphQLOutputField( |
|
302 | - 'userId', |
|
303 | - 'ID', |
|
304 | - null, |
|
305 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
306 | - ), |
|
307 | - new GraphQLInputField( |
|
308 | - 'wpUser', |
|
309 | - 'Int', |
|
310 | - null, |
|
311 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
312 | - ), |
|
313 | - ]; |
|
53 | + /** |
|
54 | + * @return GraphQLFieldInterface[] |
|
55 | + */ |
|
56 | + public function getFields(): array |
|
57 | + { |
|
58 | + $fields = [ |
|
59 | + new GraphQLField( |
|
60 | + 'id', |
|
61 | + ['non_null' => 'ID'], |
|
62 | + null, |
|
63 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
64 | + ), |
|
65 | + new GraphQLOutputField( |
|
66 | + 'dbId', |
|
67 | + ['non_null' => 'Int'], |
|
68 | + 'ID', |
|
69 | + esc_html__('Ticket ID', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLOutputField( |
|
72 | + 'cacheId', |
|
73 | + ['non_null' => 'String'], |
|
74 | + null, |
|
75 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLInputField( |
|
78 | + 'datetimes', |
|
79 | + ['list_of' => 'ID'], |
|
80 | + null, |
|
81 | + sprintf( |
|
82 | + '%1$s %2$s', |
|
83 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
84 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
85 | + ) |
|
86 | + ), |
|
87 | + new GraphQLField( |
|
88 | + 'description', |
|
89 | + 'String', |
|
90 | + 'description', |
|
91 | + esc_html__('Description of Ticket', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLField( |
|
94 | + 'endDate', |
|
95 | + 'String', |
|
96 | + 'end_date', |
|
97 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
98 | + [$this, 'formatDatetime'] |
|
99 | + ), |
|
100 | + new GraphQLOutputField( |
|
101 | + 'event', |
|
102 | + $this->namespace . 'Event', |
|
103 | + null, |
|
104 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
105 | + ), |
|
106 | + new GraphQLField( |
|
107 | + 'isDefault', |
|
108 | + 'Boolean', |
|
109 | + 'is_default', |
|
110 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
111 | + ), |
|
112 | + new GraphQLOutputField( |
|
113 | + 'isExpired', |
|
114 | + 'Boolean', |
|
115 | + 'is_expired', |
|
116 | + esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
117 | + ), |
|
118 | + new GraphQLOutputField( |
|
119 | + 'isFree', |
|
120 | + 'Boolean', |
|
121 | + 'is_free', |
|
122 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
123 | + ), |
|
124 | + new GraphQLOutputField( |
|
125 | + 'isOnSale', |
|
126 | + 'Boolean', |
|
127 | + 'is_on_sale', |
|
128 | + esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
129 | + ), |
|
130 | + new GraphQLOutputField( |
|
131 | + 'isPending', |
|
132 | + 'Boolean', |
|
133 | + 'is_pending', |
|
134 | + esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
135 | + ), |
|
136 | + new GraphQLField( |
|
137 | + 'isRequired', |
|
138 | + 'Boolean', |
|
139 | + 'required', |
|
140 | + esc_html__( |
|
141 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
142 | + 'event_espresso' |
|
143 | + ) |
|
144 | + ), |
|
145 | + new GraphQLOutputField( |
|
146 | + 'isSoldOut', |
|
147 | + 'Boolean', |
|
148 | + null, |
|
149 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
150 | + null, |
|
151 | + [$this, 'getIsSoldOut'] |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'isTaxable', |
|
155 | + 'Boolean', |
|
156 | + 'taxable', |
|
157 | + esc_html__( |
|
158 | + 'Flag indicating whether there is tax applied on this ticket', |
|
159 | + 'event_espresso' |
|
160 | + ) |
|
161 | + ), |
|
162 | + new GraphQLField( |
|
163 | + 'isTrashed', |
|
164 | + 'Boolean', |
|
165 | + 'deleted', |
|
166 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'max', |
|
170 | + 'Int', |
|
171 | + 'max', |
|
172 | + esc_html__( |
|
173 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + [$this, 'parseInfiniteValue'] |
|
177 | + ), |
|
178 | + new GraphQLField( |
|
179 | + 'min', |
|
180 | + 'Int', |
|
181 | + 'min', |
|
182 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
183 | + ), |
|
184 | + new GraphQLField( |
|
185 | + 'name', |
|
186 | + 'String', |
|
187 | + 'name', |
|
188 | + esc_html__('Ticket Name', 'event_espresso') |
|
189 | + ), |
|
190 | + new GraphQLField( |
|
191 | + 'order', |
|
192 | + 'Int', |
|
193 | + 'order', |
|
194 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
195 | + ), |
|
196 | + new GraphQLOutputField( |
|
197 | + 'parent', |
|
198 | + $this->name(), |
|
199 | + null, |
|
200 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
201 | + ), |
|
202 | + new GraphQLInputField( |
|
203 | + 'parent', |
|
204 | + 'ID', |
|
205 | + null, |
|
206 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
207 | + ), |
|
208 | + new GraphQLField( |
|
209 | + 'price', |
|
210 | + 'Float', |
|
211 | + 'price', |
|
212 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
213 | + ), |
|
214 | + new GraphQLInputField( |
|
215 | + 'prices', |
|
216 | + ['list_of' => 'ID'], |
|
217 | + null, |
|
218 | + sprintf( |
|
219 | + '%1$s %2$s', |
|
220 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
221 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
222 | + ) |
|
223 | + ), |
|
224 | + new GraphQLField( |
|
225 | + 'quantity', |
|
226 | + 'Int', |
|
227 | + 'qty', |
|
228 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
229 | + [$this, 'parseInfiniteValue'] |
|
230 | + ), |
|
231 | + new GraphQLOutputField( |
|
232 | + 'registrationCount', |
|
233 | + 'Int', |
|
234 | + null, |
|
235 | + esc_html__('Number of registrations for the ticket', 'event_espresso'), |
|
236 | + null, |
|
237 | + [$this, 'getRegistrationCount'] |
|
238 | + ), |
|
239 | + new GraphQLField( |
|
240 | + 'reserved', |
|
241 | + 'Int', |
|
242 | + 'reserved', |
|
243 | + esc_html__( |
|
244 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
245 | + 'event_espresso' |
|
246 | + ) |
|
247 | + ), |
|
248 | + new GraphQLField( |
|
249 | + 'reverseCalculate', |
|
250 | + 'Boolean', |
|
251 | + 'reverse_calculate', |
|
252 | + esc_html__( |
|
253 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
254 | + 'event_espresso' |
|
255 | + ) |
|
256 | + ), |
|
257 | + new GraphQLField( |
|
258 | + 'row', |
|
259 | + 'Int', |
|
260 | + 'row', |
|
261 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
262 | + ), |
|
263 | + new GraphQLField( |
|
264 | + 'sold', |
|
265 | + 'Int', |
|
266 | + 'sold', |
|
267 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
268 | + ), |
|
269 | + new GraphQLOutputField( |
|
270 | + 'status', |
|
271 | + $this->namespace . 'TicketStatusEnum', |
|
272 | + 'ticket_status', |
|
273 | + esc_html__('Ticket status', 'event_espresso') |
|
274 | + ), |
|
275 | + new GraphQLField( |
|
276 | + 'startDate', |
|
277 | + 'String', |
|
278 | + 'start_date', |
|
279 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
280 | + [$this, 'formatDatetime'] |
|
281 | + ), |
|
282 | + new GraphQLField( |
|
283 | + 'uses', |
|
284 | + 'Int', |
|
285 | + 'uses', |
|
286 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
287 | + [$this, 'parseInfiniteValue'] |
|
288 | + ), |
|
289 | + new GraphQLField( |
|
290 | + 'visibility', |
|
291 | + $this->namespace . 'TicketVisibilityEnum', |
|
292 | + 'visibility', |
|
293 | + esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
294 | + ), |
|
295 | + new GraphQLOutputField( |
|
296 | + 'wpUser', |
|
297 | + 'User', |
|
298 | + null, |
|
299 | + esc_html__('Ticket Creator', 'event_espresso') |
|
300 | + ), |
|
301 | + new GraphQLOutputField( |
|
302 | + 'userId', |
|
303 | + 'ID', |
|
304 | + null, |
|
305 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
306 | + ), |
|
307 | + new GraphQLInputField( |
|
308 | + 'wpUser', |
|
309 | + 'Int', |
|
310 | + null, |
|
311 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
312 | + ), |
|
313 | + ]; |
|
314 | 314 | |
315 | - return apply_filters( |
|
316 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
317 | - $fields, |
|
318 | - $this->name, |
|
319 | - $this->model |
|
320 | - ); |
|
321 | - } |
|
315 | + return apply_filters( |
|
316 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
317 | + $fields, |
|
318 | + $this->name, |
|
319 | + $this->model |
|
320 | + ); |
|
321 | + } |
|
322 | 322 | |
323 | 323 | |
324 | - /** |
|
325 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
326 | - * @param array $args The inputArgs on the field |
|
327 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
328 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
329 | - * @return bool |
|
330 | - * @throws Exception |
|
331 | - * @throws InvalidArgumentException |
|
332 | - * @throws InvalidDataTypeException |
|
333 | - * @throws InvalidInterfaceException |
|
334 | - * @throws ReflectionException |
|
335 | - * @throws UserError |
|
336 | - * @throws UnexpectedEntityException |
|
337 | - * @since $VID:$ |
|
338 | - */ |
|
339 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
340 | - { |
|
341 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
342 | - } |
|
324 | + /** |
|
325 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
326 | + * @param array $args The inputArgs on the field |
|
327 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
328 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
329 | + * @return bool |
|
330 | + * @throws Exception |
|
331 | + * @throws InvalidArgumentException |
|
332 | + * @throws InvalidDataTypeException |
|
333 | + * @throws InvalidInterfaceException |
|
334 | + * @throws ReflectionException |
|
335 | + * @throws UserError |
|
336 | + * @throws UnexpectedEntityException |
|
337 | + * @since $VID:$ |
|
338 | + */ |
|
339 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
340 | + { |
|
341 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
342 | + } |
|
343 | 343 | |
344 | 344 | |
345 | - /** |
|
346 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
347 | - * @param array $args The inputArgs on the field |
|
348 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
349 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
350 | - * @return bool |
|
351 | - * @throws Exception |
|
352 | - * @throws InvalidArgumentException |
|
353 | - * @throws InvalidDataTypeException |
|
354 | - * @throws InvalidInterfaceException |
|
355 | - * @throws ReflectionException |
|
356 | - * @throws UserError |
|
357 | - * @throws UnexpectedEntityException |
|
358 | - * @since $VID:$ |
|
359 | - */ |
|
360 | - public function getRegistrationCount(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): int |
|
361 | - { |
|
362 | - $active_reg_statuses = EEM_Registration::active_reg_statuses(); |
|
363 | - return $source->count_registrations( |
|
364 | - [ |
|
365 | - [ |
|
366 | - 'STS_ID' => ['IN', $active_reg_statuses], |
|
367 | - 'REG_deleted' => 0, |
|
368 | - ] |
|
369 | - ] |
|
370 | - ); |
|
371 | - } |
|
345 | + /** |
|
346 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
347 | + * @param array $args The inputArgs on the field |
|
348 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
349 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
350 | + * @return bool |
|
351 | + * @throws Exception |
|
352 | + * @throws InvalidArgumentException |
|
353 | + * @throws InvalidDataTypeException |
|
354 | + * @throws InvalidInterfaceException |
|
355 | + * @throws ReflectionException |
|
356 | + * @throws UserError |
|
357 | + * @throws UnexpectedEntityException |
|
358 | + * @since $VID:$ |
|
359 | + */ |
|
360 | + public function getRegistrationCount(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): int |
|
361 | + { |
|
362 | + $active_reg_statuses = EEM_Registration::active_reg_statuses(); |
|
363 | + return $source->count_registrations( |
|
364 | + [ |
|
365 | + [ |
|
366 | + 'STS_ID' => ['IN', $active_reg_statuses], |
|
367 | + 'REG_deleted' => 0, |
|
368 | + ] |
|
369 | + ] |
|
370 | + ); |
|
371 | + } |
|
372 | 372 | |
373 | 373 | |
374 | - /** |
|
375 | - * @param array $inputFields The mutation input fields. |
|
376 | - * @throws InvalidArgumentException |
|
377 | - * @throws ReflectionException |
|
378 | - * @throws Exception |
|
379 | - */ |
|
380 | - public function registerMutations(array $inputFields) |
|
381 | - { |
|
382 | - register_graphql_input_type( |
|
383 | - 'Update' . $this->name() . 'BaseInput', |
|
384 | - [ |
|
385 | - 'fields' => $inputFields, |
|
386 | - ] |
|
387 | - ); |
|
388 | - // Register mutation to update an entity. |
|
389 | - register_graphql_mutation( |
|
390 | - 'update' . $this->name(), |
|
391 | - [ |
|
392 | - 'inputFields' => $inputFields, |
|
393 | - 'outputFields' => [ |
|
394 | - lcfirst($this->name()) => [ |
|
395 | - 'type' => $this->name(), |
|
396 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
397 | - ], |
|
398 | - ], |
|
399 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
400 | - ] |
|
401 | - ); |
|
402 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
403 | - // Register mutation to update an entity. |
|
404 | - register_graphql_mutation( |
|
405 | - 'bulkUpdate' . $this->name(), |
|
406 | - array_merge( |
|
407 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
408 | - [ |
|
409 | - 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
410 | - ] |
|
411 | - ) |
|
412 | - ); |
|
413 | - // Register mutation to delete an entity. |
|
414 | - register_graphql_mutation( |
|
415 | - 'delete' . $this->name(), |
|
416 | - [ |
|
417 | - 'inputFields' => [ |
|
418 | - 'id' => $inputFields['id'], |
|
419 | - 'deletePermanently' => [ |
|
420 | - 'type' => 'Boolean', |
|
421 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
422 | - ], |
|
423 | - ], |
|
424 | - 'outputFields' => [ |
|
425 | - lcfirst($this->name()) => [ |
|
426 | - 'type' => $this->name(), |
|
427 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
428 | - 'resolve' => static function ($payload) { |
|
429 | - $deleted = (object) $payload['deleted']; |
|
374 | + /** |
|
375 | + * @param array $inputFields The mutation input fields. |
|
376 | + * @throws InvalidArgumentException |
|
377 | + * @throws ReflectionException |
|
378 | + * @throws Exception |
|
379 | + */ |
|
380 | + public function registerMutations(array $inputFields) |
|
381 | + { |
|
382 | + register_graphql_input_type( |
|
383 | + 'Update' . $this->name() . 'BaseInput', |
|
384 | + [ |
|
385 | + 'fields' => $inputFields, |
|
386 | + ] |
|
387 | + ); |
|
388 | + // Register mutation to update an entity. |
|
389 | + register_graphql_mutation( |
|
390 | + 'update' . $this->name(), |
|
391 | + [ |
|
392 | + 'inputFields' => $inputFields, |
|
393 | + 'outputFields' => [ |
|
394 | + lcfirst($this->name()) => [ |
|
395 | + 'type' => $this->name(), |
|
396 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
397 | + ], |
|
398 | + ], |
|
399 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
400 | + ] |
|
401 | + ); |
|
402 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
403 | + // Register mutation to update an entity. |
|
404 | + register_graphql_mutation( |
|
405 | + 'bulkUpdate' . $this->name(), |
|
406 | + array_merge( |
|
407 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
408 | + [ |
|
409 | + 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
410 | + ] |
|
411 | + ) |
|
412 | + ); |
|
413 | + // Register mutation to delete an entity. |
|
414 | + register_graphql_mutation( |
|
415 | + 'delete' . $this->name(), |
|
416 | + [ |
|
417 | + 'inputFields' => [ |
|
418 | + 'id' => $inputFields['id'], |
|
419 | + 'deletePermanently' => [ |
|
420 | + 'type' => 'Boolean', |
|
421 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
422 | + ], |
|
423 | + ], |
|
424 | + 'outputFields' => [ |
|
425 | + lcfirst($this->name()) => [ |
|
426 | + 'type' => $this->name(), |
|
427 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
428 | + 'resolve' => static function ($payload) { |
|
429 | + $deleted = (object) $payload['deleted']; |
|
430 | 430 | |
431 | - return ! empty($deleted) ? $deleted : null; |
|
432 | - }, |
|
433 | - ], |
|
434 | - ], |
|
435 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
436 | - ] |
|
437 | - ); |
|
431 | + return ! empty($deleted) ? $deleted : null; |
|
432 | + }, |
|
433 | + ], |
|
434 | + ], |
|
435 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
436 | + ] |
|
437 | + ); |
|
438 | 438 | |
439 | - // remove primary key from input. |
|
440 | - unset($inputFields['id']); |
|
441 | - // Register mutation to update an entity. |
|
442 | - register_graphql_mutation( |
|
443 | - 'create' . $this->name(), |
|
444 | - [ |
|
445 | - 'inputFields' => $inputFields, |
|
446 | - 'outputFields' => [ |
|
447 | - lcfirst($this->name()) => [ |
|
448 | - 'type' => $this->name(), |
|
449 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
450 | - ], |
|
451 | - ], |
|
452 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
453 | - ] |
|
454 | - ); |
|
455 | - } |
|
439 | + // remove primary key from input. |
|
440 | + unset($inputFields['id']); |
|
441 | + // Register mutation to update an entity. |
|
442 | + register_graphql_mutation( |
|
443 | + 'create' . $this->name(), |
|
444 | + [ |
|
445 | + 'inputFields' => $inputFields, |
|
446 | + 'outputFields' => [ |
|
447 | + lcfirst($this->name()) => [ |
|
448 | + 'type' => $this->name(), |
|
449 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
450 | + ], |
|
451 | + ], |
|
452 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
453 | + ] |
|
454 | + ); |
|
455 | + } |
|
456 | 456 | } |
@@ -16,47 +16,47 @@ |
||
16 | 16 | { |
17 | 17 | |
18 | 18 | |
19 | - /** |
|
20 | - * returns true if the current request matches this route |
|
21 | - * child classes can override and use Request directly to match route with request |
|
22 | - * or supply a RouteMatchSpecification class and just use the below |
|
23 | - * |
|
24 | - * @return bool |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function matchesCurrentRequest(): bool |
|
28 | - { |
|
29 | - return ($this->request->isFrontend() || $this->request->isFrontAjax() || $this->request->isIframe()) |
|
30 | - && ! $this->maintenance_mode->level(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - protected function registerDependencies() |
|
38 | - { |
|
39 | - $this->dependency_map->registerDependencies( |
|
40 | - 'EE_Front_Controller', |
|
41 | - [ |
|
42 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
43 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
44 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
45 | - ] |
|
46 | - ); |
|
47 | - } |
|
48 | - |
|
49 | - |
|
50 | - /** |
|
51 | - * implements logic required to run during request |
|
52 | - * |
|
53 | - * @return bool |
|
54 | - * @since $VID:$ |
|
55 | - */ |
|
56 | - protected function requestHandler(): bool |
|
57 | - { |
|
58 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
59 | - $this->loader->getShared('EE_Front_Controller'); |
|
60 | - return true; |
|
61 | - } |
|
19 | + /** |
|
20 | + * returns true if the current request matches this route |
|
21 | + * child classes can override and use Request directly to match route with request |
|
22 | + * or supply a RouteMatchSpecification class and just use the below |
|
23 | + * |
|
24 | + * @return bool |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function matchesCurrentRequest(): bool |
|
28 | + { |
|
29 | + return ($this->request->isFrontend() || $this->request->isFrontAjax() || $this->request->isIframe()) |
|
30 | + && ! $this->maintenance_mode->level(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + protected function registerDependencies() |
|
38 | + { |
|
39 | + $this->dependency_map->registerDependencies( |
|
40 | + 'EE_Front_Controller', |
|
41 | + [ |
|
42 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
43 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
44 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
45 | + ] |
|
46 | + ); |
|
47 | + } |
|
48 | + |
|
49 | + |
|
50 | + /** |
|
51 | + * implements logic required to run during request |
|
52 | + * |
|
53 | + * @return bool |
|
54 | + * @since $VID:$ |
|
55 | + */ |
|
56 | + protected function requestHandler(): bool |
|
57 | + { |
|
58 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
59 | + $this->loader->getShared('EE_Front_Controller'); |
|
60 | + return true; |
|
61 | + } |
|
62 | 62 | } |