@@ -25,267 +25,267 @@ |
||
25 | 25 | class Ticket extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Ticket constructor. |
|
30 | - * |
|
31 | - * @param EEM_Ticket $ticket_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Ticket $ticket_model) |
|
34 | - { |
|
35 | - $this->model = $ticket_model; |
|
36 | - $this->setName('Ticket'); |
|
37 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Ticket constructor. |
|
30 | + * |
|
31 | + * @param EEM_Ticket $ticket_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Ticket $ticket_model) |
|
34 | + { |
|
35 | + $this->model = $ticket_model; |
|
36 | + $this->setName('Ticket'); |
|
37 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - protected function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('Ticket ID', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'name', |
|
58 | - 'String', |
|
59 | - 'name', |
|
60 | - esc_html__('Ticket Name', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'description', |
|
64 | - 'String', |
|
65 | - 'description', |
|
66 | - esc_html__('Description of Ticket', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'startDate', |
|
70 | - 'String', |
|
71 | - 'start_date', |
|
72 | - esc_html__('Start time/date of Ticket', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'endDate', |
|
76 | - 'String', |
|
77 | - 'end_date', |
|
78 | - esc_html__('End time/date of Ticket', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'min', |
|
82 | - 'Int', |
|
83 | - 'min', |
|
84 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'max', |
|
88 | - 'Int', |
|
89 | - 'max', |
|
90 | - esc_html__( |
|
91 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
92 | - 'event_espresso' |
|
93 | - ), |
|
94 | - [$this, 'parseInfiniteValue'] |
|
95 | - ), |
|
96 | - new GraphQLField( |
|
97 | - 'price', |
|
98 | - 'Float', |
|
99 | - 'price', |
|
100 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLField( |
|
103 | - 'sold', |
|
104 | - 'Int', |
|
105 | - 'sold', |
|
106 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLField( |
|
109 | - 'quantity', |
|
110 | - 'Int', |
|
111 | - 'qty', |
|
112 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
113 | - [$this, 'parseInfiniteValue'] |
|
114 | - ), |
|
115 | - new GraphQLField( |
|
116 | - 'reserved', |
|
117 | - 'Int', |
|
118 | - 'reserved', |
|
119 | - esc_html__( |
|
120 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | - 'event_espresso' |
|
122 | - ) |
|
123 | - ), |
|
124 | - new GraphQLField( |
|
125 | - 'uses', |
|
126 | - 'Int', |
|
127 | - 'uses', |
|
128 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | - [$this, 'parseInfiniteValue'] |
|
130 | - ), |
|
131 | - new GraphQLField( |
|
132 | - 'isRequired', |
|
133 | - 'Boolean', |
|
134 | - 'required', |
|
135 | - esc_html__( |
|
136 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
137 | - 'event_espresso' |
|
138 | - ) |
|
139 | - ), |
|
140 | - new GraphQLField( |
|
141 | - 'isTaxable', |
|
142 | - 'Boolean', |
|
143 | - 'taxable', |
|
144 | - esc_html__( |
|
145 | - 'Flag indicating whether there is tax applied on this ticket', |
|
146 | - 'event_espresso' |
|
147 | - ) |
|
148 | - ), |
|
149 | - new GraphQLField( |
|
150 | - 'isDefault', |
|
151 | - 'Boolean', |
|
152 | - 'is_default', |
|
153 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
154 | - ), |
|
155 | - new GraphQLField( |
|
156 | - 'order', |
|
157 | - 'Int', |
|
158 | - 'order', |
|
159 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'row', |
|
163 | - 'Int', |
|
164 | - 'row', |
|
165 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLOutputField( |
|
168 | - 'wpUser', |
|
169 | - 'User', |
|
170 | - null, |
|
171 | - esc_html__('Ticket Creator', 'event_espresso') |
|
172 | - ), |
|
173 | - new GraphQLInputField( |
|
174 | - 'wpUser', |
|
175 | - 'Int', |
|
176 | - null, |
|
177 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
178 | - ), |
|
179 | - new GraphQLOutputField( |
|
180 | - 'parent', |
|
181 | - 'Ticket', |
|
182 | - null, |
|
183 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
184 | - ), |
|
185 | - new GraphQLInputField( |
|
186 | - 'parent', |
|
187 | - 'Int', |
|
188 | - null, |
|
189 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
190 | - ), |
|
191 | - new GraphQLField( |
|
192 | - 'reverseCalculate', |
|
193 | - 'Boolean', |
|
194 | - 'reverse_calculate', |
|
195 | - esc_html__( |
|
196 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
197 | - 'event_espresso' |
|
198 | - ) |
|
199 | - ), |
|
200 | - new GraphQLField( |
|
201 | - 'isFree', |
|
202 | - 'Boolean', |
|
203 | - 'is_free', |
|
204 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
205 | - ), |
|
206 | - new GraphQLOutputField( |
|
207 | - 'event', |
|
208 | - 'Event', |
|
209 | - null, |
|
210 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
211 | - ), |
|
212 | - new GraphQLInputField( |
|
213 | - 'datetimes', |
|
214 | - ['list_of' => 'Int'], |
|
215 | - null, |
|
216 | - sprintf( |
|
217 | - '%1$s %2$s', |
|
218 | - esc_html__('IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
219 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
220 | - ) |
|
221 | - ), |
|
222 | - ]; |
|
223 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + protected function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('Ticket ID', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'name', |
|
58 | + 'String', |
|
59 | + 'name', |
|
60 | + esc_html__('Ticket Name', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'description', |
|
64 | + 'String', |
|
65 | + 'description', |
|
66 | + esc_html__('Description of Ticket', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'startDate', |
|
70 | + 'String', |
|
71 | + 'start_date', |
|
72 | + esc_html__('Start time/date of Ticket', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'endDate', |
|
76 | + 'String', |
|
77 | + 'end_date', |
|
78 | + esc_html__('End time/date of Ticket', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'min', |
|
82 | + 'Int', |
|
83 | + 'min', |
|
84 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'max', |
|
88 | + 'Int', |
|
89 | + 'max', |
|
90 | + esc_html__( |
|
91 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
92 | + 'event_espresso' |
|
93 | + ), |
|
94 | + [$this, 'parseInfiniteValue'] |
|
95 | + ), |
|
96 | + new GraphQLField( |
|
97 | + 'price', |
|
98 | + 'Float', |
|
99 | + 'price', |
|
100 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLField( |
|
103 | + 'sold', |
|
104 | + 'Int', |
|
105 | + 'sold', |
|
106 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLField( |
|
109 | + 'quantity', |
|
110 | + 'Int', |
|
111 | + 'qty', |
|
112 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
113 | + [$this, 'parseInfiniteValue'] |
|
114 | + ), |
|
115 | + new GraphQLField( |
|
116 | + 'reserved', |
|
117 | + 'Int', |
|
118 | + 'reserved', |
|
119 | + esc_html__( |
|
120 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
121 | + 'event_espresso' |
|
122 | + ) |
|
123 | + ), |
|
124 | + new GraphQLField( |
|
125 | + 'uses', |
|
126 | + 'Int', |
|
127 | + 'uses', |
|
128 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
129 | + [$this, 'parseInfiniteValue'] |
|
130 | + ), |
|
131 | + new GraphQLField( |
|
132 | + 'isRequired', |
|
133 | + 'Boolean', |
|
134 | + 'required', |
|
135 | + esc_html__( |
|
136 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
137 | + 'event_espresso' |
|
138 | + ) |
|
139 | + ), |
|
140 | + new GraphQLField( |
|
141 | + 'isTaxable', |
|
142 | + 'Boolean', |
|
143 | + 'taxable', |
|
144 | + esc_html__( |
|
145 | + 'Flag indicating whether there is tax applied on this ticket', |
|
146 | + 'event_espresso' |
|
147 | + ) |
|
148 | + ), |
|
149 | + new GraphQLField( |
|
150 | + 'isDefault', |
|
151 | + 'Boolean', |
|
152 | + 'is_default', |
|
153 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
154 | + ), |
|
155 | + new GraphQLField( |
|
156 | + 'order', |
|
157 | + 'Int', |
|
158 | + 'order', |
|
159 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'row', |
|
163 | + 'Int', |
|
164 | + 'row', |
|
165 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLOutputField( |
|
168 | + 'wpUser', |
|
169 | + 'User', |
|
170 | + null, |
|
171 | + esc_html__('Ticket Creator', 'event_espresso') |
|
172 | + ), |
|
173 | + new GraphQLInputField( |
|
174 | + 'wpUser', |
|
175 | + 'Int', |
|
176 | + null, |
|
177 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
178 | + ), |
|
179 | + new GraphQLOutputField( |
|
180 | + 'parent', |
|
181 | + 'Ticket', |
|
182 | + null, |
|
183 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
184 | + ), |
|
185 | + new GraphQLInputField( |
|
186 | + 'parent', |
|
187 | + 'Int', |
|
188 | + null, |
|
189 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
190 | + ), |
|
191 | + new GraphQLField( |
|
192 | + 'reverseCalculate', |
|
193 | + 'Boolean', |
|
194 | + 'reverse_calculate', |
|
195 | + esc_html__( |
|
196 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
197 | + 'event_espresso' |
|
198 | + ) |
|
199 | + ), |
|
200 | + new GraphQLField( |
|
201 | + 'isFree', |
|
202 | + 'Boolean', |
|
203 | + 'is_free', |
|
204 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
205 | + ), |
|
206 | + new GraphQLOutputField( |
|
207 | + 'event', |
|
208 | + 'Event', |
|
209 | + null, |
|
210 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
211 | + ), |
|
212 | + new GraphQLInputField( |
|
213 | + 'datetimes', |
|
214 | + ['list_of' => 'Int'], |
|
215 | + null, |
|
216 | + sprintf( |
|
217 | + '%1$s %2$s', |
|
218 | + esc_html__('IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
219 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
220 | + ) |
|
221 | + ), |
|
222 | + ]; |
|
223 | + } |
|
224 | 224 | |
225 | 225 | |
226 | - /** |
|
227 | - * @param array $inputFields The mutation input fields. |
|
228 | - * @throws InvalidArgumentException |
|
229 | - * @throws ReflectionException |
|
230 | - * @since $VID:$ |
|
231 | - */ |
|
232 | - public function registerMutations(array $inputFields) |
|
233 | - { |
|
234 | - // Register mutation to update an entity. |
|
235 | - register_graphql_mutation( |
|
236 | - 'update' . $this->name(), |
|
237 | - [ |
|
238 | - 'inputFields' => $inputFields, |
|
239 | - 'outputFields' => [ |
|
240 | - lcfirst($this->name()) => [ |
|
241 | - 'type' => $this->name(), |
|
242 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
243 | - ], |
|
244 | - ], |
|
245 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
246 | - ] |
|
247 | - ); |
|
248 | - // Register mutation to delete an entity. |
|
249 | - register_graphql_mutation( |
|
250 | - 'delete' . $this->name(), |
|
251 | - [ |
|
252 | - 'inputFields' => [ |
|
253 | - 'id' => $inputFields['id'], |
|
254 | - 'deletePermanently' => [ |
|
255 | - 'type' => 'Boolean', |
|
256 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
257 | - ], |
|
258 | - ], |
|
259 | - 'outputFields' => [ |
|
260 | - lcfirst($this->name()) => [ |
|
261 | - 'type' => $this->name(), |
|
262 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
263 | - 'resolve' => static function ($payload) { |
|
264 | - $deleted = (object) $payload['deleted']; |
|
226 | + /** |
|
227 | + * @param array $inputFields The mutation input fields. |
|
228 | + * @throws InvalidArgumentException |
|
229 | + * @throws ReflectionException |
|
230 | + * @since $VID:$ |
|
231 | + */ |
|
232 | + public function registerMutations(array $inputFields) |
|
233 | + { |
|
234 | + // Register mutation to update an entity. |
|
235 | + register_graphql_mutation( |
|
236 | + 'update' . $this->name(), |
|
237 | + [ |
|
238 | + 'inputFields' => $inputFields, |
|
239 | + 'outputFields' => [ |
|
240 | + lcfirst($this->name()) => [ |
|
241 | + 'type' => $this->name(), |
|
242 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
243 | + ], |
|
244 | + ], |
|
245 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
246 | + ] |
|
247 | + ); |
|
248 | + // Register mutation to delete an entity. |
|
249 | + register_graphql_mutation( |
|
250 | + 'delete' . $this->name(), |
|
251 | + [ |
|
252 | + 'inputFields' => [ |
|
253 | + 'id' => $inputFields['id'], |
|
254 | + 'deletePermanently' => [ |
|
255 | + 'type' => 'Boolean', |
|
256 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
257 | + ], |
|
258 | + ], |
|
259 | + 'outputFields' => [ |
|
260 | + lcfirst($this->name()) => [ |
|
261 | + 'type' => $this->name(), |
|
262 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
263 | + 'resolve' => static function ($payload) { |
|
264 | + $deleted = (object) $payload['deleted']; |
|
265 | 265 | |
266 | - return ! empty($deleted) ? $deleted : null; |
|
267 | - }, |
|
268 | - ], |
|
269 | - ], |
|
270 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
271 | - ] |
|
272 | - ); |
|
266 | + return ! empty($deleted) ? $deleted : null; |
|
267 | + }, |
|
268 | + ], |
|
269 | + ], |
|
270 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
271 | + ] |
|
272 | + ); |
|
273 | 273 | |
274 | - // remove primary key from input. |
|
275 | - unset($inputFields['id']); |
|
276 | - // Register mutation to update an entity. |
|
277 | - register_graphql_mutation( |
|
278 | - 'create' . $this->name(), |
|
279 | - [ |
|
280 | - 'inputFields' => $inputFields, |
|
281 | - 'outputFields' => [ |
|
282 | - lcfirst($this->name()) => [ |
|
283 | - 'type' => $this->name(), |
|
284 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
285 | - ], |
|
286 | - ], |
|
287 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
288 | - ] |
|
289 | - ); |
|
290 | - } |
|
274 | + // remove primary key from input. |
|
275 | + unset($inputFields['id']); |
|
276 | + // Register mutation to update an entity. |
|
277 | + register_graphql_mutation( |
|
278 | + 'create' . $this->name(), |
|
279 | + [ |
|
280 | + 'inputFields' => $inputFields, |
|
281 | + 'outputFields' => [ |
|
282 | + lcfirst($this->name()) => [ |
|
283 | + 'type' => $this->name(), |
|
284 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
285 | + ], |
|
286 | + ], |
|
287 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
288 | + ] |
|
289 | + ); |
|
290 | + } |
|
291 | 291 | } |
@@ -25,247 +25,247 @@ |
||
25 | 25 | class Datetime extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * EventDate constructor. |
|
30 | - * |
|
31 | - * @param EEM_Datetime $datetime_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Datetime $datetime_model) |
|
34 | - { |
|
35 | - $this->model = $datetime_model; |
|
36 | - $this->setName('Datetime'); |
|
37 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * EventDate constructor. |
|
30 | + * |
|
31 | + * @param EEM_Datetime $datetime_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Datetime $datetime_model) |
|
34 | + { |
|
35 | + $this->model = $datetime_model; |
|
36 | + $this->setName('Datetime'); |
|
37 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('The datetime ID.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'name', |
|
58 | - 'String', |
|
59 | - 'name', |
|
60 | - esc_html__('Datetime Name', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'description', |
|
64 | - 'String', |
|
65 | - 'description', |
|
66 | - esc_html__('Description for Datetime', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'start', |
|
70 | - 'String', |
|
71 | - 'start', |
|
72 | - esc_html__('Start timestamp of Event', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'startDate', |
|
76 | - 'String', |
|
77 | - 'start_date', |
|
78 | - esc_html__('Start time/date of Event', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'end', |
|
82 | - 'String', |
|
83 | - 'end', |
|
84 | - esc_html__('End timestamp of Event', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'endDate', |
|
88 | - 'String', |
|
89 | - 'end_date', |
|
90 | - esc_html__('End time/date of Event', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'startTime', |
|
94 | - 'String', |
|
95 | - 'start_time', |
|
96 | - esc_html__('Start time of Event', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLField( |
|
99 | - 'endTime', |
|
100 | - 'String', |
|
101 | - 'end_time', |
|
102 | - esc_html__('End time of Event', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLField( |
|
105 | - 'capacity', |
|
106 | - 'Int', |
|
107 | - 'reg_limit', |
|
108 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
109 | - [$this, 'parseInfiniteValue'] |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'sold', |
|
113 | - 'Int', |
|
114 | - 'sold', |
|
115 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'reserved', |
|
119 | - 'Int', |
|
120 | - 'reserved', |
|
121 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'order', |
|
125 | - 'Int', |
|
126 | - 'order', |
|
127 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'length', |
|
131 | - 'Int', |
|
132 | - 'length', |
|
133 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLOutputField( |
|
136 | - 'parent', |
|
137 | - 'Datetime', |
|
138 | - null, |
|
139 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLInputField( |
|
142 | - 'parent', |
|
143 | - 'Int', |
|
144 | - null, |
|
145 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'isPrimary', |
|
149 | - 'Boolean', |
|
150 | - 'is_primary', |
|
151 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'isSoldOut', |
|
155 | - 'Boolean', |
|
156 | - 'sold_out', |
|
157 | - esc_html__( |
|
158 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
159 | - 'event_espresso' |
|
160 | - ) |
|
161 | - ), |
|
162 | - new GraphQLField( |
|
163 | - 'isUpcoming', |
|
164 | - 'Boolean', |
|
165 | - 'is_upcoming', |
|
166 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'isActive', |
|
170 | - 'Boolean', |
|
171 | - 'is_active', |
|
172 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'isExpired', |
|
176 | - 'Boolean', |
|
177 | - 'is_expired', |
|
178 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLOutputField( |
|
181 | - 'event', |
|
182 | - 'Event', |
|
183 | - null, |
|
184 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLInputField( |
|
187 | - 'event', |
|
188 | - 'Int', |
|
189 | - null, |
|
190 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
191 | - ), |
|
192 | - new GraphQLInputField( |
|
193 | - 'tickets', |
|
194 | - ['list_of' => 'Int'], |
|
195 | - null, |
|
196 | - sprintf( |
|
197 | - '%1$s %2$s', |
|
198 | - esc_html__('IDs of the tickets related to the datetime.', 'event_espresso'), |
|
199 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
200 | - ) |
|
201 | - ), |
|
202 | - ]; |
|
203 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('The datetime ID.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'name', |
|
58 | + 'String', |
|
59 | + 'name', |
|
60 | + esc_html__('Datetime Name', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'description', |
|
64 | + 'String', |
|
65 | + 'description', |
|
66 | + esc_html__('Description for Datetime', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'start', |
|
70 | + 'String', |
|
71 | + 'start', |
|
72 | + esc_html__('Start timestamp of Event', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'startDate', |
|
76 | + 'String', |
|
77 | + 'start_date', |
|
78 | + esc_html__('Start time/date of Event', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'end', |
|
82 | + 'String', |
|
83 | + 'end', |
|
84 | + esc_html__('End timestamp of Event', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'endDate', |
|
88 | + 'String', |
|
89 | + 'end_date', |
|
90 | + esc_html__('End time/date of Event', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'startTime', |
|
94 | + 'String', |
|
95 | + 'start_time', |
|
96 | + esc_html__('Start time of Event', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLField( |
|
99 | + 'endTime', |
|
100 | + 'String', |
|
101 | + 'end_time', |
|
102 | + esc_html__('End time of Event', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLField( |
|
105 | + 'capacity', |
|
106 | + 'Int', |
|
107 | + 'reg_limit', |
|
108 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
109 | + [$this, 'parseInfiniteValue'] |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'sold', |
|
113 | + 'Int', |
|
114 | + 'sold', |
|
115 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'reserved', |
|
119 | + 'Int', |
|
120 | + 'reserved', |
|
121 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'order', |
|
125 | + 'Int', |
|
126 | + 'order', |
|
127 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'length', |
|
131 | + 'Int', |
|
132 | + 'length', |
|
133 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLOutputField( |
|
136 | + 'parent', |
|
137 | + 'Datetime', |
|
138 | + null, |
|
139 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLInputField( |
|
142 | + 'parent', |
|
143 | + 'Int', |
|
144 | + null, |
|
145 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'isPrimary', |
|
149 | + 'Boolean', |
|
150 | + 'is_primary', |
|
151 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'isSoldOut', |
|
155 | + 'Boolean', |
|
156 | + 'sold_out', |
|
157 | + esc_html__( |
|
158 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
159 | + 'event_espresso' |
|
160 | + ) |
|
161 | + ), |
|
162 | + new GraphQLField( |
|
163 | + 'isUpcoming', |
|
164 | + 'Boolean', |
|
165 | + 'is_upcoming', |
|
166 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'isActive', |
|
170 | + 'Boolean', |
|
171 | + 'is_active', |
|
172 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'isExpired', |
|
176 | + 'Boolean', |
|
177 | + 'is_expired', |
|
178 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLOutputField( |
|
181 | + 'event', |
|
182 | + 'Event', |
|
183 | + null, |
|
184 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLInputField( |
|
187 | + 'event', |
|
188 | + 'Int', |
|
189 | + null, |
|
190 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
191 | + ), |
|
192 | + new GraphQLInputField( |
|
193 | + 'tickets', |
|
194 | + ['list_of' => 'Int'], |
|
195 | + null, |
|
196 | + sprintf( |
|
197 | + '%1$s %2$s', |
|
198 | + esc_html__('IDs of the tickets related to the datetime.', 'event_espresso'), |
|
199 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
200 | + ) |
|
201 | + ), |
|
202 | + ]; |
|
203 | + } |
|
204 | 204 | |
205 | 205 | |
206 | - /** |
|
207 | - * @param array $inputFields The mutation input fields. |
|
208 | - * @throws InvalidArgumentException |
|
209 | - * @throws ReflectionException |
|
210 | - * @since $VID:$ |
|
211 | - */ |
|
212 | - public function registerMutations(array $inputFields) |
|
213 | - { |
|
214 | - // Register mutation to update an entity. |
|
215 | - register_graphql_mutation( |
|
216 | - 'update' . $this->name(), |
|
217 | - [ |
|
218 | - 'inputFields' => $inputFields, |
|
219 | - 'outputFields' => [ |
|
220 | - lcfirst($this->name()) => [ |
|
221 | - 'type' => $this->name(), |
|
222 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
223 | - ], |
|
224 | - ], |
|
225 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
226 | - ] |
|
227 | - ); |
|
228 | - // Register mutation to delete an entity. |
|
229 | - register_graphql_mutation( |
|
230 | - 'delete' . $this->name(), |
|
231 | - [ |
|
232 | - 'inputFields' => [ |
|
233 | - 'id' => $inputFields['id'], |
|
234 | - 'deletePermanently' => [ |
|
235 | - 'type' => 'Boolean', |
|
236 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
237 | - ], |
|
238 | - ], |
|
239 | - 'outputFields' => [ |
|
240 | - lcfirst($this->name()) => [ |
|
241 | - 'type' => $this->name(), |
|
242 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
243 | - 'resolve' => static function ($payload) { |
|
244 | - $deleted = (object) $payload['deleted']; |
|
206 | + /** |
|
207 | + * @param array $inputFields The mutation input fields. |
|
208 | + * @throws InvalidArgumentException |
|
209 | + * @throws ReflectionException |
|
210 | + * @since $VID:$ |
|
211 | + */ |
|
212 | + public function registerMutations(array $inputFields) |
|
213 | + { |
|
214 | + // Register mutation to update an entity. |
|
215 | + register_graphql_mutation( |
|
216 | + 'update' . $this->name(), |
|
217 | + [ |
|
218 | + 'inputFields' => $inputFields, |
|
219 | + 'outputFields' => [ |
|
220 | + lcfirst($this->name()) => [ |
|
221 | + 'type' => $this->name(), |
|
222 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
223 | + ], |
|
224 | + ], |
|
225 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
226 | + ] |
|
227 | + ); |
|
228 | + // Register mutation to delete an entity. |
|
229 | + register_graphql_mutation( |
|
230 | + 'delete' . $this->name(), |
|
231 | + [ |
|
232 | + 'inputFields' => [ |
|
233 | + 'id' => $inputFields['id'], |
|
234 | + 'deletePermanently' => [ |
|
235 | + 'type' => 'Boolean', |
|
236 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
237 | + ], |
|
238 | + ], |
|
239 | + 'outputFields' => [ |
|
240 | + lcfirst($this->name()) => [ |
|
241 | + 'type' => $this->name(), |
|
242 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
243 | + 'resolve' => static function ($payload) { |
|
244 | + $deleted = (object) $payload['deleted']; |
|
245 | 245 | |
246 | - return ! empty($deleted) ? $deleted : null; |
|
247 | - }, |
|
248 | - ], |
|
249 | - ], |
|
250 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
251 | - ] |
|
252 | - ); |
|
246 | + return ! empty($deleted) ? $deleted : null; |
|
247 | + }, |
|
248 | + ], |
|
249 | + ], |
|
250 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
251 | + ] |
|
252 | + ); |
|
253 | 253 | |
254 | - // remove primary key from input. |
|
255 | - unset($inputFields['id']); |
|
256 | - // Register mutation to update an entity. |
|
257 | - register_graphql_mutation( |
|
258 | - 'create' . $this->name(), |
|
259 | - [ |
|
260 | - 'inputFields' => $inputFields, |
|
261 | - 'outputFields' => [ |
|
262 | - lcfirst($this->name()) => [ |
|
263 | - 'type' => $this->name(), |
|
264 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
265 | - ], |
|
266 | - ], |
|
267 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
268 | - ] |
|
269 | - ); |
|
270 | - } |
|
254 | + // remove primary key from input. |
|
255 | + unset($inputFields['id']); |
|
256 | + // Register mutation to update an entity. |
|
257 | + register_graphql_mutation( |
|
258 | + 'create' . $this->name(), |
|
259 | + [ |
|
260 | + 'inputFields' => $inputFields, |
|
261 | + 'outputFields' => [ |
|
262 | + lcfirst($this->name()) => [ |
|
263 | + 'type' => $this->name(), |
|
264 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
265 | + ], |
|
266 | + ], |
|
267 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
268 | + ] |
|
269 | + ); |
|
270 | + } |
|
271 | 271 | } |
@@ -20,80 +20,80 @@ |
||
20 | 20 | class DatetimeUpdate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Datetime $model |
|
27 | - * @param Datetime $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Updates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | - /** |
|
48 | - * Stop now if a user isn't allowed to create a datetime. |
|
49 | - */ |
|
50 | - if (! current_user_can('ee_edit_events')) { |
|
51 | - // translators: the %1$s is the name of the object being mutated |
|
52 | - throw new UserError( |
|
53 | - sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
54 | - ); |
|
55 | - } |
|
56 | - |
|
57 | - $id = ! empty($input['id']) ? absint($input['id']) : 0; |
|
58 | - $entity = null; |
|
59 | - |
|
60 | - if ($id) { |
|
61 | - $entity = $model->get_one_by_ID($id); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * If there's no existing datetime, throw an exception |
|
66 | - */ |
|
67 | - if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
68 | - // translators: the placeholder is the name of the type being updated |
|
69 | - throw new UserError( |
|
70 | - sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
71 | - ); |
|
72 | - } |
|
73 | - |
|
74 | - $tickets = []; |
|
75 | - |
|
76 | - $args = DatetimeMutation::prepareFields($input); |
|
77 | - |
|
78 | - if (isset($args['tickets'])) { |
|
79 | - $tickets = $args['tickets']; |
|
80 | - unset($args['tickets']); |
|
81 | - } |
|
82 | - |
|
83 | - // Update the entity |
|
84 | - $result = $entity->save($args); |
|
85 | - |
|
86 | - if (empty($result)) { |
|
87 | - throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
|
88 | - } |
|
89 | - |
|
90 | - if (! empty($tickets)) { |
|
91 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
92 | - } |
|
93 | - |
|
94 | - return [ |
|
95 | - 'id' => $id, |
|
96 | - ]; |
|
97 | - }; |
|
98 | - } |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Datetime $model |
|
27 | + * @param Datetime $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Updates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + /** |
|
48 | + * Stop now if a user isn't allowed to create a datetime. |
|
49 | + */ |
|
50 | + if (! current_user_can('ee_edit_events')) { |
|
51 | + // translators: the %1$s is the name of the object being mutated |
|
52 | + throw new UserError( |
|
53 | + sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
54 | + ); |
|
55 | + } |
|
56 | + |
|
57 | + $id = ! empty($input['id']) ? absint($input['id']) : 0; |
|
58 | + $entity = null; |
|
59 | + |
|
60 | + if ($id) { |
|
61 | + $entity = $model->get_one_by_ID($id); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * If there's no existing datetime, throw an exception |
|
66 | + */ |
|
67 | + if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
68 | + // translators: the placeholder is the name of the type being updated |
|
69 | + throw new UserError( |
|
70 | + sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
71 | + ); |
|
72 | + } |
|
73 | + |
|
74 | + $tickets = []; |
|
75 | + |
|
76 | + $args = DatetimeMutation::prepareFields($input); |
|
77 | + |
|
78 | + if (isset($args['tickets'])) { |
|
79 | + $tickets = $args['tickets']; |
|
80 | + unset($args['tickets']); |
|
81 | + } |
|
82 | + |
|
83 | + // Update the entity |
|
84 | + $result = $entity->save($args); |
|
85 | + |
|
86 | + if (empty($result)) { |
|
87 | + throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
|
88 | + } |
|
89 | + |
|
90 | + if (! empty($tickets)) { |
|
91 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
92 | + } |
|
93 | + |
|
94 | + return [ |
|
95 | + 'id' => $id, |
|
96 | + ]; |
|
97 | + }; |
|
98 | + } |
|
99 | 99 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | /** |
48 | 48 | * Stop now if a user isn't allowed to create a datetime. |
49 | 49 | */ |
50 | - if (! current_user_can('ee_edit_events')) { |
|
50 | + if ( ! current_user_can('ee_edit_events')) { |
|
51 | 51 | // translators: the %1$s is the name of the object being mutated |
52 | 52 | throw new UserError( |
53 | 53 | sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * If there's no existing datetime, throw an exception |
66 | 66 | */ |
67 | - if (! $id || ! ($entity instanceof EE_Datetime)) { |
|
67 | + if ( ! $id || ! ($entity instanceof EE_Datetime)) { |
|
68 | 68 | // translators: the placeholder is the name of the type being updated |
69 | 69 | throw new UserError( |
70 | 70 | sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
88 | 88 | } |
89 | 89 | |
90 | - if (! empty($tickets)) { |
|
90 | + if ( ! empty($tickets)) { |
|
91 | 91 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
92 | 92 | } |
93 | 93 |
@@ -20,64 +20,64 @@ |
||
20 | 20 | class DatetimeCreate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Datetime $model |
|
27 | - * @param Datetime $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Creates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Datetime $model |
|
27 | + * @param Datetime $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Creates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create a datetime. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create a datetime. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - $tickets = []; |
|
58 | + $tickets = []; |
|
59 | 59 | |
60 | - $args = DatetimeMutation::prepareFields($input); |
|
60 | + $args = DatetimeMutation::prepareFields($input); |
|
61 | 61 | |
62 | - if (isset($args['tickets'])) { |
|
63 | - $tickets = $args['tickets']; |
|
64 | - unset($args['tickets']); |
|
65 | - } |
|
62 | + if (isset($args['tickets'])) { |
|
63 | + $tickets = $args['tickets']; |
|
64 | + unset($args['tickets']); |
|
65 | + } |
|
66 | 66 | |
67 | - $entity = EE_Datetime::new_instance($args); |
|
68 | - $id = $entity->save(); |
|
67 | + $entity = EE_Datetime::new_instance($args); |
|
68 | + $id = $entity->save(); |
|
69 | 69 | |
70 | - if (empty($id)) { |
|
71 | - throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | - } |
|
70 | + if (empty($id)) { |
|
71 | + throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | + } |
|
73 | 73 | |
74 | - if (! empty($tickets)) { |
|
75 | - DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
76 | - } |
|
74 | + if (! empty($tickets)) { |
|
75 | + DatetimeMutation::setRelatedTickets($entity, $tickets); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $id, |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $id, |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create a datetime. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
72 | 72 | } |
73 | 73 | |
74 | - if (! empty($tickets)) { |
|
74 | + if ( ! empty($tickets)) { |
|
75 | 75 | DatetimeMutation::setRelatedTickets($entity, $tickets); |
76 | 76 | } |
77 | 77 |
@@ -20,80 +20,80 @@ |
||
20 | 20 | class TicketUpdate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - * @param Ticket $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Updates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | - /** |
|
48 | - * Stop now if a user isn't allowed to create a datetime. |
|
49 | - */ |
|
50 | - if (! current_user_can('ee_edit_events')) { |
|
51 | - // translators: the %1$s is the name of the object being mutated |
|
52 | - throw new UserError( |
|
53 | - sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
54 | - ); |
|
55 | - } |
|
56 | - |
|
57 | - $id = ! empty($input['id']) ? absint($input['id']) : 0; |
|
58 | - $entity = null; |
|
59 | - |
|
60 | - if ($id) { |
|
61 | - $entity = $model->get_one_by_ID($id); |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * If there's no existing datetime, throw an exception |
|
66 | - */ |
|
67 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
68 | - // translators: the placeholder is the name of the type being updated |
|
69 | - throw new UserError( |
|
70 | - sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
71 | - ); |
|
72 | - } |
|
73 | - |
|
74 | - $datetimes = []; |
|
75 | - |
|
76 | - $args = TicketMutation::prepareFields($input); |
|
77 | - |
|
78 | - if (isset($args['datetimes'])) { |
|
79 | - $datetimes = $args['datetimes']; |
|
80 | - unset($args['datetimes']); |
|
81 | - } |
|
82 | - |
|
83 | - // Update the entity |
|
84 | - $result = $entity->save($args); |
|
85 | - |
|
86 | - if (empty($result)) { |
|
87 | - throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
|
88 | - } |
|
89 | - |
|
90 | - if (! empty($datetimes)) { |
|
91 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
92 | - } |
|
93 | - |
|
94 | - return [ |
|
95 | - 'id' => $id, |
|
96 | - ]; |
|
97 | - }; |
|
98 | - } |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + * @param Ticket $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Updates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | + /** |
|
48 | + * Stop now if a user isn't allowed to create a datetime. |
|
49 | + */ |
|
50 | + if (! current_user_can('ee_edit_events')) { |
|
51 | + // translators: the %1$s is the name of the object being mutated |
|
52 | + throw new UserError( |
|
53 | + sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
|
54 | + ); |
|
55 | + } |
|
56 | + |
|
57 | + $id = ! empty($input['id']) ? absint($input['id']) : 0; |
|
58 | + $entity = null; |
|
59 | + |
|
60 | + if ($id) { |
|
61 | + $entity = $model->get_one_by_ID($id); |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * If there's no existing datetime, throw an exception |
|
66 | + */ |
|
67 | + if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
68 | + // translators: the placeholder is the name of the type being updated |
|
69 | + throw new UserError( |
|
70 | + sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
|
71 | + ); |
|
72 | + } |
|
73 | + |
|
74 | + $datetimes = []; |
|
75 | + |
|
76 | + $args = TicketMutation::prepareFields($input); |
|
77 | + |
|
78 | + if (isset($args['datetimes'])) { |
|
79 | + $datetimes = $args['datetimes']; |
|
80 | + unset($args['datetimes']); |
|
81 | + } |
|
82 | + |
|
83 | + // Update the entity |
|
84 | + $result = $entity->save($args); |
|
85 | + |
|
86 | + if (empty($result)) { |
|
87 | + throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
|
88 | + } |
|
89 | + |
|
90 | + if (! empty($datetimes)) { |
|
91 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
92 | + } |
|
93 | + |
|
94 | + return [ |
|
95 | + 'id' => $id, |
|
96 | + ]; |
|
97 | + }; |
|
98 | + } |
|
99 | 99 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | /** |
48 | 48 | * Stop now if a user isn't allowed to create a datetime. |
49 | 49 | */ |
50 | - if (! current_user_can('ee_edit_events')) { |
|
50 | + if ( ! current_user_can('ee_edit_events')) { |
|
51 | 51 | // translators: the %1$s is the name of the object being mutated |
52 | 52 | throw new UserError( |
53 | 53 | sprintf(__('Sorry, you are not allowed to edit %1$s', 'event_espresso'), $type->name()) |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * If there's no existing datetime, throw an exception |
66 | 66 | */ |
67 | - if (! $id || ! ($entity instanceof EE_Ticket)) { |
|
67 | + if ( ! $id || ! ($entity instanceof EE_Ticket)) { |
|
68 | 68 | // translators: the placeholder is the name of the type being updated |
69 | 69 | throw new UserError( |
70 | 70 | sprintf(__('No %1$s could be found to update', 'event_espresso'), $type->name()) |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | throw new UserError(__('The object failed to update but no error was provided', 'event_espresso')); |
88 | 88 | } |
89 | 89 | |
90 | - if (! empty($datetimes)) { |
|
90 | + if ( ! empty($datetimes)) { |
|
91 | 91 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
92 | 92 | } |
93 | 93 |
@@ -20,64 +20,64 @@ |
||
20 | 20 | class TicketCreate |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Defines the mutation data modification closure. |
|
25 | - * |
|
26 | - * @param EEM_Ticket $model |
|
27 | - * @param Ticket $type |
|
28 | - * @return callable |
|
29 | - */ |
|
30 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | - { |
|
32 | - /** |
|
33 | - * Creates an entity. |
|
34 | - * |
|
35 | - * @param array $input The input for the mutation |
|
36 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | - * @return array |
|
39 | - * @throws UserError |
|
40 | - * @throws ReflectionException |
|
41 | - * @throws InvalidArgumentException |
|
42 | - * @throws InvalidInterfaceException |
|
43 | - * @throws InvalidDataTypeException |
|
44 | - * @throws EE_Error |
|
45 | - */ |
|
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
23 | + /** |
|
24 | + * Defines the mutation data modification closure. |
|
25 | + * |
|
26 | + * @param EEM_Ticket $model |
|
27 | + * @param Ticket $type |
|
28 | + * @return callable |
|
29 | + */ |
|
30 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
31 | + { |
|
32 | + /** |
|
33 | + * Creates an entity. |
|
34 | + * |
|
35 | + * @param array $input The input for the mutation |
|
36 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
37 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
38 | + * @return array |
|
39 | + * @throws UserError |
|
40 | + * @throws ReflectionException |
|
41 | + * @throws InvalidArgumentException |
|
42 | + * @throws InvalidInterfaceException |
|
43 | + * @throws InvalidDataTypeException |
|
44 | + * @throws EE_Error |
|
45 | + */ |
|
46 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | - /** |
|
49 | - * Stop now if a user isn't allowed to create a datetime. |
|
50 | - */ |
|
51 | - if (! current_user_can('ee_edit_events')) { |
|
52 | - // translators: the %1$s is the name of the object being mutated |
|
53 | - throw new UserError( |
|
54 | - sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | - ); |
|
56 | - } |
|
48 | + /** |
|
49 | + * Stop now if a user isn't allowed to create a datetime. |
|
50 | + */ |
|
51 | + if (! current_user_can('ee_edit_events')) { |
|
52 | + // translators: the %1$s is the name of the object being mutated |
|
53 | + throw new UserError( |
|
54 | + sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
|
55 | + ); |
|
56 | + } |
|
57 | 57 | |
58 | - $datetimes = []; |
|
58 | + $datetimes = []; |
|
59 | 59 | |
60 | - $args = TicketMutation::prepareFields($input); |
|
60 | + $args = TicketMutation::prepareFields($input); |
|
61 | 61 | |
62 | - if (isset($args['datetimes'])) { |
|
63 | - $datetimes = $args['datetimes']; |
|
64 | - unset($args['datetimes']); |
|
65 | - } |
|
62 | + if (isset($args['datetimes'])) { |
|
63 | + $datetimes = $args['datetimes']; |
|
64 | + unset($args['datetimes']); |
|
65 | + } |
|
66 | 66 | |
67 | - $entity = EE_Ticket::new_instance($args); |
|
68 | - $id = $entity->save(); |
|
67 | + $entity = EE_Ticket::new_instance($args); |
|
68 | + $id = $entity->save(); |
|
69 | 69 | |
70 | - if (empty($id)) { |
|
71 | - throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | - } |
|
70 | + if (empty($id)) { |
|
71 | + throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
|
72 | + } |
|
73 | 73 | |
74 | - if (! empty($datetimes)) { |
|
75 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
76 | - } |
|
74 | + if (! empty($datetimes)) { |
|
75 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
76 | + } |
|
77 | 77 | |
78 | - return [ |
|
79 | - 'id' => $id, |
|
80 | - ]; |
|
81 | - }; |
|
82 | - } |
|
78 | + return [ |
|
79 | + 'id' => $id, |
|
80 | + ]; |
|
81 | + }; |
|
82 | + } |
|
83 | 83 | } |
@@ -43,12 +43,12 @@ discard block |
||
43 | 43 | * @throws InvalidDataTypeException |
44 | 44 | * @throws EE_Error |
45 | 45 | */ |
46 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
46 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Stop now if a user isn't allowed to create a datetime. |
50 | 50 | */ |
51 | - if (! current_user_can('ee_edit_events')) { |
|
51 | + if ( ! current_user_can('ee_edit_events')) { |
|
52 | 52 | // translators: the %1$s is the name of the object being mutated |
53 | 53 | throw new UserError( |
54 | 54 | sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso'), $type->name()) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | throw new UserError(__('The object failed to create but no error was provided', 'event_espresso')); |
72 | 72 | } |
73 | 73 | |
74 | - if (! empty($datetimes)) { |
|
74 | + if ( ! empty($datetimes)) { |
|
75 | 75 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
76 | 76 | } |
77 | 77 |
@@ -11,63 +11,63 @@ |
||
11 | 11 | class DatetimeMutation |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Maps the GraphQL input to a format that the model functions can use |
|
16 | - * |
|
17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function prepareFields(array $input) |
|
21 | - { |
|
14 | + /** |
|
15 | + * Maps the GraphQL input to a format that the model functions can use |
|
16 | + * |
|
17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function prepareFields(array $input) |
|
21 | + { |
|
22 | 22 | |
23 | - $args = []; |
|
23 | + $args = []; |
|
24 | 24 | |
25 | - if (! empty($input['event'])) { |
|
26 | - $args['EVT_ID'] = absint($input['event']); |
|
27 | - } |
|
25 | + if (! empty($input['event'])) { |
|
26 | + $args['EVT_ID'] = absint($input['event']); |
|
27 | + } |
|
28 | 28 | |
29 | - if (! empty($input['name'])) { |
|
30 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
31 | - } |
|
29 | + if (! empty($input['name'])) { |
|
30 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
31 | + } |
|
32 | 32 | |
33 | - if (! empty($input['description'])) { |
|
34 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
35 | - } |
|
33 | + if (! empty($input['description'])) { |
|
34 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
35 | + } |
|
36 | 36 | |
37 | - if (! empty($input['startDate'])) { |
|
38 | - $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
39 | - } |
|
37 | + if (! empty($input['startDate'])) { |
|
38 | + $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
|
39 | + } |
|
40 | 40 | |
41 | - if (! empty($input['endDate'])) { |
|
42 | - $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
43 | - } |
|
41 | + if (! empty($input['endDate'])) { |
|
42 | + $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
|
43 | + } |
|
44 | 44 | |
45 | - if (! empty($input['tickets'])) { |
|
46 | - $args['tickets'] = array_filter(array_map('absint', (array) $input['tickets'])); |
|
47 | - } |
|
45 | + if (! empty($input['tickets'])) { |
|
46 | + $args['tickets'] = array_filter(array_map('absint', (array) $input['tickets'])); |
|
47 | + } |
|
48 | 48 | |
49 | - // Likewise the other fields... |
|
49 | + // Likewise the other fields... |
|
50 | 50 | |
51 | - return $args; |
|
52 | - } |
|
51 | + return $args; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Sets the related tickets for the given datetime. |
|
56 | - * |
|
57 | - * @param EE_Datetime $entity The datetime instance. |
|
58 | - * @param array $tickets Array of ticket IDs to relate. |
|
59 | - */ |
|
60 | - public static function setRelatedTickets($entity, array $tickets) |
|
61 | - { |
|
62 | - $relationName = 'Ticket'; |
|
63 | - // Remove all the existing related tickets |
|
64 | - $entity->_remove_relations($relationName); |
|
54 | + /** |
|
55 | + * Sets the related tickets for the given datetime. |
|
56 | + * |
|
57 | + * @param EE_Datetime $entity The datetime instance. |
|
58 | + * @param array $tickets Array of ticket IDs to relate. |
|
59 | + */ |
|
60 | + public static function setRelatedTickets($entity, array $tickets) |
|
61 | + { |
|
62 | + $relationName = 'Ticket'; |
|
63 | + // Remove all the existing related tickets |
|
64 | + $entity->_remove_relations($relationName); |
|
65 | 65 | |
66 | - foreach ($tickets as $ID) { |
|
67 | - $entity->_add_relation_to( |
|
68 | - $ID, |
|
69 | - $relationName |
|
70 | - ); |
|
71 | - } |
|
72 | - } |
|
66 | + foreach ($tickets as $ID) { |
|
67 | + $entity->_add_relation_to( |
|
68 | + $ID, |
|
69 | + $relationName |
|
70 | + ); |
|
71 | + } |
|
72 | + } |
|
73 | 73 | } |
@@ -22,27 +22,27 @@ |
||
22 | 22 | |
23 | 23 | $args = []; |
24 | 24 | |
25 | - if (! empty($input['event'])) { |
|
25 | + if ( ! empty($input['event'])) { |
|
26 | 26 | $args['EVT_ID'] = absint($input['event']); |
27 | 27 | } |
28 | 28 | |
29 | - if (! empty($input['name'])) { |
|
29 | + if ( ! empty($input['name'])) { |
|
30 | 30 | $args['DTT_name'] = sanitize_text_field($input['name']); |
31 | 31 | } |
32 | 32 | |
33 | - if (! empty($input['description'])) { |
|
33 | + if ( ! empty($input['description'])) { |
|
34 | 34 | $args['DTT_description'] = sanitize_text_field($input['description']); |
35 | 35 | } |
36 | 36 | |
37 | - if (! empty($input['startDate'])) { |
|
37 | + if ( ! empty($input['startDate'])) { |
|
38 | 38 | $args['DTT_EVT_start'] = sanitize_text_field($input['startDate']); |
39 | 39 | } |
40 | 40 | |
41 | - if (! empty($input['endDate'])) { |
|
41 | + if ( ! empty($input['endDate'])) { |
|
42 | 42 | $args['DTT_EVT_end'] = sanitize_text_field($input['endDate']); |
43 | 43 | } |
44 | 44 | |
45 | - if (! empty($input['tickets'])) { |
|
45 | + if ( ! empty($input['tickets'])) { |
|
46 | 46 | $args['tickets'] = array_filter(array_map('absint', (array) $input['tickets'])); |
47 | 47 | } |
48 | 48 |
@@ -11,55 +11,55 @@ |
||
11 | 11 | class TicketMutation |
12 | 12 | { |
13 | 13 | |
14 | - /** |
|
15 | - * Maps the GraphQL input to a format that the model functions can use |
|
16 | - * |
|
17 | - * @param array $input Data coming from the GraphQL mutation query input |
|
18 | - * @return array |
|
19 | - */ |
|
20 | - public static function prepareFields(array $input) |
|
21 | - { |
|
14 | + /** |
|
15 | + * Maps the GraphQL input to a format that the model functions can use |
|
16 | + * |
|
17 | + * @param array $input Data coming from the GraphQL mutation query input |
|
18 | + * @return array |
|
19 | + */ |
|
20 | + public static function prepareFields(array $input) |
|
21 | + { |
|
22 | 22 | |
23 | - $args = []; |
|
23 | + $args = []; |
|
24 | 24 | |
25 | - if (! empty($input['name'])) { |
|
26 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
27 | - } |
|
25 | + if (! empty($input['name'])) { |
|
26 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
27 | + } |
|
28 | 28 | |
29 | - if (! empty($input['description'])) { |
|
30 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
31 | - } |
|
29 | + if (! empty($input['description'])) { |
|
30 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
31 | + } |
|
32 | 32 | |
33 | - if (! empty($input['price'])) { |
|
34 | - $args['TKT_price'] = floatval($input['price']); |
|
35 | - } |
|
33 | + if (! empty($input['price'])) { |
|
34 | + $args['TKT_price'] = floatval($input['price']); |
|
35 | + } |
|
36 | 36 | |
37 | - if (! empty($input['datetimes'])) { |
|
38 | - $args['datetimes'] = array_filter(array_map('absint', (array) $input['datetimes'])); |
|
39 | - } |
|
37 | + if (! empty($input['datetimes'])) { |
|
38 | + $args['datetimes'] = array_filter(array_map('absint', (array) $input['datetimes'])); |
|
39 | + } |
|
40 | 40 | |
41 | - // Likewise the other fields... |
|
41 | + // Likewise the other fields... |
|
42 | 42 | |
43 | - return $args; |
|
44 | - } |
|
43 | + return $args; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Sets the related tickets for the given datetime. |
|
48 | - * |
|
49 | - * @param EE_Ticket $entity The Ticket instance. |
|
50 | - * @param array $datetimes Array of datetime IDs to relate. |
|
51 | - */ |
|
52 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
53 | - { |
|
54 | - $relationName = 'Datetime'; |
|
55 | - // Remove all the existing related datetimes |
|
56 | - $entity->_remove_relations($relationName); |
|
46 | + /** |
|
47 | + * Sets the related tickets for the given datetime. |
|
48 | + * |
|
49 | + * @param EE_Ticket $entity The Ticket instance. |
|
50 | + * @param array $datetimes Array of datetime IDs to relate. |
|
51 | + */ |
|
52 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
53 | + { |
|
54 | + $relationName = 'Datetime'; |
|
55 | + // Remove all the existing related datetimes |
|
56 | + $entity->_remove_relations($relationName); |
|
57 | 57 | |
58 | - foreach ($datetimes as $ID) { |
|
59 | - $entity->_add_relation_to( |
|
60 | - $ID, |
|
61 | - $relationName |
|
62 | - ); |
|
63 | - } |
|
64 | - } |
|
58 | + foreach ($datetimes as $ID) { |
|
59 | + $entity->_add_relation_to( |
|
60 | + $ID, |
|
61 | + $relationName |
|
62 | + ); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | } |
@@ -22,19 +22,19 @@ |
||
22 | 22 | |
23 | 23 | $args = []; |
24 | 24 | |
25 | - if (! empty($input['name'])) { |
|
25 | + if ( ! empty($input['name'])) { |
|
26 | 26 | $args['TKT_name'] = sanitize_text_field($input['name']); |
27 | 27 | } |
28 | 28 | |
29 | - if (! empty($input['description'])) { |
|
29 | + if ( ! empty($input['description'])) { |
|
30 | 30 | $args['TKT_description'] = sanitize_text_field($input['description']); |
31 | 31 | } |
32 | 32 | |
33 | - if (! empty($input['price'])) { |
|
33 | + if ( ! empty($input['price'])) { |
|
34 | 34 | $args['TKT_price'] = floatval($input['price']); |
35 | 35 | } |
36 | 36 | |
37 | - if (! empty($input['datetimes'])) { |
|
37 | + if ( ! empty($input['datetimes'])) { |
|
38 | 38 | $args['datetimes'] = array_filter(array_map('absint', (array) $input['datetimes'])); |
39 | 39 | } |
40 | 40 |