@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | /** |
52 | - * @return GraphQLFieldInterface[] |
|
52 | + * @return GraphQLField[] |
|
53 | 53 | * @since $VID:$ |
54 | 54 | */ |
55 | 55 | public function getFields() |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @param array $args The inputArgs on the field |
221 | 221 | * @param AppContext $context The AppContext passed down the GraphQL tree |
222 | 222 | * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
223 | - * @return string |
|
223 | + * @return boolean |
|
224 | 224 | * @throws Exception |
225 | 225 | * @throws InvalidArgumentException |
226 | 226 | * @throws InvalidDataTypeException |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
7 | 7 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
8 | 8 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
9 | - |
|
10 | 9 | use EE_Datetime; |
11 | 10 | use EEM_Datetime; |
12 | 11 | use EventEspresso\core\services\graphql\fields\GraphQLFieldInterface; |
@@ -33,272 +33,272 @@ |
||
33 | 33 | class Datetime extends TypeBase |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * EventDate constructor. |
|
38 | - * |
|
39 | - * @param EEM_Datetime $datetime_model |
|
40 | - */ |
|
41 | - public function __construct(EEM_Datetime $datetime_model) |
|
42 | - { |
|
43 | - $this->model = $datetime_model; |
|
44 | - $this->setName($this->namespace . 'Datetime'); |
|
45 | - $this->setDescription(__('An event date', 'event_espresso')); |
|
46 | - $this->setIsCustomPostType(false); |
|
47 | - parent::__construct(); |
|
48 | - } |
|
36 | + /** |
|
37 | + * EventDate constructor. |
|
38 | + * |
|
39 | + * @param EEM_Datetime $datetime_model |
|
40 | + */ |
|
41 | + public function __construct(EEM_Datetime $datetime_model) |
|
42 | + { |
|
43 | + $this->model = $datetime_model; |
|
44 | + $this->setName($this->namespace . 'Datetime'); |
|
45 | + $this->setDescription(__('An event date', 'event_espresso')); |
|
46 | + $this->setIsCustomPostType(false); |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return GraphQLFieldInterface[] |
|
53 | - * @since $VID:$ |
|
54 | - */ |
|
55 | - public function getFields() |
|
56 | - { |
|
57 | - return [ |
|
58 | - new GraphQLField( |
|
59 | - 'id', |
|
60 | - ['non_null' => 'ID'], |
|
61 | - null, |
|
62 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLOutputField( |
|
65 | - 'dbId', |
|
66 | - ['non_null' => 'Int'], |
|
67 | - 'ID', |
|
68 | - esc_html__('The datetime ID.', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLField( |
|
71 | - 'name', |
|
72 | - 'String', |
|
73 | - 'name', |
|
74 | - esc_html__('Datetime Name', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLField( |
|
77 | - 'description', |
|
78 | - 'String', |
|
79 | - 'description', |
|
80 | - esc_html__('Description for Datetime', 'event_espresso') |
|
81 | - ), |
|
82 | - new GraphQLField( |
|
83 | - 'startDate', |
|
84 | - 'String', |
|
85 | - 'start_date_and_time', |
|
86 | - esc_html__('Start date and time of the Event', 'event_espresso'), |
|
87 | - [$this, 'formatDatetime'] |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'endDate', |
|
91 | - 'String', |
|
92 | - 'end_date_and_time', |
|
93 | - esc_html__('End date and time of the Event', 'event_espresso'), |
|
94 | - [$this, 'formatDatetime'] |
|
95 | - ), |
|
96 | - new GraphQLField( |
|
97 | - 'capacity', |
|
98 | - 'Int', |
|
99 | - 'reg_limit', |
|
100 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
101 | - [$this, 'parseInfiniteValue'] |
|
102 | - ), |
|
103 | - new GraphQLField( |
|
104 | - 'sold', |
|
105 | - 'Int', |
|
106 | - 'sold', |
|
107 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
108 | - ), |
|
109 | - new GraphQLField( |
|
110 | - 'reserved', |
|
111 | - 'Int', |
|
112 | - 'reserved', |
|
113 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
114 | - ), |
|
115 | - new GraphQLField( |
|
116 | - 'order', |
|
117 | - 'Int', |
|
118 | - 'order', |
|
119 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
120 | - ), |
|
121 | - new GraphQLField( |
|
122 | - 'length', |
|
123 | - 'Int', |
|
124 | - 'length', |
|
125 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
126 | - ), |
|
127 | - new GraphQLOutputField( |
|
128 | - 'parent', |
|
129 | - $this->name(), |
|
130 | - null, |
|
131 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
132 | - ), |
|
133 | - new GraphQLInputField( |
|
134 | - 'parent', |
|
135 | - 'ID', |
|
136 | - null, |
|
137 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
138 | - ), |
|
139 | - new GraphQLField( |
|
140 | - 'isPrimary', |
|
141 | - 'Boolean', |
|
142 | - 'is_primary', |
|
143 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
144 | - ), |
|
145 | - new GraphQLField( |
|
146 | - 'isSoldOut', |
|
147 | - 'Boolean', |
|
148 | - 'sold_out', |
|
149 | - esc_html__( |
|
150 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
151 | - 'event_espresso' |
|
152 | - ) |
|
153 | - ), |
|
154 | - new GraphQLOutputField( |
|
155 | - 'isUpcoming', |
|
156 | - 'Boolean', |
|
157 | - 'is_upcoming', |
|
158 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
159 | - ), |
|
160 | - new GraphQLOutputField( |
|
161 | - 'isActive', |
|
162 | - 'Boolean', |
|
163 | - 'is_active', |
|
164 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
165 | - ), |
|
166 | - new GraphQLOutputField( |
|
167 | - 'isExpired', |
|
168 | - 'Boolean', |
|
169 | - 'is_expired', |
|
170 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
171 | - ), |
|
172 | - new GraphQLOutputField( |
|
173 | - 'event', |
|
174 | - $this->namespace . 'Event', |
|
175 | - null, |
|
176 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
177 | - ), |
|
178 | - new GraphQLInputField( |
|
179 | - 'eventId', |
|
180 | - 'Int', |
|
181 | - null, |
|
182 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
183 | - ), |
|
184 | - new GraphQLInputField( |
|
185 | - 'event', |
|
186 | - 'ID', |
|
187 | - null, |
|
188 | - esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
189 | - ), |
|
190 | - new GraphQLInputField( |
|
191 | - 'tickets', |
|
192 | - ['list_of' => 'ID'], |
|
193 | - null, |
|
194 | - sprintf( |
|
195 | - '%1$s %2$s', |
|
196 | - esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
197 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
198 | - ) |
|
199 | - ), |
|
200 | - new GraphQLOutputField( |
|
201 | - 'status', |
|
202 | - $this->namespace . 'DatetimeStatusEnum', |
|
203 | - 'get_active_status', |
|
204 | - esc_html__('Datetime status', 'event_espresso') |
|
205 | - ), |
|
206 | - new GraphQLOutputField( |
|
207 | - 'isDeleted', |
|
208 | - 'Boolean', |
|
209 | - null, |
|
210 | - esc_html__('Flag indicating whether the datetime is deleted', 'event_espresso'), |
|
211 | - null, |
|
212 | - [$this, 'getIsDeleted'] |
|
213 | - ), |
|
214 | - ]; |
|
215 | - } |
|
51 | + /** |
|
52 | + * @return GraphQLFieldInterface[] |
|
53 | + * @since $VID:$ |
|
54 | + */ |
|
55 | + public function getFields() |
|
56 | + { |
|
57 | + return [ |
|
58 | + new GraphQLField( |
|
59 | + 'id', |
|
60 | + ['non_null' => 'ID'], |
|
61 | + null, |
|
62 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLOutputField( |
|
65 | + 'dbId', |
|
66 | + ['non_null' => 'Int'], |
|
67 | + 'ID', |
|
68 | + esc_html__('The datetime ID.', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLField( |
|
71 | + 'name', |
|
72 | + 'String', |
|
73 | + 'name', |
|
74 | + esc_html__('Datetime Name', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLField( |
|
77 | + 'description', |
|
78 | + 'String', |
|
79 | + 'description', |
|
80 | + esc_html__('Description for Datetime', 'event_espresso') |
|
81 | + ), |
|
82 | + new GraphQLField( |
|
83 | + 'startDate', |
|
84 | + 'String', |
|
85 | + 'start_date_and_time', |
|
86 | + esc_html__('Start date and time of the Event', 'event_espresso'), |
|
87 | + [$this, 'formatDatetime'] |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'endDate', |
|
91 | + 'String', |
|
92 | + 'end_date_and_time', |
|
93 | + esc_html__('End date and time of the Event', 'event_espresso'), |
|
94 | + [$this, 'formatDatetime'] |
|
95 | + ), |
|
96 | + new GraphQLField( |
|
97 | + 'capacity', |
|
98 | + 'Int', |
|
99 | + 'reg_limit', |
|
100 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
101 | + [$this, 'parseInfiniteValue'] |
|
102 | + ), |
|
103 | + new GraphQLField( |
|
104 | + 'sold', |
|
105 | + 'Int', |
|
106 | + 'sold', |
|
107 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
108 | + ), |
|
109 | + new GraphQLField( |
|
110 | + 'reserved', |
|
111 | + 'Int', |
|
112 | + 'reserved', |
|
113 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
114 | + ), |
|
115 | + new GraphQLField( |
|
116 | + 'order', |
|
117 | + 'Int', |
|
118 | + 'order', |
|
119 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
120 | + ), |
|
121 | + new GraphQLField( |
|
122 | + 'length', |
|
123 | + 'Int', |
|
124 | + 'length', |
|
125 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
126 | + ), |
|
127 | + new GraphQLOutputField( |
|
128 | + 'parent', |
|
129 | + $this->name(), |
|
130 | + null, |
|
131 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
132 | + ), |
|
133 | + new GraphQLInputField( |
|
134 | + 'parent', |
|
135 | + 'ID', |
|
136 | + null, |
|
137 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
138 | + ), |
|
139 | + new GraphQLField( |
|
140 | + 'isPrimary', |
|
141 | + 'Boolean', |
|
142 | + 'is_primary', |
|
143 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
144 | + ), |
|
145 | + new GraphQLField( |
|
146 | + 'isSoldOut', |
|
147 | + 'Boolean', |
|
148 | + 'sold_out', |
|
149 | + esc_html__( |
|
150 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
151 | + 'event_espresso' |
|
152 | + ) |
|
153 | + ), |
|
154 | + new GraphQLOutputField( |
|
155 | + 'isUpcoming', |
|
156 | + 'Boolean', |
|
157 | + 'is_upcoming', |
|
158 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
159 | + ), |
|
160 | + new GraphQLOutputField( |
|
161 | + 'isActive', |
|
162 | + 'Boolean', |
|
163 | + 'is_active', |
|
164 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
165 | + ), |
|
166 | + new GraphQLOutputField( |
|
167 | + 'isExpired', |
|
168 | + 'Boolean', |
|
169 | + 'is_expired', |
|
170 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
171 | + ), |
|
172 | + new GraphQLOutputField( |
|
173 | + 'event', |
|
174 | + $this->namespace . 'Event', |
|
175 | + null, |
|
176 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
177 | + ), |
|
178 | + new GraphQLInputField( |
|
179 | + 'eventId', |
|
180 | + 'Int', |
|
181 | + null, |
|
182 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
183 | + ), |
|
184 | + new GraphQLInputField( |
|
185 | + 'event', |
|
186 | + 'ID', |
|
187 | + null, |
|
188 | + esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
189 | + ), |
|
190 | + new GraphQLInputField( |
|
191 | + 'tickets', |
|
192 | + ['list_of' => 'ID'], |
|
193 | + null, |
|
194 | + sprintf( |
|
195 | + '%1$s %2$s', |
|
196 | + esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
197 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
198 | + ) |
|
199 | + ), |
|
200 | + new GraphQLOutputField( |
|
201 | + 'status', |
|
202 | + $this->namespace . 'DatetimeStatusEnum', |
|
203 | + 'get_active_status', |
|
204 | + esc_html__('Datetime status', 'event_espresso') |
|
205 | + ), |
|
206 | + new GraphQLOutputField( |
|
207 | + 'isDeleted', |
|
208 | + 'Boolean', |
|
209 | + null, |
|
210 | + esc_html__('Flag indicating whether the datetime is deleted', 'event_espresso'), |
|
211 | + null, |
|
212 | + [$this, 'getIsDeleted'] |
|
213 | + ), |
|
214 | + ]; |
|
215 | + } |
|
216 | 216 | |
217 | 217 | |
218 | - /** |
|
219 | - * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
220 | - * @param array $args The inputArgs on the field |
|
221 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
222 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
223 | - * @return string |
|
224 | - * @throws Exception |
|
225 | - * @throws InvalidArgumentException |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - * @throws InvalidInterfaceException |
|
228 | - * @throws ReflectionException |
|
229 | - * @throws UserError |
|
230 | - * @throws UnexpectedEntityException |
|
231 | - * @since $VID:$ |
|
232 | - */ |
|
233 | - public function getIsDeleted(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
234 | - { |
|
235 | - return (bool) $source->get('DTT_deleted'); |
|
236 | - } |
|
218 | + /** |
|
219 | + * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
220 | + * @param array $args The inputArgs on the field |
|
221 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
222 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
223 | + * @return string |
|
224 | + * @throws Exception |
|
225 | + * @throws InvalidArgumentException |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + * @throws InvalidInterfaceException |
|
228 | + * @throws ReflectionException |
|
229 | + * @throws UserError |
|
230 | + * @throws UnexpectedEntityException |
|
231 | + * @since $VID:$ |
|
232 | + */ |
|
233 | + public function getIsDeleted(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
234 | + { |
|
235 | + return (bool) $source->get('DTT_deleted'); |
|
236 | + } |
|
237 | 237 | |
238 | 238 | |
239 | - /** |
|
240 | - * @param array $inputFields The mutation input fields. |
|
241 | - * @throws InvalidArgumentException |
|
242 | - * @throws ReflectionException |
|
243 | - * @since $VID:$ |
|
244 | - */ |
|
245 | - public function registerMutations(array $inputFields) |
|
246 | - { |
|
247 | - // Register mutation to update an entity. |
|
248 | - register_graphql_mutation( |
|
249 | - 'update' . $this->name(), |
|
250 | - [ |
|
251 | - 'inputFields' => $inputFields, |
|
252 | - 'outputFields' => [ |
|
253 | - lcfirst($this->name()) => [ |
|
254 | - 'type' => $this->name(), |
|
255 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
256 | - ], |
|
257 | - ], |
|
258 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
259 | - ] |
|
260 | - ); |
|
261 | - // Register mutation to delete an entity. |
|
262 | - register_graphql_mutation( |
|
263 | - 'delete' . $this->name(), |
|
264 | - [ |
|
265 | - 'inputFields' => [ |
|
266 | - 'id' => $inputFields['id'], |
|
267 | - 'deletePermanently' => [ |
|
268 | - 'type' => 'Boolean', |
|
269 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
270 | - ], |
|
271 | - ], |
|
272 | - 'outputFields' => [ |
|
273 | - lcfirst($this->name()) => [ |
|
274 | - 'type' => $this->name(), |
|
275 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
276 | - 'resolve' => static function ($payload) { |
|
277 | - $deleted = (object) $payload['deleted']; |
|
239 | + /** |
|
240 | + * @param array $inputFields The mutation input fields. |
|
241 | + * @throws InvalidArgumentException |
|
242 | + * @throws ReflectionException |
|
243 | + * @since $VID:$ |
|
244 | + */ |
|
245 | + public function registerMutations(array $inputFields) |
|
246 | + { |
|
247 | + // Register mutation to update an entity. |
|
248 | + register_graphql_mutation( |
|
249 | + 'update' . $this->name(), |
|
250 | + [ |
|
251 | + 'inputFields' => $inputFields, |
|
252 | + 'outputFields' => [ |
|
253 | + lcfirst($this->name()) => [ |
|
254 | + 'type' => $this->name(), |
|
255 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
256 | + ], |
|
257 | + ], |
|
258 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
259 | + ] |
|
260 | + ); |
|
261 | + // Register mutation to delete an entity. |
|
262 | + register_graphql_mutation( |
|
263 | + 'delete' . $this->name(), |
|
264 | + [ |
|
265 | + 'inputFields' => [ |
|
266 | + 'id' => $inputFields['id'], |
|
267 | + 'deletePermanently' => [ |
|
268 | + 'type' => 'Boolean', |
|
269 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
270 | + ], |
|
271 | + ], |
|
272 | + 'outputFields' => [ |
|
273 | + lcfirst($this->name()) => [ |
|
274 | + 'type' => $this->name(), |
|
275 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
276 | + 'resolve' => static function ($payload) { |
|
277 | + $deleted = (object) $payload['deleted']; |
|
278 | 278 | |
279 | - return ! empty($deleted) ? $deleted : null; |
|
280 | - }, |
|
281 | - ], |
|
282 | - ], |
|
283 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
284 | - ] |
|
285 | - ); |
|
279 | + return ! empty($deleted) ? $deleted : null; |
|
280 | + }, |
|
281 | + ], |
|
282 | + ], |
|
283 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
284 | + ] |
|
285 | + ); |
|
286 | 286 | |
287 | - // remove primary key from input. |
|
288 | - unset($inputFields['id']); |
|
289 | - // Register mutation to update an entity. |
|
290 | - register_graphql_mutation( |
|
291 | - 'create' . $this->name(), |
|
292 | - [ |
|
293 | - 'inputFields' => $inputFields, |
|
294 | - 'outputFields' => [ |
|
295 | - lcfirst($this->name()) => [ |
|
296 | - 'type' => $this->name(), |
|
297 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
298 | - ], |
|
299 | - ], |
|
300 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
301 | - ] |
|
302 | - ); |
|
303 | - } |
|
287 | + // remove primary key from input. |
|
288 | + unset($inputFields['id']); |
|
289 | + // Register mutation to update an entity. |
|
290 | + register_graphql_mutation( |
|
291 | + 'create' . $this->name(), |
|
292 | + [ |
|
293 | + 'inputFields' => $inputFields, |
|
294 | + 'outputFields' => [ |
|
295 | + lcfirst($this->name()) => [ |
|
296 | + 'type' => $this->name(), |
|
297 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
298 | + ], |
|
299 | + ], |
|
300 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
301 | + ] |
|
302 | + ); |
|
303 | + } |
|
304 | 304 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __construct(EEM_Datetime $datetime_model) |
42 | 42 | { |
43 | 43 | $this->model = $datetime_model; |
44 | - $this->setName($this->namespace . 'Datetime'); |
|
44 | + $this->setName($this->namespace.'Datetime'); |
|
45 | 45 | $this->setDescription(__('An event date', 'event_espresso')); |
46 | 46 | $this->setIsCustomPostType(false); |
47 | 47 | parent::__construct(); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | ), |
172 | 172 | new GraphQLOutputField( |
173 | 173 | 'event', |
174 | - $this->namespace . 'Event', |
|
174 | + $this->namespace.'Event', |
|
175 | 175 | null, |
176 | 176 | esc_html__('Event of the datetime.', 'event_espresso') |
177 | 177 | ), |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | ), |
200 | 200 | new GraphQLOutputField( |
201 | 201 | 'status', |
202 | - $this->namespace . 'DatetimeStatusEnum', |
|
202 | + $this->namespace.'DatetimeStatusEnum', |
|
203 | 203 | 'get_active_status', |
204 | 204 | esc_html__('Datetime status', 'event_espresso') |
205 | 205 | ), |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | { |
247 | 247 | // Register mutation to update an entity. |
248 | 248 | register_graphql_mutation( |
249 | - 'update' . $this->name(), |
|
249 | + 'update'.$this->name(), |
|
250 | 250 | [ |
251 | 251 | 'inputFields' => $inputFields, |
252 | 252 | 'outputFields' => [ |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | ); |
261 | 261 | // Register mutation to delete an entity. |
262 | 262 | register_graphql_mutation( |
263 | - 'delete' . $this->name(), |
|
263 | + 'delete'.$this->name(), |
|
264 | 264 | [ |
265 | 265 | 'inputFields' => [ |
266 | 266 | 'id' => $inputFields['id'], |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | lcfirst($this->name()) => [ |
274 | 274 | 'type' => $this->name(), |
275 | 275 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
276 | - 'resolve' => static function ($payload) { |
|
276 | + 'resolve' => static function($payload) { |
|
277 | 277 | $deleted = (object) $payload['deleted']; |
278 | 278 | |
279 | 279 | return ! empty($deleted) ? $deleted : null; |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | unset($inputFields['id']); |
289 | 289 | // Register mutation to update an entity. |
290 | 290 | register_graphql_mutation( |
291 | - 'create' . $this->name(), |
|
291 | + 'create'.$this->name(), |
|
292 | 292 | [ |
293 | 293 | 'inputFields' => $inputFields, |
294 | 294 | 'outputFields' => [ |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | |
51 | 51 | /** |
52 | - * @return GraphQLFieldInterface[] |
|
52 | + * @return GraphQLField[] |
|
53 | 53 | * @since $VID:$ |
54 | 54 | */ |
55 | 55 | public function getFields() |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @param array $args The inputArgs on the field |
269 | 269 | * @param AppContext $context The AppContext passed down the GraphQL tree |
270 | 270 | * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
271 | - * @return string |
|
271 | + * @return boolean |
|
272 | 272 | * @throws Exception |
273 | 273 | * @throws InvalidArgumentException |
274 | 274 | * @throws InvalidDataTypeException |
@@ -6,7 +6,6 @@ |
||
6 | 6 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
7 | 7 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
8 | 8 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
9 | - |
|
10 | 9 | use EE_Ticket; |
11 | 10 | use EEM_Ticket; |
12 | 11 | use EventEspresso\core\services\graphql\fields\GraphQLFieldInterface; |
@@ -33,320 +33,320 @@ |
||
33 | 33 | class Ticket extends TypeBase |
34 | 34 | { |
35 | 35 | |
36 | - /** |
|
37 | - * Ticket constructor. |
|
38 | - * |
|
39 | - * @param EEM_Ticket $ticket_model |
|
40 | - */ |
|
41 | - public function __construct(EEM_Ticket $ticket_model) |
|
42 | - { |
|
43 | - $this->model = $ticket_model; |
|
44 | - $this->setName($this->namespace . 'Ticket'); |
|
45 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
46 | - $this->setIsCustomPostType(false); |
|
47 | - parent::__construct(); |
|
48 | - } |
|
36 | + /** |
|
37 | + * Ticket constructor. |
|
38 | + * |
|
39 | + * @param EEM_Ticket $ticket_model |
|
40 | + */ |
|
41 | + public function __construct(EEM_Ticket $ticket_model) |
|
42 | + { |
|
43 | + $this->model = $ticket_model; |
|
44 | + $this->setName($this->namespace . 'Ticket'); |
|
45 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
46 | + $this->setIsCustomPostType(false); |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return GraphQLFieldInterface[] |
|
53 | - * @since $VID:$ |
|
54 | - */ |
|
55 | - public function getFields() |
|
56 | - { |
|
57 | - return [ |
|
58 | - new GraphQLField( |
|
59 | - 'id', |
|
60 | - ['non_null' => 'ID'], |
|
61 | - null, |
|
62 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLOutputField( |
|
65 | - 'dbId', |
|
66 | - ['non_null' => 'Int'], |
|
67 | - 'ID', |
|
68 | - esc_html__('Ticket ID', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLField( |
|
71 | - 'name', |
|
72 | - 'String', |
|
73 | - 'name', |
|
74 | - esc_html__('Ticket Name', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLField( |
|
77 | - 'description', |
|
78 | - 'String', |
|
79 | - 'description', |
|
80 | - esc_html__('Description of Ticket', 'event_espresso') |
|
81 | - ), |
|
82 | - new GraphQLField( |
|
83 | - 'startDate', |
|
84 | - 'String', |
|
85 | - 'start_date', |
|
86 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
87 | - [$this, 'formatDatetime'] |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'endDate', |
|
91 | - 'String', |
|
92 | - 'end_date', |
|
93 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
94 | - [$this, 'formatDatetime'] |
|
95 | - ), |
|
96 | - new GraphQLField( |
|
97 | - 'min', |
|
98 | - 'Int', |
|
99 | - 'min', |
|
100 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLField( |
|
103 | - 'max', |
|
104 | - 'Int', |
|
105 | - 'max', |
|
106 | - esc_html__( |
|
107 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
108 | - 'event_espresso' |
|
109 | - ), |
|
110 | - [$this, 'parseInfiniteValue'] |
|
111 | - ), |
|
112 | - new GraphQLField( |
|
113 | - 'price', |
|
114 | - 'Float', |
|
115 | - 'price', |
|
116 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
117 | - ), |
|
118 | - new GraphQLField( |
|
119 | - 'sold', |
|
120 | - 'Int', |
|
121 | - 'sold', |
|
122 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
123 | - ), |
|
124 | - new GraphQLField( |
|
125 | - 'quantity', |
|
126 | - 'Int', |
|
127 | - 'qty', |
|
128 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
129 | - [$this, 'parseInfiniteValue'] |
|
130 | - ), |
|
131 | - new GraphQLField( |
|
132 | - 'reserved', |
|
133 | - 'Int', |
|
134 | - 'reserved', |
|
135 | - esc_html__( |
|
136 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
137 | - 'event_espresso' |
|
138 | - ) |
|
139 | - ), |
|
140 | - new GraphQLField( |
|
141 | - 'uses', |
|
142 | - 'Int', |
|
143 | - 'uses', |
|
144 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
145 | - [$this, 'parseInfiniteValue'] |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'isRequired', |
|
149 | - 'Boolean', |
|
150 | - 'required', |
|
151 | - esc_html__( |
|
152 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
153 | - 'event_espresso' |
|
154 | - ) |
|
155 | - ), |
|
156 | - new GraphQLField( |
|
157 | - 'isTaxable', |
|
158 | - 'Boolean', |
|
159 | - 'taxable', |
|
160 | - esc_html__( |
|
161 | - 'Flag indicating whether there is tax applied on this ticket', |
|
162 | - 'event_espresso' |
|
163 | - ) |
|
164 | - ), |
|
165 | - new GraphQLField( |
|
166 | - 'isDefault', |
|
167 | - 'Boolean', |
|
168 | - 'is_default', |
|
169 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
170 | - ), |
|
171 | - new GraphQLField( |
|
172 | - 'order', |
|
173 | - 'Int', |
|
174 | - 'order', |
|
175 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
176 | - ), |
|
177 | - new GraphQLField( |
|
178 | - 'row', |
|
179 | - 'Int', |
|
180 | - 'row', |
|
181 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLOutputField( |
|
184 | - 'wpUser', |
|
185 | - 'User', |
|
186 | - null, |
|
187 | - esc_html__('Ticket Creator', 'event_espresso') |
|
188 | - ), |
|
189 | - new GraphQLInputField( |
|
190 | - 'wpUser', |
|
191 | - 'Int', |
|
192 | - null, |
|
193 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
194 | - ), |
|
195 | - new GraphQLOutputField( |
|
196 | - 'parent', |
|
197 | - $this->name(), |
|
198 | - null, |
|
199 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | - ), |
|
201 | - new GraphQLInputField( |
|
202 | - 'parent', |
|
203 | - 'ID', |
|
204 | - null, |
|
205 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLField( |
|
208 | - 'reverseCalculate', |
|
209 | - 'Boolean', |
|
210 | - 'reverse_calculate', |
|
211 | - esc_html__( |
|
212 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
213 | - 'event_espresso' |
|
214 | - ) |
|
215 | - ), |
|
216 | - new GraphQLField( |
|
217 | - 'isFree', |
|
218 | - 'Boolean', |
|
219 | - 'is_free', |
|
220 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
221 | - ), |
|
222 | - new GraphQLOutputField( |
|
223 | - 'event', |
|
224 | - $this->namespace . 'Event', |
|
225 | - null, |
|
226 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
227 | - ), |
|
228 | - new GraphQLInputField( |
|
229 | - 'datetimes', |
|
230 | - ['list_of' => 'ID'], |
|
231 | - null, |
|
232 | - sprintf( |
|
233 | - '%1$s %2$s', |
|
234 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
235 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
236 | - ) |
|
237 | - ), |
|
238 | - new GraphQLInputField( |
|
239 | - 'prices', |
|
240 | - ['list_of' => 'ID'], |
|
241 | - null, |
|
242 | - sprintf( |
|
243 | - '%1$s %2$s', |
|
244 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
245 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
246 | - ) |
|
247 | - ), |
|
248 | - new GraphQLOutputField( |
|
249 | - 'status', |
|
250 | - $this->namespace . 'TicketStatusEnum', |
|
251 | - 'ticket_status', |
|
252 | - esc_html__('Ticket status', 'event_espresso') |
|
253 | - ), |
|
254 | - new GraphQLOutputField( |
|
255 | - 'isSoldOut', |
|
256 | - 'Boolean', |
|
257 | - null, |
|
258 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
259 | - null, |
|
260 | - [$this, 'getIsSoldOut'] |
|
261 | - ), |
|
262 | - ]; |
|
263 | - } |
|
51 | + /** |
|
52 | + * @return GraphQLFieldInterface[] |
|
53 | + * @since $VID:$ |
|
54 | + */ |
|
55 | + public function getFields() |
|
56 | + { |
|
57 | + return [ |
|
58 | + new GraphQLField( |
|
59 | + 'id', |
|
60 | + ['non_null' => 'ID'], |
|
61 | + null, |
|
62 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLOutputField( |
|
65 | + 'dbId', |
|
66 | + ['non_null' => 'Int'], |
|
67 | + 'ID', |
|
68 | + esc_html__('Ticket ID', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLField( |
|
71 | + 'name', |
|
72 | + 'String', |
|
73 | + 'name', |
|
74 | + esc_html__('Ticket Name', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLField( |
|
77 | + 'description', |
|
78 | + 'String', |
|
79 | + 'description', |
|
80 | + esc_html__('Description of Ticket', 'event_espresso') |
|
81 | + ), |
|
82 | + new GraphQLField( |
|
83 | + 'startDate', |
|
84 | + 'String', |
|
85 | + 'start_date', |
|
86 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
87 | + [$this, 'formatDatetime'] |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'endDate', |
|
91 | + 'String', |
|
92 | + 'end_date', |
|
93 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
94 | + [$this, 'formatDatetime'] |
|
95 | + ), |
|
96 | + new GraphQLField( |
|
97 | + 'min', |
|
98 | + 'Int', |
|
99 | + 'min', |
|
100 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLField( |
|
103 | + 'max', |
|
104 | + 'Int', |
|
105 | + 'max', |
|
106 | + esc_html__( |
|
107 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
108 | + 'event_espresso' |
|
109 | + ), |
|
110 | + [$this, 'parseInfiniteValue'] |
|
111 | + ), |
|
112 | + new GraphQLField( |
|
113 | + 'price', |
|
114 | + 'Float', |
|
115 | + 'price', |
|
116 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
117 | + ), |
|
118 | + new GraphQLField( |
|
119 | + 'sold', |
|
120 | + 'Int', |
|
121 | + 'sold', |
|
122 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
123 | + ), |
|
124 | + new GraphQLField( |
|
125 | + 'quantity', |
|
126 | + 'Int', |
|
127 | + 'qty', |
|
128 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
129 | + [$this, 'parseInfiniteValue'] |
|
130 | + ), |
|
131 | + new GraphQLField( |
|
132 | + 'reserved', |
|
133 | + 'Int', |
|
134 | + 'reserved', |
|
135 | + esc_html__( |
|
136 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
137 | + 'event_espresso' |
|
138 | + ) |
|
139 | + ), |
|
140 | + new GraphQLField( |
|
141 | + 'uses', |
|
142 | + 'Int', |
|
143 | + 'uses', |
|
144 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
145 | + [$this, 'parseInfiniteValue'] |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'isRequired', |
|
149 | + 'Boolean', |
|
150 | + 'required', |
|
151 | + esc_html__( |
|
152 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
153 | + 'event_espresso' |
|
154 | + ) |
|
155 | + ), |
|
156 | + new GraphQLField( |
|
157 | + 'isTaxable', |
|
158 | + 'Boolean', |
|
159 | + 'taxable', |
|
160 | + esc_html__( |
|
161 | + 'Flag indicating whether there is tax applied on this ticket', |
|
162 | + 'event_espresso' |
|
163 | + ) |
|
164 | + ), |
|
165 | + new GraphQLField( |
|
166 | + 'isDefault', |
|
167 | + 'Boolean', |
|
168 | + 'is_default', |
|
169 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
170 | + ), |
|
171 | + new GraphQLField( |
|
172 | + 'order', |
|
173 | + 'Int', |
|
174 | + 'order', |
|
175 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
176 | + ), |
|
177 | + new GraphQLField( |
|
178 | + 'row', |
|
179 | + 'Int', |
|
180 | + 'row', |
|
181 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLOutputField( |
|
184 | + 'wpUser', |
|
185 | + 'User', |
|
186 | + null, |
|
187 | + esc_html__('Ticket Creator', 'event_espresso') |
|
188 | + ), |
|
189 | + new GraphQLInputField( |
|
190 | + 'wpUser', |
|
191 | + 'Int', |
|
192 | + null, |
|
193 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
194 | + ), |
|
195 | + new GraphQLOutputField( |
|
196 | + 'parent', |
|
197 | + $this->name(), |
|
198 | + null, |
|
199 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | + ), |
|
201 | + new GraphQLInputField( |
|
202 | + 'parent', |
|
203 | + 'ID', |
|
204 | + null, |
|
205 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLField( |
|
208 | + 'reverseCalculate', |
|
209 | + 'Boolean', |
|
210 | + 'reverse_calculate', |
|
211 | + esc_html__( |
|
212 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
213 | + 'event_espresso' |
|
214 | + ) |
|
215 | + ), |
|
216 | + new GraphQLField( |
|
217 | + 'isFree', |
|
218 | + 'Boolean', |
|
219 | + 'is_free', |
|
220 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
221 | + ), |
|
222 | + new GraphQLOutputField( |
|
223 | + 'event', |
|
224 | + $this->namespace . 'Event', |
|
225 | + null, |
|
226 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
227 | + ), |
|
228 | + new GraphQLInputField( |
|
229 | + 'datetimes', |
|
230 | + ['list_of' => 'ID'], |
|
231 | + null, |
|
232 | + sprintf( |
|
233 | + '%1$s %2$s', |
|
234 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
235 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
236 | + ) |
|
237 | + ), |
|
238 | + new GraphQLInputField( |
|
239 | + 'prices', |
|
240 | + ['list_of' => 'ID'], |
|
241 | + null, |
|
242 | + sprintf( |
|
243 | + '%1$s %2$s', |
|
244 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
245 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
246 | + ) |
|
247 | + ), |
|
248 | + new GraphQLOutputField( |
|
249 | + 'status', |
|
250 | + $this->namespace . 'TicketStatusEnum', |
|
251 | + 'ticket_status', |
|
252 | + esc_html__('Ticket status', 'event_espresso') |
|
253 | + ), |
|
254 | + new GraphQLOutputField( |
|
255 | + 'isSoldOut', |
|
256 | + 'Boolean', |
|
257 | + null, |
|
258 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
259 | + null, |
|
260 | + [$this, 'getIsSoldOut'] |
|
261 | + ), |
|
262 | + ]; |
|
263 | + } |
|
264 | 264 | |
265 | 265 | |
266 | - /** |
|
267 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
268 | - * @param array $args The inputArgs on the field |
|
269 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
270 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
271 | - * @return string |
|
272 | - * @throws Exception |
|
273 | - * @throws InvalidArgumentException |
|
274 | - * @throws InvalidDataTypeException |
|
275 | - * @throws InvalidInterfaceException |
|
276 | - * @throws ReflectionException |
|
277 | - * @throws UserError |
|
278 | - * @throws UnexpectedEntityException |
|
279 | - * @since $VID:$ |
|
280 | - */ |
|
281 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
282 | - { |
|
283 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
284 | - } |
|
266 | + /** |
|
267 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
268 | + * @param array $args The inputArgs on the field |
|
269 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
270 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
271 | + * @return string |
|
272 | + * @throws Exception |
|
273 | + * @throws InvalidArgumentException |
|
274 | + * @throws InvalidDataTypeException |
|
275 | + * @throws InvalidInterfaceException |
|
276 | + * @throws ReflectionException |
|
277 | + * @throws UserError |
|
278 | + * @throws UnexpectedEntityException |
|
279 | + * @since $VID:$ |
|
280 | + */ |
|
281 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
282 | + { |
|
283 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
284 | + } |
|
285 | 285 | |
286 | 286 | |
287 | - /** |
|
288 | - * @param array $inputFields The mutation input fields. |
|
289 | - * @throws InvalidArgumentException |
|
290 | - * @throws ReflectionException |
|
291 | - * @since $VID:$ |
|
292 | - */ |
|
293 | - public function registerMutations(array $inputFields) |
|
294 | - { |
|
295 | - // Register mutation to update an entity. |
|
296 | - register_graphql_mutation( |
|
297 | - 'update' . $this->name(), |
|
298 | - [ |
|
299 | - 'inputFields' => $inputFields, |
|
300 | - 'outputFields' => [ |
|
301 | - lcfirst($this->name()) => [ |
|
302 | - 'type' => $this->name(), |
|
303 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
304 | - ], |
|
305 | - ], |
|
306 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
307 | - ] |
|
308 | - ); |
|
309 | - // Register mutation to delete an entity. |
|
310 | - register_graphql_mutation( |
|
311 | - 'delete' . $this->name(), |
|
312 | - [ |
|
313 | - 'inputFields' => [ |
|
314 | - 'id' => $inputFields['id'], |
|
315 | - 'deletePermanently' => [ |
|
316 | - 'type' => 'Boolean', |
|
317 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
318 | - ], |
|
319 | - ], |
|
320 | - 'outputFields' => [ |
|
321 | - lcfirst($this->name()) => [ |
|
322 | - 'type' => $this->name(), |
|
323 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
324 | - 'resolve' => static function ($payload) { |
|
325 | - $deleted = (object) $payload['deleted']; |
|
287 | + /** |
|
288 | + * @param array $inputFields The mutation input fields. |
|
289 | + * @throws InvalidArgumentException |
|
290 | + * @throws ReflectionException |
|
291 | + * @since $VID:$ |
|
292 | + */ |
|
293 | + public function registerMutations(array $inputFields) |
|
294 | + { |
|
295 | + // Register mutation to update an entity. |
|
296 | + register_graphql_mutation( |
|
297 | + 'update' . $this->name(), |
|
298 | + [ |
|
299 | + 'inputFields' => $inputFields, |
|
300 | + 'outputFields' => [ |
|
301 | + lcfirst($this->name()) => [ |
|
302 | + 'type' => $this->name(), |
|
303 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
304 | + ], |
|
305 | + ], |
|
306 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
307 | + ] |
|
308 | + ); |
|
309 | + // Register mutation to delete an entity. |
|
310 | + register_graphql_mutation( |
|
311 | + 'delete' . $this->name(), |
|
312 | + [ |
|
313 | + 'inputFields' => [ |
|
314 | + 'id' => $inputFields['id'], |
|
315 | + 'deletePermanently' => [ |
|
316 | + 'type' => 'Boolean', |
|
317 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
318 | + ], |
|
319 | + ], |
|
320 | + 'outputFields' => [ |
|
321 | + lcfirst($this->name()) => [ |
|
322 | + 'type' => $this->name(), |
|
323 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
324 | + 'resolve' => static function ($payload) { |
|
325 | + $deleted = (object) $payload['deleted']; |
|
326 | 326 | |
327 | - return ! empty($deleted) ? $deleted : null; |
|
328 | - }, |
|
329 | - ], |
|
330 | - ], |
|
331 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
332 | - ] |
|
333 | - ); |
|
327 | + return ! empty($deleted) ? $deleted : null; |
|
328 | + }, |
|
329 | + ], |
|
330 | + ], |
|
331 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
332 | + ] |
|
333 | + ); |
|
334 | 334 | |
335 | - // remove primary key from input. |
|
336 | - unset($inputFields['id']); |
|
337 | - // Register mutation to update an entity. |
|
338 | - register_graphql_mutation( |
|
339 | - 'create' . $this->name(), |
|
340 | - [ |
|
341 | - 'inputFields' => $inputFields, |
|
342 | - 'outputFields' => [ |
|
343 | - lcfirst($this->name()) => [ |
|
344 | - 'type' => $this->name(), |
|
345 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
346 | - ], |
|
347 | - ], |
|
348 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
349 | - ] |
|
350 | - ); |
|
351 | - } |
|
335 | + // remove primary key from input. |
|
336 | + unset($inputFields['id']); |
|
337 | + // Register mutation to update an entity. |
|
338 | + register_graphql_mutation( |
|
339 | + 'create' . $this->name(), |
|
340 | + [ |
|
341 | + 'inputFields' => $inputFields, |
|
342 | + 'outputFields' => [ |
|
343 | + lcfirst($this->name()) => [ |
|
344 | + 'type' => $this->name(), |
|
345 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
346 | + ], |
|
347 | + ], |
|
348 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
349 | + ] |
|
350 | + ); |
|
351 | + } |
|
352 | 352 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | public function __construct(EEM_Ticket $ticket_model) |
42 | 42 | { |
43 | 43 | $this->model = $ticket_model; |
44 | - $this->setName($this->namespace . 'Ticket'); |
|
44 | + $this->setName($this->namespace.'Ticket'); |
|
45 | 45 | $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
46 | 46 | $this->setIsCustomPostType(false); |
47 | 47 | parent::__construct(); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | ), |
222 | 222 | new GraphQLOutputField( |
223 | 223 | 'event', |
224 | - $this->namespace . 'Event', |
|
224 | + $this->namespace.'Event', |
|
225 | 225 | null, |
226 | 226 | esc_html__('Event of the ticket.', 'event_espresso') |
227 | 227 | ), |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | ), |
248 | 248 | new GraphQLOutputField( |
249 | 249 | 'status', |
250 | - $this->namespace . 'TicketStatusEnum', |
|
250 | + $this->namespace.'TicketStatusEnum', |
|
251 | 251 | 'ticket_status', |
252 | 252 | esc_html__('Ticket status', 'event_espresso') |
253 | 253 | ), |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | { |
295 | 295 | // Register mutation to update an entity. |
296 | 296 | register_graphql_mutation( |
297 | - 'update' . $this->name(), |
|
297 | + 'update'.$this->name(), |
|
298 | 298 | [ |
299 | 299 | 'inputFields' => $inputFields, |
300 | 300 | 'outputFields' => [ |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | ); |
309 | 309 | // Register mutation to delete an entity. |
310 | 310 | register_graphql_mutation( |
311 | - 'delete' . $this->name(), |
|
311 | + 'delete'.$this->name(), |
|
312 | 312 | [ |
313 | 313 | 'inputFields' => [ |
314 | 314 | 'id' => $inputFields['id'], |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | lcfirst($this->name()) => [ |
322 | 322 | 'type' => $this->name(), |
323 | 323 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
324 | - 'resolve' => static function ($payload) { |
|
324 | + 'resolve' => static function($payload) { |
|
325 | 325 | $deleted = (object) $payload['deleted']; |
326 | 326 | |
327 | 327 | return ! empty($deleted) ? $deleted : null; |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | unset($inputFields['id']); |
337 | 337 | // Register mutation to update an entity. |
338 | 338 | register_graphql_mutation( |
339 | - 'create' . $this->name(), |
|
339 | + 'create'.$this->name(), |
|
340 | 340 | [ |
341 | 341 | 'inputFields' => $inputFields, |
342 | 342 | 'outputFields' => [ |
@@ -19,180 +19,180 @@ |
||
19 | 19 | class DatetimeConnectionResolver extends AbstractConnectionResolver |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @return EEM_Datetime |
|
24 | - * @throws EE_Error |
|
25 | - * @throws InvalidArgumentException |
|
26 | - * @throws InvalidDataTypeException |
|
27 | - * @throws InvalidInterfaceException |
|
28 | - */ |
|
29 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
30 | - public function get_query() |
|
31 | - { |
|
32 | - return EEM_Datetime::instance(); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Return an array of items from the query |
|
37 | - * |
|
38 | - * @return array |
|
39 | - */ |
|
40 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | - public function get_items() |
|
42 | - { |
|
43 | - $results = $this->query->get_col($this->query_args); |
|
44 | - |
|
45 | - return ! empty($results) ? $results : []; |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Determine whether the Query should execute. If it's determined that the query should |
|
50 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
51 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
52 | - * |
|
53 | - * Return false to prevent the query from executing. |
|
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
57 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | - public function should_execute() |
|
59 | - { |
|
60 | - if (false === $this->should_execute) { |
|
61 | - return false; |
|
62 | - } |
|
63 | - |
|
64 | - return $this->should_execute; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
69 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
70 | - * handle batch resolution of the posts. |
|
71 | - * |
|
72 | - * @return array |
|
73 | - * @throws EE_Error |
|
74 | - * @throws InvalidArgumentException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - */ |
|
78 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | - public function get_query_args() |
|
80 | - { |
|
81 | - $where_params = ['DTT_deleted' => ['IN', [true, false]]]; |
|
82 | - $query_args = []; |
|
83 | - |
|
84 | - $query_args['limit'] = $this->getLimit(); |
|
85 | - |
|
86 | - // Avoid multiple entries by join. |
|
87 | - $query_args['group_by'] = 'DTT_ID'; |
|
88 | - |
|
89 | - /** |
|
90 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | - */ |
|
92 | - $input_fields = []; |
|
93 | - if (! empty($this->args['where'])) { |
|
94 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | - |
|
96 | - // Use the proper operator. |
|
97 | - if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
98 | - $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; |
|
99 | - } |
|
100 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
101 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - /** |
|
106 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
107 | - * |
|
108 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
109 | - * set the query to pull datetimes that belong to that event. |
|
110 | - * We can set more cases for other source types. |
|
111 | - */ |
|
112 | - if (is_object($this->source)) { |
|
113 | - switch (true) { |
|
114 | - // It's surely an event |
|
115 | - case $this->source instanceof Post: |
|
116 | - $where_params['EVT_ID'] = $this->source->ID; |
|
117 | - break; |
|
118 | - case $this->source instanceof EE_Event: |
|
119 | - $where_params['EVT_ID'] = $this->source->ID(); |
|
120 | - break; |
|
121 | - case $this->source instanceof EE_Ticket: |
|
122 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
123 | - break; |
|
124 | - case $this->source instanceof EE_Checkin: |
|
125 | - $where_params['Checkin.CHK_ID'] = $this->source->ID(); |
|
126 | - break; |
|
127 | - } |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Merge the input_fields with the default query_args |
|
132 | - */ |
|
133 | - if (! empty($input_fields)) { |
|
134 | - $where_params = array_merge($where_params, $input_fields); |
|
135 | - } |
|
136 | - |
|
137 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); |
|
138 | - |
|
139 | - if (! empty($this->args['where']['upcoming'])) { |
|
140 | - $where_params['DTT_EVT_start'] = array( |
|
141 | - '>', |
|
142 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
143 | - ); |
|
144 | - } |
|
145 | - |
|
146 | - if (! empty($this->args['where']['active'])) { |
|
147 | - $where_params['DTT_EVT_start'] = array( |
|
148 | - '<', |
|
149 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
150 | - ); |
|
151 | - $where_params['DTT_EVT_end'] = array( |
|
152 | - '>', |
|
153 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
154 | - ); |
|
155 | - } |
|
156 | - |
|
157 | - if (! empty($this->args['where']['expired'])) { |
|
158 | - $where_params['DTT_EVT_end'] = array( |
|
159 | - '<', |
|
160 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - $query_args[] = $where_params; |
|
165 | - |
|
166 | - /** |
|
167 | - * Return the $query_args |
|
168 | - */ |
|
169 | - return $query_args; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
175 | - * friendly keys. |
|
176 | - * |
|
177 | - * @param array $where_args |
|
178 | - * @return array |
|
179 | - */ |
|
180 | - public function sanitizeInputFields(array $where_args) |
|
181 | - { |
|
182 | - $arg_mapping = [ |
|
183 | - 'event' => 'EVT_ID', |
|
184 | - 'eventIn' => 'EVT_ID', |
|
185 | - 'eventId' => 'EVT_ID', |
|
186 | - 'eventIdIn' => 'EVT_ID', |
|
187 | - 'ticket' => 'Ticket.TKT_ID', |
|
188 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
189 | - 'ticketId' => 'Ticket.TKT_ID', |
|
190 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
191 | - ]; |
|
192 | - return $this->sanitizeWhereArgsForInputFields( |
|
193 | - $where_args, |
|
194 | - $arg_mapping, |
|
195 | - ['event', 'eventIn', 'ticket', 'ticketIn'] |
|
196 | - ); |
|
197 | - } |
|
22 | + /** |
|
23 | + * @return EEM_Datetime |
|
24 | + * @throws EE_Error |
|
25 | + * @throws InvalidArgumentException |
|
26 | + * @throws InvalidDataTypeException |
|
27 | + * @throws InvalidInterfaceException |
|
28 | + */ |
|
29 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
30 | + public function get_query() |
|
31 | + { |
|
32 | + return EEM_Datetime::instance(); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Return an array of items from the query |
|
37 | + * |
|
38 | + * @return array |
|
39 | + */ |
|
40 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
41 | + public function get_items() |
|
42 | + { |
|
43 | + $results = $this->query->get_col($this->query_args); |
|
44 | + |
|
45 | + return ! empty($results) ? $results : []; |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Determine whether the Query should execute. If it's determined that the query should |
|
50 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
51 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
52 | + * |
|
53 | + * Return false to prevent the query from executing. |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
58 | + public function should_execute() |
|
59 | + { |
|
60 | + if (false === $this->should_execute) { |
|
61 | + return false; |
|
62 | + } |
|
63 | + |
|
64 | + return $this->should_execute; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
69 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
70 | + * handle batch resolution of the posts. |
|
71 | + * |
|
72 | + * @return array |
|
73 | + * @throws EE_Error |
|
74 | + * @throws InvalidArgumentException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + */ |
|
78 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | + public function get_query_args() |
|
80 | + { |
|
81 | + $where_params = ['DTT_deleted' => ['IN', [true, false]]]; |
|
82 | + $query_args = []; |
|
83 | + |
|
84 | + $query_args['limit'] = $this->getLimit(); |
|
85 | + |
|
86 | + // Avoid multiple entries by join. |
|
87 | + $query_args['group_by'] = 'DTT_ID'; |
|
88 | + |
|
89 | + /** |
|
90 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | + */ |
|
92 | + $input_fields = []; |
|
93 | + if (! empty($this->args['where'])) { |
|
94 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | + |
|
96 | + // Use the proper operator. |
|
97 | + if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
98 | + $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; |
|
99 | + } |
|
100 | + if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
101 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + /** |
|
106 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
107 | + * |
|
108 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
109 | + * set the query to pull datetimes that belong to that event. |
|
110 | + * We can set more cases for other source types. |
|
111 | + */ |
|
112 | + if (is_object($this->source)) { |
|
113 | + switch (true) { |
|
114 | + // It's surely an event |
|
115 | + case $this->source instanceof Post: |
|
116 | + $where_params['EVT_ID'] = $this->source->ID; |
|
117 | + break; |
|
118 | + case $this->source instanceof EE_Event: |
|
119 | + $where_params['EVT_ID'] = $this->source->ID(); |
|
120 | + break; |
|
121 | + case $this->source instanceof EE_Ticket: |
|
122 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
123 | + break; |
|
124 | + case $this->source instanceof EE_Checkin: |
|
125 | + $where_params['Checkin.CHK_ID'] = $this->source->ID(); |
|
126 | + break; |
|
127 | + } |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Merge the input_fields with the default query_args |
|
132 | + */ |
|
133 | + if (! empty($input_fields)) { |
|
134 | + $where_params = array_merge($where_params, $input_fields); |
|
135 | + } |
|
136 | + |
|
137 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); |
|
138 | + |
|
139 | + if (! empty($this->args['where']['upcoming'])) { |
|
140 | + $where_params['DTT_EVT_start'] = array( |
|
141 | + '>', |
|
142 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
143 | + ); |
|
144 | + } |
|
145 | + |
|
146 | + if (! empty($this->args['where']['active'])) { |
|
147 | + $where_params['DTT_EVT_start'] = array( |
|
148 | + '<', |
|
149 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
150 | + ); |
|
151 | + $where_params['DTT_EVT_end'] = array( |
|
152 | + '>', |
|
153 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
154 | + ); |
|
155 | + } |
|
156 | + |
|
157 | + if (! empty($this->args['where']['expired'])) { |
|
158 | + $where_params['DTT_EVT_end'] = array( |
|
159 | + '<', |
|
160 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + $query_args[] = $where_params; |
|
165 | + |
|
166 | + /** |
|
167 | + * Return the $query_args |
|
168 | + */ |
|
169 | + return $query_args; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
175 | + * friendly keys. |
|
176 | + * |
|
177 | + * @param array $where_args |
|
178 | + * @return array |
|
179 | + */ |
|
180 | + public function sanitizeInputFields(array $where_args) |
|
181 | + { |
|
182 | + $arg_mapping = [ |
|
183 | + 'event' => 'EVT_ID', |
|
184 | + 'eventIn' => 'EVT_ID', |
|
185 | + 'eventId' => 'EVT_ID', |
|
186 | + 'eventIdIn' => 'EVT_ID', |
|
187 | + 'ticket' => 'Ticket.TKT_ID', |
|
188 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
189 | + 'ticketId' => 'Ticket.TKT_ID', |
|
190 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
191 | + ]; |
|
192 | + return $this->sanitizeWhereArgsForInputFields( |
|
193 | + $where_args, |
|
194 | + $arg_mapping, |
|
195 | + ['event', 'eventIn', 'ticket', 'ticketIn'] |
|
196 | + ); |
|
197 | + } |
|
198 | 198 | } |
@@ -16,133 +16,133 @@ |
||
16 | 16 | class TicketConnectionResolver extends AbstractConnectionResolver |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @return EEM_Ticket |
|
21 | - * @throws EE_Error |
|
22 | - * @throws InvalidArgumentException |
|
23 | - * @throws InvalidDataTypeException |
|
24 | - * @throws InvalidInterfaceException |
|
25 | - */ |
|
26 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
27 | - public function get_query() |
|
28 | - { |
|
29 | - return EEM_Ticket::instance(); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * Return an array of items from the query |
|
35 | - * |
|
36 | - * @return array |
|
37 | - */ |
|
38 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
39 | - public function get_items() |
|
40 | - { |
|
41 | - $results = $this->query->get_col($this->query_args); |
|
42 | - |
|
43 | - return ! empty($results) ? $results : []; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * Determine whether the Query should execute. If it's determined that the query should |
|
49 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
50 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
51 | - * Return false to prevent the query from executing. |
|
52 | - * |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
56 | - public function should_execute() |
|
57 | - { |
|
58 | - if (false === $this->should_execute) { |
|
59 | - return false; |
|
60 | - } |
|
61 | - |
|
62 | - return $this->should_execute; |
|
63 | - } |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
68 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
69 | - * handle batch resolution of the posts. |
|
70 | - * |
|
71 | - * @return array |
|
72 | - * @throws EE_Error |
|
73 | - * @throws InvalidArgumentException |
|
74 | - * @throws ReflectionException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - */ |
|
78 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | - public function get_query_args() |
|
80 | - { |
|
81 | - $where_params = ['TKT_deleted' => ['IN', [true, false]]]; |
|
82 | - $query_args = []; |
|
83 | - |
|
84 | - $query_args['limit'] = $this->getLimit(); |
|
85 | - |
|
86 | - // Avoid multiple entries by join. |
|
87 | - $query_args['group_by'] = 'TKT_ID'; |
|
88 | - |
|
89 | - /** |
|
90 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | - */ |
|
92 | - $input_fields = []; |
|
93 | - if (! empty($this->args['where'])) { |
|
94 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | - |
|
96 | - // Use the proper operator. |
|
97 | - if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
98 | - $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
104 | - */ |
|
105 | - if ($this->source instanceof EE_Datetime) { |
|
106 | - $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
107 | - } |
|
108 | - |
|
109 | - /** |
|
110 | - * Merge the input_fields with the default query_args |
|
111 | - */ |
|
112 | - if (! empty($input_fields)) { |
|
113 | - $where_params = array_merge($where_params, $input_fields); |
|
114 | - } |
|
115 | - |
|
116 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); |
|
117 | - |
|
118 | - $query_args[] = $where_params; |
|
119 | - |
|
120 | - /** |
|
121 | - * Return the $query_args |
|
122 | - */ |
|
123 | - return $query_args; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
129 | - * friendly keys. |
|
130 | - * |
|
131 | - * @param array $where_args |
|
132 | - * @return array |
|
133 | - */ |
|
134 | - public function sanitizeInputFields(array $where_args) |
|
135 | - { |
|
136 | - $arg_mapping = [ |
|
137 | - 'datetime' => 'Datetime.DTT_ID', |
|
138 | - 'datetimeIn' => 'Datetime.DTT_ID', |
|
139 | - 'datetimeIdIn' => 'Datetime.DTT_ID', |
|
140 | - 'datetimeId' => 'Datetime.DTT_ID', // priority. |
|
141 | - ]; |
|
142 | - return $this->sanitizeWhereArgsForInputFields( |
|
143 | - $where_args, |
|
144 | - $arg_mapping, |
|
145 | - ['datetime', 'datetimeIn'] |
|
146 | - ); |
|
147 | - } |
|
19 | + /** |
|
20 | + * @return EEM_Ticket |
|
21 | + * @throws EE_Error |
|
22 | + * @throws InvalidArgumentException |
|
23 | + * @throws InvalidDataTypeException |
|
24 | + * @throws InvalidInterfaceException |
|
25 | + */ |
|
26 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
27 | + public function get_query() |
|
28 | + { |
|
29 | + return EEM_Ticket::instance(); |
|
30 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * Return an array of items from the query |
|
35 | + * |
|
36 | + * @return array |
|
37 | + */ |
|
38 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
39 | + public function get_items() |
|
40 | + { |
|
41 | + $results = $this->query->get_col($this->query_args); |
|
42 | + |
|
43 | + return ! empty($results) ? $results : []; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * Determine whether the Query should execute. If it's determined that the query should |
|
49 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
50 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
51 | + * Return false to prevent the query from executing. |
|
52 | + * |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
56 | + public function should_execute() |
|
57 | + { |
|
58 | + if (false === $this->should_execute) { |
|
59 | + return false; |
|
60 | + } |
|
61 | + |
|
62 | + return $this->should_execute; |
|
63 | + } |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
68 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
69 | + * handle batch resolution of the posts. |
|
70 | + * |
|
71 | + * @return array |
|
72 | + * @throws EE_Error |
|
73 | + * @throws InvalidArgumentException |
|
74 | + * @throws ReflectionException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + */ |
|
78 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
79 | + public function get_query_args() |
|
80 | + { |
|
81 | + $where_params = ['TKT_deleted' => ['IN', [true, false]]]; |
|
82 | + $query_args = []; |
|
83 | + |
|
84 | + $query_args['limit'] = $this->getLimit(); |
|
85 | + |
|
86 | + // Avoid multiple entries by join. |
|
87 | + $query_args['group_by'] = 'TKT_ID'; |
|
88 | + |
|
89 | + /** |
|
90 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
91 | + */ |
|
92 | + $input_fields = []; |
|
93 | + if (! empty($this->args['where'])) { |
|
94 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
95 | + |
|
96 | + // Use the proper operator. |
|
97 | + if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
98 | + $input_fields['Datetime.DTT_ID'] = ['in', $input_fields['Datetime.DTT_ID']]; |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
104 | + */ |
|
105 | + if ($this->source instanceof EE_Datetime) { |
|
106 | + $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
107 | + } |
|
108 | + |
|
109 | + /** |
|
110 | + * Merge the input_fields with the default query_args |
|
111 | + */ |
|
112 | + if (! empty($input_fields)) { |
|
113 | + $where_params = array_merge($where_params, $input_fields); |
|
114 | + } |
|
115 | + |
|
116 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); |
|
117 | + |
|
118 | + $query_args[] = $where_params; |
|
119 | + |
|
120 | + /** |
|
121 | + * Return the $query_args |
|
122 | + */ |
|
123 | + return $query_args; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
129 | + * friendly keys. |
|
130 | + * |
|
131 | + * @param array $where_args |
|
132 | + * @return array |
|
133 | + */ |
|
134 | + public function sanitizeInputFields(array $where_args) |
|
135 | + { |
|
136 | + $arg_mapping = [ |
|
137 | + 'datetime' => 'Datetime.DTT_ID', |
|
138 | + 'datetimeIn' => 'Datetime.DTT_ID', |
|
139 | + 'datetimeIdIn' => 'Datetime.DTT_ID', |
|
140 | + 'datetimeId' => 'Datetime.DTT_ID', // priority. |
|
141 | + ]; |
|
142 | + return $this->sanitizeWhereArgsForInputFields( |
|
143 | + $where_args, |
|
144 | + $arg_mapping, |
|
145 | + ['datetime', 'datetimeIn'] |
|
146 | + ); |
|
147 | + } |
|
148 | 148 | } |
@@ -21,196 +21,196 @@ |
||
21 | 21 | class Event extends TypeBase |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Event constructor. |
|
26 | - * |
|
27 | - * @param EEM_Event $event_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Event $event_model) |
|
30 | - { |
|
31 | - $this->model = $event_model; |
|
32 | - $this->setName($this->namespace . 'Event'); |
|
33 | - $this->setIsCustomPostType(true); |
|
34 | - parent::__construct(); |
|
35 | - } |
|
24 | + /** |
|
25 | + * Event constructor. |
|
26 | + * |
|
27 | + * @param EEM_Event $event_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Event $event_model) |
|
30 | + { |
|
31 | + $this->model = $event_model; |
|
32 | + $this->setName($this->namespace . 'Event'); |
|
33 | + $this->setIsCustomPostType(true); |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function getFields() |
|
43 | - { |
|
44 | - return [ |
|
45 | - new GraphQLOutputField( |
|
46 | - 'dbId', |
|
47 | - ['non_null' => 'Int'], |
|
48 | - 'ID', |
|
49 | - esc_html__('The event ID.', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLField( |
|
52 | - 'name', |
|
53 | - 'String', |
|
54 | - 'name', |
|
55 | - esc_html__('Event Name', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLField( |
|
58 | - 'desc', |
|
59 | - 'String', |
|
60 | - 'description', |
|
61 | - esc_html__('Event Description', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'shortDesc', |
|
65 | - 'String', |
|
66 | - 'short_description', |
|
67 | - esc_html__('Event Short Description', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLField( |
|
70 | - 'created', |
|
71 | - 'String', |
|
72 | - 'created', |
|
73 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLOutputField( |
|
76 | - 'wpUser', |
|
77 | - 'User', |
|
78 | - null, |
|
79 | - esc_html__('Event Creator', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLInputField( |
|
82 | - 'wpUser', |
|
83 | - 'Int', |
|
84 | - null, |
|
85 | - esc_html__('Event Creator ID', 'event_espresso') |
|
86 | - ), |
|
87 | - new GraphQLField( |
|
88 | - 'order', |
|
89 | - 'Int', |
|
90 | - 'order', |
|
91 | - esc_html__('Event Menu Order', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLField( |
|
94 | - 'displayDesc', |
|
95 | - 'Boolean', |
|
96 | - 'display_description', |
|
97 | - esc_html__('Display Description Flag', 'event_espresso') |
|
98 | - ), |
|
99 | - new GraphQLField( |
|
100 | - 'displayTicketSelector', |
|
101 | - 'Boolean', |
|
102 | - 'display_ticket_selector', |
|
103 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'visibleOn', |
|
107 | - 'String', |
|
108 | - 'visible_on', |
|
109 | - esc_html__('Event Visible Date', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'additionalLimit', |
|
113 | - 'Int', |
|
114 | - 'additional_limit', |
|
115 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'phone', |
|
119 | - 'String', |
|
120 | - 'phone', |
|
121 | - esc_html__('Event Phone Number', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'memberOnly', |
|
125 | - 'Boolean', |
|
126 | - 'member_only', |
|
127 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'allowOverflow', |
|
131 | - 'Boolean', |
|
132 | - 'allow_overflow', |
|
133 | - esc_html__('Allow Overflow on Event', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLField( |
|
136 | - 'timezoneString', |
|
137 | - 'String', |
|
138 | - 'timezone_string', |
|
139 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLField( |
|
142 | - 'externalUrl', |
|
143 | - 'String', |
|
144 | - 'external_url', |
|
145 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'donations', |
|
149 | - 'Boolean', |
|
150 | - 'donations', |
|
151 | - esc_html__('Accept Donations?', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'isSoldOut', |
|
155 | - 'Boolean', |
|
156 | - 'is_sold_out', |
|
157 | - esc_html__( |
|
158 | - 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
159 | - 'event_espresso' |
|
160 | - ) |
|
161 | - ), |
|
162 | - new GraphQLField( |
|
163 | - 'isPostponed', |
|
164 | - 'Boolean', |
|
165 | - 'is_postponed', |
|
166 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'isCancelled', |
|
170 | - 'Boolean', |
|
171 | - 'is_cancelled', |
|
172 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLOutputField( |
|
175 | - 'isUpcoming', |
|
176 | - 'Boolean', |
|
177 | - 'is_upcoming', |
|
178 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLOutputField( |
|
181 | - 'isActive', |
|
182 | - 'Boolean', |
|
183 | - 'is_active', |
|
184 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLOutputField( |
|
187 | - 'isInactive', |
|
188 | - 'Boolean', |
|
189 | - 'is_inactive', |
|
190 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
191 | - ), |
|
192 | - new GraphQLOutputField( |
|
193 | - 'isExpired', |
|
194 | - 'Boolean', |
|
195 | - 'is_expired', |
|
196 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
197 | - ), |
|
198 | - ]; |
|
199 | - } |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function getFields() |
|
43 | + { |
|
44 | + return [ |
|
45 | + new GraphQLOutputField( |
|
46 | + 'dbId', |
|
47 | + ['non_null' => 'Int'], |
|
48 | + 'ID', |
|
49 | + esc_html__('The event ID.', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLField( |
|
52 | + 'name', |
|
53 | + 'String', |
|
54 | + 'name', |
|
55 | + esc_html__('Event Name', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLField( |
|
58 | + 'desc', |
|
59 | + 'String', |
|
60 | + 'description', |
|
61 | + esc_html__('Event Description', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'shortDesc', |
|
65 | + 'String', |
|
66 | + 'short_description', |
|
67 | + esc_html__('Event Short Description', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLField( |
|
70 | + 'created', |
|
71 | + 'String', |
|
72 | + 'created', |
|
73 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLOutputField( |
|
76 | + 'wpUser', |
|
77 | + 'User', |
|
78 | + null, |
|
79 | + esc_html__('Event Creator', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLInputField( |
|
82 | + 'wpUser', |
|
83 | + 'Int', |
|
84 | + null, |
|
85 | + esc_html__('Event Creator ID', 'event_espresso') |
|
86 | + ), |
|
87 | + new GraphQLField( |
|
88 | + 'order', |
|
89 | + 'Int', |
|
90 | + 'order', |
|
91 | + esc_html__('Event Menu Order', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLField( |
|
94 | + 'displayDesc', |
|
95 | + 'Boolean', |
|
96 | + 'display_description', |
|
97 | + esc_html__('Display Description Flag', 'event_espresso') |
|
98 | + ), |
|
99 | + new GraphQLField( |
|
100 | + 'displayTicketSelector', |
|
101 | + 'Boolean', |
|
102 | + 'display_ticket_selector', |
|
103 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'visibleOn', |
|
107 | + 'String', |
|
108 | + 'visible_on', |
|
109 | + esc_html__('Event Visible Date', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'additionalLimit', |
|
113 | + 'Int', |
|
114 | + 'additional_limit', |
|
115 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'phone', |
|
119 | + 'String', |
|
120 | + 'phone', |
|
121 | + esc_html__('Event Phone Number', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'memberOnly', |
|
125 | + 'Boolean', |
|
126 | + 'member_only', |
|
127 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'allowOverflow', |
|
131 | + 'Boolean', |
|
132 | + 'allow_overflow', |
|
133 | + esc_html__('Allow Overflow on Event', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLField( |
|
136 | + 'timezoneString', |
|
137 | + 'String', |
|
138 | + 'timezone_string', |
|
139 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLField( |
|
142 | + 'externalUrl', |
|
143 | + 'String', |
|
144 | + 'external_url', |
|
145 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'donations', |
|
149 | + 'Boolean', |
|
150 | + 'donations', |
|
151 | + esc_html__('Accept Donations?', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'isSoldOut', |
|
155 | + 'Boolean', |
|
156 | + 'is_sold_out', |
|
157 | + esc_html__( |
|
158 | + 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
159 | + 'event_espresso' |
|
160 | + ) |
|
161 | + ), |
|
162 | + new GraphQLField( |
|
163 | + 'isPostponed', |
|
164 | + 'Boolean', |
|
165 | + 'is_postponed', |
|
166 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'isCancelled', |
|
170 | + 'Boolean', |
|
171 | + 'is_cancelled', |
|
172 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLOutputField( |
|
175 | + 'isUpcoming', |
|
176 | + 'Boolean', |
|
177 | + 'is_upcoming', |
|
178 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLOutputField( |
|
181 | + 'isActive', |
|
182 | + 'Boolean', |
|
183 | + 'is_active', |
|
184 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLOutputField( |
|
187 | + 'isInactive', |
|
188 | + 'Boolean', |
|
189 | + 'is_inactive', |
|
190 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
191 | + ), |
|
192 | + new GraphQLOutputField( |
|
193 | + 'isExpired', |
|
194 | + 'Boolean', |
|
195 | + 'is_expired', |
|
196 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
197 | + ), |
|
198 | + ]; |
|
199 | + } |
|
200 | 200 | |
201 | 201 | |
202 | - /** |
|
203 | - * Extends the existing WP GraphQL mutations. |
|
204 | - * |
|
205 | - * @since $VID:$ |
|
206 | - */ |
|
207 | - public function extendMutations() |
|
208 | - { |
|
209 | - add_action( |
|
210 | - 'graphql_post_object_mutation_update_additional_data', |
|
211 | - EventUpdate::mutateFields($this->model, $this), |
|
212 | - 10, |
|
213 | - 6 |
|
214 | - ); |
|
215 | - } |
|
202 | + /** |
|
203 | + * Extends the existing WP GraphQL mutations. |
|
204 | + * |
|
205 | + * @since $VID:$ |
|
206 | + */ |
|
207 | + public function extendMutations() |
|
208 | + { |
|
209 | + add_action( |
|
210 | + 'graphql_post_object_mutation_update_additional_data', |
|
211 | + EventUpdate::mutateFields($this->model, $this), |
|
212 | + 10, |
|
213 | + 6 |
|
214 | + ); |
|
215 | + } |
|
216 | 216 | } |
@@ -16,39 +16,39 @@ |
||
16 | 16 | class TicketStatusEnum extends EnumBase |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * TicketStatusEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'TicketStatusEnum'); |
|
25 | - $this->setDescription(esc_html__('Whether the ticket is On Sale, Pending, or Expired', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * TicketStatusEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'TicketStatusEnum'); |
|
25 | + $this->setDescription(esc_html__('Whether the ticket is On Sale, Pending, or Expired', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - protected function getValues() |
|
35 | - { |
|
36 | - return [ |
|
37 | - 'SOLD_OUT' => [ |
|
38 | - 'value' => EE_Ticket::sold_out, |
|
39 | - ], |
|
40 | - 'EXPIRED' => [ |
|
41 | - 'value' => EE_Ticket::expired, |
|
42 | - ], |
|
43 | - 'ARCHIVED' => [ |
|
44 | - 'value' => EE_Ticket::archived, |
|
45 | - ], |
|
46 | - 'PENDING' => [ |
|
47 | - 'value' => EE_Ticket::pending, |
|
48 | - ], |
|
49 | - 'ONSALE' => [ |
|
50 | - 'value' => EE_Ticket::onsale, |
|
51 | - ], |
|
52 | - ]; |
|
53 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + protected function getValues() |
|
35 | + { |
|
36 | + return [ |
|
37 | + 'SOLD_OUT' => [ |
|
38 | + 'value' => EE_Ticket::sold_out, |
|
39 | + ], |
|
40 | + 'EXPIRED' => [ |
|
41 | + 'value' => EE_Ticket::expired, |
|
42 | + ], |
|
43 | + 'ARCHIVED' => [ |
|
44 | + 'value' => EE_Ticket::archived, |
|
45 | + ], |
|
46 | + 'PENDING' => [ |
|
47 | + 'value' => EE_Ticket::pending, |
|
48 | + ], |
|
49 | + 'ONSALE' => [ |
|
50 | + 'value' => EE_Ticket::onsale, |
|
51 | + ], |
|
52 | + ]; |
|
53 | + } |
|
54 | 54 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->setName($this->namespace . 'TicketStatusEnum'); |
|
24 | + $this->setName($this->namespace.'TicketStatusEnum'); |
|
25 | 25 | $this->setDescription(esc_html__('Whether the ticket is On Sale, Pending, or Expired', 'event_espresso')); |
26 | 26 | parent::__construct(); |
27 | 27 | } |
@@ -16,45 +16,45 @@ |
||
16 | 16 | class DatetimeStatusEnum extends EnumBase |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * DatetimeStatusEnum constructor. |
|
21 | - */ |
|
22 | - public function __construct() |
|
23 | - { |
|
24 | - $this->setName($this->namespace . 'DatetimeStatusEnum'); |
|
25 | - $this->setDescription(esc_html__('Datetime status', 'event_espresso')); |
|
26 | - parent::__construct(); |
|
27 | - } |
|
19 | + /** |
|
20 | + * DatetimeStatusEnum constructor. |
|
21 | + */ |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + $this->setName($this->namespace . 'DatetimeStatusEnum'); |
|
25 | + $this->setDescription(esc_html__('Datetime status', 'event_espresso')); |
|
26 | + parent::__construct(); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | - /** |
|
31 | - * @return array |
|
32 | - * @since $VID:$ |
|
33 | - */ |
|
34 | - protected function getValues() |
|
35 | - { |
|
36 | - return [ |
|
37 | - 'SOLD_OUT' => [ |
|
38 | - 'value' => EE_Datetime::sold_out, |
|
39 | - ], |
|
40 | - 'ACTIVE' => [ |
|
41 | - 'value' => EE_Datetime::active, |
|
42 | - ], |
|
43 | - 'UPCOMING' => [ |
|
44 | - 'value' => EE_Datetime::upcoming, |
|
45 | - ], |
|
46 | - 'POSTPONED' => [ |
|
47 | - 'value' => EE_Datetime::postponed, |
|
48 | - ], |
|
49 | - 'CANCELLED' => [ |
|
50 | - 'value' => EE_Datetime::cancelled, |
|
51 | - ], |
|
52 | - 'EXPIRED' => [ |
|
53 | - 'value' => EE_Datetime::expired, |
|
54 | - ], |
|
55 | - 'INACTIVE' => [ |
|
56 | - 'value' => EE_Datetime::inactive, |
|
57 | - ], |
|
58 | - ]; |
|
59 | - } |
|
30 | + /** |
|
31 | + * @return array |
|
32 | + * @since $VID:$ |
|
33 | + */ |
|
34 | + protected function getValues() |
|
35 | + { |
|
36 | + return [ |
|
37 | + 'SOLD_OUT' => [ |
|
38 | + 'value' => EE_Datetime::sold_out, |
|
39 | + ], |
|
40 | + 'ACTIVE' => [ |
|
41 | + 'value' => EE_Datetime::active, |
|
42 | + ], |
|
43 | + 'UPCOMING' => [ |
|
44 | + 'value' => EE_Datetime::upcoming, |
|
45 | + ], |
|
46 | + 'POSTPONED' => [ |
|
47 | + 'value' => EE_Datetime::postponed, |
|
48 | + ], |
|
49 | + 'CANCELLED' => [ |
|
50 | + 'value' => EE_Datetime::cancelled, |
|
51 | + ], |
|
52 | + 'EXPIRED' => [ |
|
53 | + 'value' => EE_Datetime::expired, |
|
54 | + ], |
|
55 | + 'INACTIVE' => [ |
|
56 | + 'value' => EE_Datetime::inactive, |
|
57 | + ], |
|
58 | + ]; |
|
59 | + } |
|
60 | 60 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | */ |
22 | 22 | public function __construct() |
23 | 23 | { |
24 | - $this->setName($this->namespace . 'DatetimeStatusEnum'); |
|
24 | + $this->setName($this->namespace.'DatetimeStatusEnum'); |
|
25 | 25 | $this->setDescription(esc_html__('Datetime status', 'event_espresso')); |
26 | 26 | parent::__construct(); |
27 | 27 | } |
@@ -13,78 +13,78 @@ |
||
13 | 13 | class EventMutation |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Maps the GraphQL input to a format that the model functions can use |
|
18 | - * |
|
19 | - * @param array $input Data coming from the GraphQL mutation query input |
|
20 | - * @param string $mutation_name Name of the mutation being performed |
|
21 | - * @return array |
|
22 | - */ |
|
23 | - public static function prepareFields(array $input, $mutation_name) |
|
24 | - { |
|
25 | - |
|
26 | - $args = []; |
|
27 | - |
|
28 | - if (! empty($input['additionalLimit'])) { |
|
29 | - $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
30 | - } |
|
31 | - |
|
32 | - if (array_key_exists('allowOverflow', $input)) { |
|
33 | - $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
34 | - } |
|
35 | - |
|
36 | - if (! empty($input['desc'])) { |
|
37 | - $args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
|
38 | - } |
|
39 | - |
|
40 | - if (array_key_exists('displayDesc', $input)) { |
|
41 | - $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
42 | - } |
|
43 | - |
|
44 | - if (array_key_exists('displayTicketSelector', $input)) { |
|
45 | - $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
46 | - } |
|
47 | - |
|
48 | - if (array_key_exists('donations', $input)) { |
|
49 | - $args['EVT_donations'] = (bool) ($input['donations']); |
|
50 | - } |
|
51 | - |
|
52 | - if (! empty($input['externalUrl'])) { |
|
53 | - $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
54 | - } |
|
55 | - |
|
56 | - if (array_key_exists('memberOnly', $input)) { |
|
57 | - $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
58 | - } |
|
59 | - |
|
60 | - if (! empty($input['name'])) { |
|
61 | - $args['EVT_name'] = sanitize_text_field($input['name']); |
|
62 | - } |
|
63 | - |
|
64 | - if (! empty($input['order'])) { |
|
65 | - $args['EVT_order'] = absint($input['order']); |
|
66 | - } |
|
67 | - |
|
68 | - if (! empty($input['phone'])) { |
|
69 | - $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
70 | - } |
|
71 | - |
|
72 | - if (! empty($input['shortDesc'])) { |
|
73 | - $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
|
74 | - } |
|
75 | - |
|
76 | - if (! empty($input['timezoneString'])) { |
|
77 | - $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
78 | - } |
|
79 | - |
|
80 | - if (! empty($input['visibleOn'])) { |
|
81 | - $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
82 | - } |
|
83 | - |
|
84 | - if (! empty($input['wpUser'])) { |
|
85 | - $args['EVT_wp_user'] = absint($input['wpUser']); |
|
86 | - } |
|
87 | - |
|
88 | - return $args; |
|
89 | - } |
|
16 | + /** |
|
17 | + * Maps the GraphQL input to a format that the model functions can use |
|
18 | + * |
|
19 | + * @param array $input Data coming from the GraphQL mutation query input |
|
20 | + * @param string $mutation_name Name of the mutation being performed |
|
21 | + * @return array |
|
22 | + */ |
|
23 | + public static function prepareFields(array $input, $mutation_name) |
|
24 | + { |
|
25 | + |
|
26 | + $args = []; |
|
27 | + |
|
28 | + if (! empty($input['additionalLimit'])) { |
|
29 | + $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
|
30 | + } |
|
31 | + |
|
32 | + if (array_key_exists('allowOverflow', $input)) { |
|
33 | + $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
|
34 | + } |
|
35 | + |
|
36 | + if (! empty($input['desc'])) { |
|
37 | + $args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
|
38 | + } |
|
39 | + |
|
40 | + if (array_key_exists('displayDesc', $input)) { |
|
41 | + $args['EVT_display_desc'] = (bool) ($input['displayDesc']); |
|
42 | + } |
|
43 | + |
|
44 | + if (array_key_exists('displayTicketSelector', $input)) { |
|
45 | + $args['EVT_display_ticket_selector'] = (bool) ($input['displayTicketSelector']); |
|
46 | + } |
|
47 | + |
|
48 | + if (array_key_exists('donations', $input)) { |
|
49 | + $args['EVT_donations'] = (bool) ($input['donations']); |
|
50 | + } |
|
51 | + |
|
52 | + if (! empty($input['externalUrl'])) { |
|
53 | + $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
|
54 | + } |
|
55 | + |
|
56 | + if (array_key_exists('memberOnly', $input)) { |
|
57 | + $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
|
58 | + } |
|
59 | + |
|
60 | + if (! empty($input['name'])) { |
|
61 | + $args['EVT_name'] = sanitize_text_field($input['name']); |
|
62 | + } |
|
63 | + |
|
64 | + if (! empty($input['order'])) { |
|
65 | + $args['EVT_order'] = absint($input['order']); |
|
66 | + } |
|
67 | + |
|
68 | + if (! empty($input['phone'])) { |
|
69 | + $args['EVT_phone'] = sanitize_text_field($input['phone']); |
|
70 | + } |
|
71 | + |
|
72 | + if (! empty($input['shortDesc'])) { |
|
73 | + $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
|
74 | + } |
|
75 | + |
|
76 | + if (! empty($input['timezoneString'])) { |
|
77 | + $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
|
78 | + } |
|
79 | + |
|
80 | + if (! empty($input['visibleOn'])) { |
|
81 | + $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
|
82 | + } |
|
83 | + |
|
84 | + if (! empty($input['wpUser'])) { |
|
85 | + $args['EVT_wp_user'] = absint($input['wpUser']); |
|
86 | + } |
|
87 | + |
|
88 | + return $args; |
|
89 | + } |
|
90 | 90 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | $args = []; |
27 | 27 | |
28 | - if (! empty($input['additionalLimit'])) { |
|
28 | + if ( ! empty($input['additionalLimit'])) { |
|
29 | 29 | $args['EVT_additional_limit'] = absint($input['additionalLimit']); |
30 | 30 | } |
31 | 31 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $args['EVT_allow_overflow'] = (bool) ($input['allowOverflow']); |
34 | 34 | } |
35 | 35 | |
36 | - if (! empty($input['desc'])) { |
|
36 | + if ( ! empty($input['desc'])) { |
|
37 | 37 | $args['EVT_desc'] = sanitize_post_field('post_content', $input['desc'], null, $context = 'db'); |
38 | 38 | } |
39 | 39 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $args['EVT_donations'] = (bool) ($input['donations']); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($input['externalUrl'])) { |
|
52 | + if ( ! empty($input['externalUrl'])) { |
|
53 | 53 | $args['EVT_external_URL'] = sanitize_text_field($input['externalUrl']); |
54 | 54 | } |
55 | 55 | |
@@ -57,31 +57,31 @@ discard block |
||
57 | 57 | $args['EVT_member_only'] = (bool) ($input['memberOnly']); |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['name'])) { |
|
60 | + if ( ! empty($input['name'])) { |
|
61 | 61 | $args['EVT_name'] = sanitize_text_field($input['name']); |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($input['order'])) { |
|
64 | + if ( ! empty($input['order'])) { |
|
65 | 65 | $args['EVT_order'] = absint($input['order']); |
66 | 66 | } |
67 | 67 | |
68 | - if (! empty($input['phone'])) { |
|
68 | + if ( ! empty($input['phone'])) { |
|
69 | 69 | $args['EVT_phone'] = sanitize_text_field($input['phone']); |
70 | 70 | } |
71 | 71 | |
72 | - if (! empty($input['shortDesc'])) { |
|
72 | + if ( ! empty($input['shortDesc'])) { |
|
73 | 73 | $args['EVT_short_desc'] = sanitize_post_field('post_excerpt', $input['shortDesc'], null, $context = 'db'); |
74 | 74 | } |
75 | 75 | |
76 | - if (! empty($input['timezoneString'])) { |
|
76 | + if ( ! empty($input['timezoneString'])) { |
|
77 | 77 | $args['EVT_timezone_string'] = sanitize_text_field($input['timezoneString']); |
78 | 78 | } |
79 | 79 | |
80 | - if (! empty($input['visibleOn'])) { |
|
80 | + if ( ! empty($input['visibleOn'])) { |
|
81 | 81 | $args['EVT_visible_on'] = new DateTime(sanitize_text_field($input['visibleOn'])); |
82 | 82 | } |
83 | 83 | |
84 | - if (! empty($input['wpUser'])) { |
|
84 | + if ( ! empty($input['wpUser'])) { |
|
85 | 85 | $args['EVT_wp_user'] = absint($input['wpUser']); |
86 | 86 | } |
87 | 87 |