@@ -34,221 +34,221 @@ discard block |
||
34 | 34 | class AdvancedEditorData |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * @var string $namespace The graphql namespace/prefix. |
|
39 | - */ |
|
40 | - protected $namespace = 'Espresso'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Event |
|
44 | - */ |
|
45 | - protected $event; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Admin_Config |
|
49 | - */ |
|
50 | - protected $admin_config; |
|
51 | - /** |
|
52 | - * @var EEM_Datetime $datetime_model |
|
53 | - */ |
|
54 | - protected $datetime_model; |
|
55 | - /** |
|
56 | - * @var EEM_Price $price_model |
|
57 | - */ |
|
58 | - protected $price_model; |
|
59 | - /** |
|
60 | - * @var EEM_Ticket $ticket_model |
|
61 | - */ |
|
62 | - protected $ticket_model; |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * AdvancedEditorAdminForm constructor. |
|
67 | - * |
|
68 | - * @param EE_Event $event |
|
69 | - * @param EE_Admin_Config $admin_config |
|
70 | - * @param EEM_Datetime $datetime_model |
|
71 | - * @param EEM_Price $price_model |
|
72 | - * @param EEM_Ticket $ticket_model |
|
73 | - */ |
|
74 | - public function __construct( |
|
75 | - EE_Event $event, |
|
76 | - EE_Admin_Config $admin_config, |
|
77 | - EEM_Datetime $datetime_model, |
|
78 | - EEM_Price $price_model, |
|
79 | - EEM_Ticket $ticket_model |
|
80 | - ) { |
|
81 | - $this->event = $event; |
|
82 | - $this->admin_config = $admin_config; |
|
83 | - $this->datetime_model = $datetime_model; |
|
84 | - $this->price_model = $price_model; |
|
85 | - $this->ticket_model = $ticket_model; |
|
86 | - add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - /** |
|
91 | - * @throws EE_Error |
|
92 | - * @throws InvalidArgumentException |
|
93 | - * @throws InvalidDataTypeException |
|
94 | - * @throws InvalidInterfaceException |
|
95 | - * @throws ModelConfigurationException |
|
96 | - * @throws ReflectionException |
|
97 | - * @throws UnexpectedEntityException |
|
98 | - * @throws DomainException |
|
99 | - * @since $VID:$ |
|
100 | - */ |
|
101 | - public function loadScriptsStyles() |
|
102 | - { |
|
103 | - if ($this->admin_config->useAdvancedEditor()) { |
|
104 | - $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
105 | - if (! $eventId) { |
|
106 | - global $post; |
|
107 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
108 | - $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
109 | - ? $post->ID |
|
110 | - : $eventId; |
|
111 | - } |
|
112 | - if ($eventId) { |
|
113 | - $data = $this->getEditorData($eventId); |
|
114 | - $data = wp_json_encode($data); |
|
115 | - add_action( |
|
116 | - 'admin_footer', |
|
117 | - static function () use ($data) { |
|
118 | - wp_add_inline_script( |
|
119 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
120 | - " |
|
37 | + /** |
|
38 | + * @var string $namespace The graphql namespace/prefix. |
|
39 | + */ |
|
40 | + protected $namespace = 'Espresso'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Event |
|
44 | + */ |
|
45 | + protected $event; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Admin_Config |
|
49 | + */ |
|
50 | + protected $admin_config; |
|
51 | + /** |
|
52 | + * @var EEM_Datetime $datetime_model |
|
53 | + */ |
|
54 | + protected $datetime_model; |
|
55 | + /** |
|
56 | + * @var EEM_Price $price_model |
|
57 | + */ |
|
58 | + protected $price_model; |
|
59 | + /** |
|
60 | + * @var EEM_Ticket $ticket_model |
|
61 | + */ |
|
62 | + protected $ticket_model; |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * AdvancedEditorAdminForm constructor. |
|
67 | + * |
|
68 | + * @param EE_Event $event |
|
69 | + * @param EE_Admin_Config $admin_config |
|
70 | + * @param EEM_Datetime $datetime_model |
|
71 | + * @param EEM_Price $price_model |
|
72 | + * @param EEM_Ticket $ticket_model |
|
73 | + */ |
|
74 | + public function __construct( |
|
75 | + EE_Event $event, |
|
76 | + EE_Admin_Config $admin_config, |
|
77 | + EEM_Datetime $datetime_model, |
|
78 | + EEM_Price $price_model, |
|
79 | + EEM_Ticket $ticket_model |
|
80 | + ) { |
|
81 | + $this->event = $event; |
|
82 | + $this->admin_config = $admin_config; |
|
83 | + $this->datetime_model = $datetime_model; |
|
84 | + $this->price_model = $price_model; |
|
85 | + $this->ticket_model = $ticket_model; |
|
86 | + add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + /** |
|
91 | + * @throws EE_Error |
|
92 | + * @throws InvalidArgumentException |
|
93 | + * @throws InvalidDataTypeException |
|
94 | + * @throws InvalidInterfaceException |
|
95 | + * @throws ModelConfigurationException |
|
96 | + * @throws ReflectionException |
|
97 | + * @throws UnexpectedEntityException |
|
98 | + * @throws DomainException |
|
99 | + * @since $VID:$ |
|
100 | + */ |
|
101 | + public function loadScriptsStyles() |
|
102 | + { |
|
103 | + if ($this->admin_config->useAdvancedEditor()) { |
|
104 | + $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
105 | + if (! $eventId) { |
|
106 | + global $post; |
|
107 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
108 | + $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
109 | + ? $post->ID |
|
110 | + : $eventId; |
|
111 | + } |
|
112 | + if ($eventId) { |
|
113 | + $data = $this->getEditorData($eventId); |
|
114 | + $data = wp_json_encode($data); |
|
115 | + add_action( |
|
116 | + 'admin_footer', |
|
117 | + static function () use ($data) { |
|
118 | + wp_add_inline_script( |
|
119 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
120 | + " |
|
121 | 121 | var eeEditorData={$data}; |
122 | 122 | ", |
123 | - 'before' |
|
124 | - ); |
|
125 | - } |
|
126 | - ); |
|
127 | - add_action( |
|
128 | - 'admin_footer', |
|
129 | - static function () use ($data) { |
|
130 | - wp_add_inline_script( |
|
131 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
132 | - " |
|
123 | + 'before' |
|
124 | + ); |
|
125 | + } |
|
126 | + ); |
|
127 | + add_action( |
|
128 | + 'admin_footer', |
|
129 | + static function () use ($data) { |
|
130 | + wp_add_inline_script( |
|
131 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
132 | + " |
|
133 | 133 | var eeEditorData={$data}; |
134 | 134 | ", |
135 | - 'before' |
|
136 | - ); |
|
137 | - } |
|
138 | - ); |
|
139 | - } |
|
140 | - } |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param int $eventId |
|
146 | - * @return array |
|
147 | - * @throws EE_Error |
|
148 | - * @throws InvalidDataTypeException |
|
149 | - * @throws InvalidInterfaceException |
|
150 | - * @throws ModelConfigurationException |
|
151 | - * @throws UnexpectedEntityException |
|
152 | - * @throws InvalidArgumentException |
|
153 | - * @throws ReflectionException |
|
154 | - * @throws DomainException |
|
155 | - * @since $VID:$ |
|
156 | - */ |
|
157 | - protected function getEditorData($eventId) |
|
158 | - { |
|
159 | - $event = $this->getEventGraphQLData($eventId); |
|
160 | - $event['dbId'] = $eventId; |
|
161 | - |
|
162 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
163 | - $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
164 | - |
|
165 | - $currentUser = $this->getGraphQLCurrentUser(); |
|
166 | - |
|
167 | - $generalSettings = $this->getGraphQLGeneralSettings(); |
|
168 | - |
|
169 | - return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings'); |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @param int $eventId |
|
175 | - * @return array |
|
176 | - * @since $VID:$ |
|
177 | - */ |
|
178 | - protected function getEventGraphQLData($eventId) |
|
179 | - { |
|
180 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
181 | - |
|
182 | - if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
183 | - $this->addDefaultEntities($eventId); |
|
184 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
185 | - } |
|
186 | - |
|
187 | - if (! empty($datetimes['nodes'])) { |
|
188 | - $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
189 | - |
|
190 | - if (! empty($datetimeIn)) { |
|
191 | - $tickets = $this->getGraphQLTickets($datetimeIn); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - if (! empty($tickets['nodes'])) { |
|
196 | - $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
197 | - |
|
198 | - if (! empty($ticketIn)) { |
|
199 | - $prices = $this->getGraphQLPrices($ticketIn); |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - $priceTypes = $this->getGraphQLPriceTypes(); |
|
204 | - |
|
205 | - $relations = $this->getRelationalData($eventId); |
|
206 | - |
|
207 | - return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * @param int $eventId |
|
212 | - * @throws DomainException |
|
213 | - * @throws EE_Error |
|
214 | - * @throws InvalidArgumentException |
|
215 | - * @throws InvalidDataTypeException |
|
216 | - * @throws InvalidInterfaceException |
|
217 | - * @throws ModelConfigurationException |
|
218 | - * @throws ReflectionException |
|
219 | - * @throws UnexpectedEntityException |
|
220 | - * @since $VID:$ |
|
221 | - */ |
|
222 | - protected function addDefaultEntities($eventId) |
|
223 | - { |
|
224 | - $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
225 | - if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
226 | - $default_date = $default_dates[0]; |
|
227 | - $default_date->save(); |
|
228 | - $default_date->_add_relation_to($eventId, 'Event'); |
|
229 | - $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
230 | - $default_prices = $this->price_model->get_all_default_prices(); |
|
231 | - foreach ($default_tickets as $default_ticket) { |
|
232 | - $default_ticket->save(); |
|
233 | - $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
234 | - foreach ($default_prices as $default_price) { |
|
235 | - $default_price->save(); |
|
236 | - $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
237 | - } |
|
238 | - } |
|
239 | - } |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * @param int $eventId |
|
245 | - * @return array|null |
|
246 | - * @since $VID:$ |
|
247 | - */ |
|
248 | - protected function getGraphQLDatetimes($eventId) |
|
249 | - { |
|
250 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
251 | - $query = <<<QUERY |
|
135 | + 'before' |
|
136 | + ); |
|
137 | + } |
|
138 | + ); |
|
139 | + } |
|
140 | + } |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param int $eventId |
|
146 | + * @return array |
|
147 | + * @throws EE_Error |
|
148 | + * @throws InvalidDataTypeException |
|
149 | + * @throws InvalidInterfaceException |
|
150 | + * @throws ModelConfigurationException |
|
151 | + * @throws UnexpectedEntityException |
|
152 | + * @throws InvalidArgumentException |
|
153 | + * @throws ReflectionException |
|
154 | + * @throws DomainException |
|
155 | + * @since $VID:$ |
|
156 | + */ |
|
157 | + protected function getEditorData($eventId) |
|
158 | + { |
|
159 | + $event = $this->getEventGraphQLData($eventId); |
|
160 | + $event['dbId'] = $eventId; |
|
161 | + |
|
162 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
163 | + $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
164 | + |
|
165 | + $currentUser = $this->getGraphQLCurrentUser(); |
|
166 | + |
|
167 | + $generalSettings = $this->getGraphQLGeneralSettings(); |
|
168 | + |
|
169 | + return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings'); |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @param int $eventId |
|
175 | + * @return array |
|
176 | + * @since $VID:$ |
|
177 | + */ |
|
178 | + protected function getEventGraphQLData($eventId) |
|
179 | + { |
|
180 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
181 | + |
|
182 | + if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
183 | + $this->addDefaultEntities($eventId); |
|
184 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
185 | + } |
|
186 | + |
|
187 | + if (! empty($datetimes['nodes'])) { |
|
188 | + $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
189 | + |
|
190 | + if (! empty($datetimeIn)) { |
|
191 | + $tickets = $this->getGraphQLTickets($datetimeIn); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + if (! empty($tickets['nodes'])) { |
|
196 | + $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
197 | + |
|
198 | + if (! empty($ticketIn)) { |
|
199 | + $prices = $this->getGraphQLPrices($ticketIn); |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + $priceTypes = $this->getGraphQLPriceTypes(); |
|
204 | + |
|
205 | + $relations = $this->getRelationalData($eventId); |
|
206 | + |
|
207 | + return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * @param int $eventId |
|
212 | + * @throws DomainException |
|
213 | + * @throws EE_Error |
|
214 | + * @throws InvalidArgumentException |
|
215 | + * @throws InvalidDataTypeException |
|
216 | + * @throws InvalidInterfaceException |
|
217 | + * @throws ModelConfigurationException |
|
218 | + * @throws ReflectionException |
|
219 | + * @throws UnexpectedEntityException |
|
220 | + * @since $VID:$ |
|
221 | + */ |
|
222 | + protected function addDefaultEntities($eventId) |
|
223 | + { |
|
224 | + $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
225 | + if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
226 | + $default_date = $default_dates[0]; |
|
227 | + $default_date->save(); |
|
228 | + $default_date->_add_relation_to($eventId, 'Event'); |
|
229 | + $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
230 | + $default_prices = $this->price_model->get_all_default_prices(); |
|
231 | + foreach ($default_tickets as $default_ticket) { |
|
232 | + $default_ticket->save(); |
|
233 | + $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
234 | + foreach ($default_prices as $default_price) { |
|
235 | + $default_price->save(); |
|
236 | + $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
237 | + } |
|
238 | + } |
|
239 | + } |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * @param int $eventId |
|
245 | + * @return array|null |
|
246 | + * @since $VID:$ |
|
247 | + */ |
|
248 | + protected function getGraphQLDatetimes($eventId) |
|
249 | + { |
|
250 | + $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
251 | + $query = <<<QUERY |
|
252 | 252 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
253 | 253 | {$field_key}(where: \$where) { |
254 | 254 | nodes { |
@@ -276,31 +276,31 @@ discard block |
||
276 | 276 | } |
277 | 277 | } |
278 | 278 | QUERY; |
279 | - $data = [ |
|
280 | - 'operation_name' => 'GET_DATETIMES', |
|
281 | - 'variables' => [ |
|
282 | - 'first' => 50, |
|
283 | - 'where' => [ |
|
284 | - 'eventId' => $eventId, |
|
285 | - ], |
|
286 | - ], |
|
287 | - 'query' => $query, |
|
288 | - ]; |
|
289 | - |
|
290 | - $responseData = $this->makeGraphQLRequest($data); |
|
291 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
292 | - } |
|
293 | - |
|
294 | - |
|
295 | - /** |
|
296 | - * @param array $datetimeIn |
|
297 | - * @return array|null |
|
298 | - * @since $VID:$ |
|
299 | - */ |
|
300 | - protected function getGraphQLTickets(array $datetimeIn) |
|
301 | - { |
|
302 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
303 | - $query = <<<QUERY |
|
279 | + $data = [ |
|
280 | + 'operation_name' => 'GET_DATETIMES', |
|
281 | + 'variables' => [ |
|
282 | + 'first' => 50, |
|
283 | + 'where' => [ |
|
284 | + 'eventId' => $eventId, |
|
285 | + ], |
|
286 | + ], |
|
287 | + 'query' => $query, |
|
288 | + ]; |
|
289 | + |
|
290 | + $responseData = $this->makeGraphQLRequest($data); |
|
291 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
292 | + } |
|
293 | + |
|
294 | + |
|
295 | + /** |
|
296 | + * @param array $datetimeIn |
|
297 | + * @return array|null |
|
298 | + * @since $VID:$ |
|
299 | + */ |
|
300 | + protected function getGraphQLTickets(array $datetimeIn) |
|
301 | + { |
|
302 | + $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
303 | + $query = <<<QUERY |
|
304 | 304 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
305 | 305 | {$field_key}(where: \$where) { |
306 | 306 | nodes { |
@@ -331,30 +331,30 @@ discard block |
||
331 | 331 | } |
332 | 332 | } |
333 | 333 | QUERY; |
334 | - $data = [ |
|
335 | - 'operation_name' => 'GET_TICKETS', |
|
336 | - 'variables' => [ |
|
337 | - 'where' => [ |
|
338 | - 'datetimeIn' => $datetimeIn, |
|
339 | - ], |
|
340 | - ], |
|
341 | - 'query' => $query, |
|
342 | - ]; |
|
343 | - |
|
344 | - $responseData = $this->makeGraphQLRequest($data); |
|
345 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * @param array $ticketIn |
|
351 | - * @return array|null |
|
352 | - * @since $VID:$ |
|
353 | - */ |
|
354 | - protected function getGraphQLPrices(array $ticketIn) |
|
355 | - { |
|
356 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
357 | - $query = <<<QUERY |
|
334 | + $data = [ |
|
335 | + 'operation_name' => 'GET_TICKETS', |
|
336 | + 'variables' => [ |
|
337 | + 'where' => [ |
|
338 | + 'datetimeIn' => $datetimeIn, |
|
339 | + ], |
|
340 | + ], |
|
341 | + 'query' => $query, |
|
342 | + ]; |
|
343 | + |
|
344 | + $responseData = $this->makeGraphQLRequest($data); |
|
345 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * @param array $ticketIn |
|
351 | + * @return array|null |
|
352 | + * @since $VID:$ |
|
353 | + */ |
|
354 | + protected function getGraphQLPrices(array $ticketIn) |
|
355 | + { |
|
356 | + $field_key = lcfirst($this->namespace) . 'Prices'; |
|
357 | + $query = <<<QUERY |
|
358 | 358 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
359 | 359 | {$field_key}(where: \$where) { |
360 | 360 | nodes { |
@@ -378,29 +378,29 @@ discard block |
||
378 | 378 | } |
379 | 379 | } |
380 | 380 | QUERY; |
381 | - $data = [ |
|
382 | - 'operation_name' => 'GET_PRICES', |
|
383 | - 'variables' => [ |
|
384 | - 'where' => [ |
|
385 | - 'ticketIn' => $ticketIn, |
|
386 | - ], |
|
387 | - ], |
|
388 | - 'query' => $query, |
|
389 | - ]; |
|
390 | - |
|
391 | - $responseData = $this->makeGraphQLRequest($data); |
|
392 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * @return array|null |
|
398 | - * @since $VID:$ |
|
399 | - */ |
|
400 | - protected function getGraphQLPriceTypes() |
|
401 | - { |
|
402 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
403 | - $query = <<<QUERY |
|
381 | + $data = [ |
|
382 | + 'operation_name' => 'GET_PRICES', |
|
383 | + 'variables' => [ |
|
384 | + 'where' => [ |
|
385 | + 'ticketIn' => $ticketIn, |
|
386 | + ], |
|
387 | + ], |
|
388 | + 'query' => $query, |
|
389 | + ]; |
|
390 | + |
|
391 | + $responseData = $this->makeGraphQLRequest($data); |
|
392 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * @return array|null |
|
398 | + * @since $VID:$ |
|
399 | + */ |
|
400 | + protected function getGraphQLPriceTypes() |
|
401 | + { |
|
402 | + $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
403 | + $query = <<<QUERY |
|
404 | 404 | query GET_PRICES { |
405 | 405 | {$field_key} { |
406 | 406 | nodes { |
@@ -420,24 +420,24 @@ discard block |
||
420 | 420 | } |
421 | 421 | } |
422 | 422 | QUERY; |
423 | - $data = [ |
|
424 | - 'operation_name' => 'GET_PRICES', |
|
425 | - 'query' => $query, |
|
426 | - ]; |
|
427 | - |
|
428 | - $responseData = $this->makeGraphQLRequest($data); |
|
429 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
430 | - } |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * @return array|null |
|
435 | - * @since $VID:$ |
|
436 | - */ |
|
437 | - protected function getGraphQLCurrentUser() |
|
438 | - { |
|
439 | - $field_key = 'viewer'; |
|
440 | - $query = <<<QUERY |
|
423 | + $data = [ |
|
424 | + 'operation_name' => 'GET_PRICES', |
|
425 | + 'query' => $query, |
|
426 | + ]; |
|
427 | + |
|
428 | + $responseData = $this->makeGraphQLRequest($data); |
|
429 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
430 | + } |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * @return array|null |
|
435 | + * @since $VID:$ |
|
436 | + */ |
|
437 | + protected function getGraphQLCurrentUser() |
|
438 | + { |
|
439 | + $field_key = 'viewer'; |
|
440 | + $query = <<<QUERY |
|
441 | 441 | query GET_CURRENT_USER { |
442 | 442 | {$field_key} { |
443 | 443 | description |
@@ -455,24 +455,24 @@ discard block |
||
455 | 455 | } |
456 | 456 | } |
457 | 457 | QUERY; |
458 | - $data = [ |
|
459 | - 'operation_name' => 'GET_CURRENT_USER', |
|
460 | - 'query' => $query, |
|
461 | - ]; |
|
462 | - |
|
463 | - $responseData = $this->makeGraphQLRequest($data); |
|
464 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
465 | - } |
|
466 | - |
|
467 | - |
|
468 | - /** |
|
469 | - * @return array|null |
|
470 | - * @since $VID:$ |
|
471 | - */ |
|
472 | - protected function getGraphQLGeneralSettings() |
|
473 | - { |
|
474 | - $field_key = 'generalSettings'; |
|
475 | - $query = <<<QUERY |
|
458 | + $data = [ |
|
459 | + 'operation_name' => 'GET_CURRENT_USER', |
|
460 | + 'query' => $query, |
|
461 | + ]; |
|
462 | + |
|
463 | + $responseData = $this->makeGraphQLRequest($data); |
|
464 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
465 | + } |
|
466 | + |
|
467 | + |
|
468 | + /** |
|
469 | + * @return array|null |
|
470 | + * @since $VID:$ |
|
471 | + */ |
|
472 | + protected function getGraphQLGeneralSettings() |
|
473 | + { |
|
474 | + $field_key = 'generalSettings'; |
|
475 | + $query = <<<QUERY |
|
476 | 476 | query GET_GENERAL_SETTINGS { |
477 | 477 | {$field_key} { |
478 | 478 | dateFormat |
@@ -482,143 +482,143 @@ discard block |
||
482 | 482 | } |
483 | 483 | } |
484 | 484 | QUERY; |
485 | - $data = [ |
|
486 | - 'operation_name' => 'GET_CURRENT_USER', |
|
487 | - 'query' => $query, |
|
488 | - ]; |
|
489 | - |
|
490 | - $responseData = $this->makeGraphQLRequest($data); |
|
491 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - /** |
|
496 | - * @param array $data |
|
497 | - * @return array |
|
498 | - * @since $VID:$ |
|
499 | - */ |
|
500 | - protected function makeGraphQLRequest($data) |
|
501 | - { |
|
502 | - try { |
|
503 | - $response = graphql($data); |
|
504 | - if (!empty($response['data'])) { |
|
505 | - return $response['data']; |
|
506 | - } |
|
507 | - return null; |
|
508 | - } catch (\Exception $e) { |
|
509 | - // do something with the errors thrown |
|
510 | - return null; |
|
511 | - } |
|
512 | - } |
|
513 | - |
|
514 | - |
|
515 | - /** |
|
516 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
517 | - * @param array $args The inputArgs on the field |
|
518 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
519 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
520 | - * @return string |
|
521 | - * @throws EE_Error |
|
522 | - * @throws Exception |
|
523 | - * @throws InvalidArgumentException |
|
524 | - * @throws InvalidDataTypeException |
|
525 | - * @throws InvalidInterfaceException |
|
526 | - * @throws ReflectionException |
|
527 | - * @throws UserError |
|
528 | - * @throws UnexpectedEntityException |
|
529 | - * @since $VID:$ |
|
530 | - */ |
|
531 | - public static function getRelationalData($eventId) |
|
532 | - { |
|
533 | - $data = [ |
|
534 | - 'datetimes' => [], |
|
535 | - 'tickets' => [], |
|
536 | - 'prices' => [], |
|
537 | - ]; |
|
538 | - |
|
539 | - $eem_datetime = EEM_Datetime::instance(); |
|
540 | - $eem_ticket = EEM_Ticket::instance(); |
|
541 | - $eem_price = EEM_Price::instance(); |
|
542 | - $eem_price_type = EEM_Price_Type::instance(); |
|
543 | - |
|
544 | - // PROCESS DATETIMES |
|
545 | - $related_models = [ |
|
546 | - 'tickets' => $eem_ticket, |
|
547 | - ]; |
|
548 | - // Get the IDs of event datetimes. |
|
549 | - $datetimeIds = $eem_datetime->get_col([[ |
|
550 | - 'EVT_ID' => $eventId, |
|
551 | - 'DTT_deleted' => ['IN', [true, false]], |
|
552 | - ]]); |
|
553 | - foreach ($datetimeIds as $datetimeId) { |
|
554 | - $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
555 | - foreach ($related_models as $key => $model) { |
|
556 | - // Get the IDs of related entities for the datetime ID. |
|
557 | - $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
558 | - if (! empty($Ids)) { |
|
559 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
560 | - } |
|
561 | - } |
|
562 | - } |
|
563 | - |
|
564 | - // PROCESS TICKETS |
|
565 | - $related_models = [ |
|
566 | - 'datetimes' => $eem_datetime, |
|
567 | - 'prices' => $eem_price, |
|
568 | - ]; |
|
569 | - // Get the IDs of all datetime tickets. |
|
570 | - $ticketIds = $eem_ticket->get_col([[ |
|
571 | - 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
572 | - 'TKT_deleted' => ['IN', [true, false]], |
|
573 | - ]]); |
|
574 | - foreach ($ticketIds as $ticketId) { |
|
575 | - $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
576 | - |
|
577 | - foreach ($related_models as $key => $model) { |
|
578 | - // Get the IDs of related entities for the ticket ID. |
|
579 | - $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
580 | - if (! empty($Ids)) { |
|
581 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
582 | - } |
|
583 | - } |
|
584 | - } |
|
585 | - |
|
586 | - // PROCESS PRICES |
|
587 | - $related_models = [ |
|
588 | - 'tickets' => $eem_ticket, |
|
589 | - 'priceTypes' => $eem_price_type, |
|
590 | - ]; |
|
591 | - // Get the IDs of all ticket prices. |
|
592 | - $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
593 | - foreach ($priceIds as $priceId) { |
|
594 | - $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
595 | - |
|
596 | - foreach ($related_models as $key => $model) { |
|
597 | - // Get the IDs of related entities for the price ID. |
|
598 | - $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
599 | - if (! empty($Ids)) { |
|
600 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
601 | - } |
|
602 | - } |
|
603 | - } |
|
604 | - |
|
605 | - return $data; |
|
606 | - } |
|
607 | - |
|
608 | - /** |
|
609 | - * Convert the DB ID into GID |
|
610 | - * |
|
611 | - * @param string $type |
|
612 | - * @param int|int[] $ID |
|
613 | - * @return mixed |
|
614 | - */ |
|
615 | - public static function convertToGlobalId($type, $ID) |
|
616 | - { |
|
617 | - if (is_array($ID)) { |
|
618 | - return array_map(function ($id) use ($type) { |
|
619 | - return self::convertToGlobalId($type, $id); |
|
620 | - }, $ID); |
|
621 | - } |
|
622 | - return Relay::toGlobalId($type, $ID); |
|
623 | - } |
|
485 | + $data = [ |
|
486 | + 'operation_name' => 'GET_CURRENT_USER', |
|
487 | + 'query' => $query, |
|
488 | + ]; |
|
489 | + |
|
490 | + $responseData = $this->makeGraphQLRequest($data); |
|
491 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + /** |
|
496 | + * @param array $data |
|
497 | + * @return array |
|
498 | + * @since $VID:$ |
|
499 | + */ |
|
500 | + protected function makeGraphQLRequest($data) |
|
501 | + { |
|
502 | + try { |
|
503 | + $response = graphql($data); |
|
504 | + if (!empty($response['data'])) { |
|
505 | + return $response['data']; |
|
506 | + } |
|
507 | + return null; |
|
508 | + } catch (\Exception $e) { |
|
509 | + // do something with the errors thrown |
|
510 | + return null; |
|
511 | + } |
|
512 | + } |
|
513 | + |
|
514 | + |
|
515 | + /** |
|
516 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
517 | + * @param array $args The inputArgs on the field |
|
518 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
519 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
520 | + * @return string |
|
521 | + * @throws EE_Error |
|
522 | + * @throws Exception |
|
523 | + * @throws InvalidArgumentException |
|
524 | + * @throws InvalidDataTypeException |
|
525 | + * @throws InvalidInterfaceException |
|
526 | + * @throws ReflectionException |
|
527 | + * @throws UserError |
|
528 | + * @throws UnexpectedEntityException |
|
529 | + * @since $VID:$ |
|
530 | + */ |
|
531 | + public static function getRelationalData($eventId) |
|
532 | + { |
|
533 | + $data = [ |
|
534 | + 'datetimes' => [], |
|
535 | + 'tickets' => [], |
|
536 | + 'prices' => [], |
|
537 | + ]; |
|
538 | + |
|
539 | + $eem_datetime = EEM_Datetime::instance(); |
|
540 | + $eem_ticket = EEM_Ticket::instance(); |
|
541 | + $eem_price = EEM_Price::instance(); |
|
542 | + $eem_price_type = EEM_Price_Type::instance(); |
|
543 | + |
|
544 | + // PROCESS DATETIMES |
|
545 | + $related_models = [ |
|
546 | + 'tickets' => $eem_ticket, |
|
547 | + ]; |
|
548 | + // Get the IDs of event datetimes. |
|
549 | + $datetimeIds = $eem_datetime->get_col([[ |
|
550 | + 'EVT_ID' => $eventId, |
|
551 | + 'DTT_deleted' => ['IN', [true, false]], |
|
552 | + ]]); |
|
553 | + foreach ($datetimeIds as $datetimeId) { |
|
554 | + $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
555 | + foreach ($related_models as $key => $model) { |
|
556 | + // Get the IDs of related entities for the datetime ID. |
|
557 | + $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
558 | + if (! empty($Ids)) { |
|
559 | + $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
560 | + } |
|
561 | + } |
|
562 | + } |
|
563 | + |
|
564 | + // PROCESS TICKETS |
|
565 | + $related_models = [ |
|
566 | + 'datetimes' => $eem_datetime, |
|
567 | + 'prices' => $eem_price, |
|
568 | + ]; |
|
569 | + // Get the IDs of all datetime tickets. |
|
570 | + $ticketIds = $eem_ticket->get_col([[ |
|
571 | + 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
572 | + 'TKT_deleted' => ['IN', [true, false]], |
|
573 | + ]]); |
|
574 | + foreach ($ticketIds as $ticketId) { |
|
575 | + $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
576 | + |
|
577 | + foreach ($related_models as $key => $model) { |
|
578 | + // Get the IDs of related entities for the ticket ID. |
|
579 | + $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
580 | + if (! empty($Ids)) { |
|
581 | + $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
582 | + } |
|
583 | + } |
|
584 | + } |
|
585 | + |
|
586 | + // PROCESS PRICES |
|
587 | + $related_models = [ |
|
588 | + 'tickets' => $eem_ticket, |
|
589 | + 'priceTypes' => $eem_price_type, |
|
590 | + ]; |
|
591 | + // Get the IDs of all ticket prices. |
|
592 | + $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
593 | + foreach ($priceIds as $priceId) { |
|
594 | + $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
595 | + |
|
596 | + foreach ($related_models as $key => $model) { |
|
597 | + // Get the IDs of related entities for the price ID. |
|
598 | + $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
599 | + if (! empty($Ids)) { |
|
600 | + $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
601 | + } |
|
602 | + } |
|
603 | + } |
|
604 | + |
|
605 | + return $data; |
|
606 | + } |
|
607 | + |
|
608 | + /** |
|
609 | + * Convert the DB ID into GID |
|
610 | + * |
|
611 | + * @param string $type |
|
612 | + * @param int|int[] $ID |
|
613 | + * @return mixed |
|
614 | + */ |
|
615 | + public static function convertToGlobalId($type, $ID) |
|
616 | + { |
|
617 | + if (is_array($ID)) { |
|
618 | + return array_map(function ($id) use ($type) { |
|
619 | + return self::convertToGlobalId($type, $id); |
|
620 | + }, $ID); |
|
621 | + } |
|
622 | + return Relay::toGlobalId($type, $ID); |
|
623 | + } |
|
624 | 624 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | if ($this->admin_config->useAdvancedEditor()) { |
104 | 104 | $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
105 | - if (! $eventId) { |
|
105 | + if ( ! $eventId) { |
|
106 | 106 | global $post; |
107 | 107 | $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
108 | 108 | $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $data = wp_json_encode($data); |
115 | 115 | add_action( |
116 | 116 | 'admin_footer', |
117 | - static function () use ($data) { |
|
117 | + static function() use ($data) { |
|
118 | 118 | wp_add_inline_script( |
119 | 119 | EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
120 | 120 | " |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | ); |
127 | 127 | add_action( |
128 | 128 | 'admin_footer', |
129 | - static function () use ($data) { |
|
129 | + static function() use ($data) { |
|
130 | 130 | wp_add_inline_script( |
131 | 131 | EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
132 | 132 | " |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $event = $this->getEventGraphQLData($eventId); |
160 | 160 | $event['dbId'] = $eventId; |
161 | 161 | |
162 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
162 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : ''; |
|
163 | 163 | $graphqlEndpoint = esc_url($graphqlEndpoint); |
164 | 164 | |
165 | 165 | $currentUser = $this->getGraphQLCurrentUser(); |
@@ -184,18 +184,18 @@ discard block |
||
184 | 184 | $datetimes = $this->getGraphQLDatetimes($eventId); |
185 | 185 | } |
186 | 186 | |
187 | - if (! empty($datetimes['nodes'])) { |
|
187 | + if ( ! empty($datetimes['nodes'])) { |
|
188 | 188 | $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
189 | 189 | |
190 | - if (! empty($datetimeIn)) { |
|
190 | + if ( ! empty($datetimeIn)) { |
|
191 | 191 | $tickets = $this->getGraphQLTickets($datetimeIn); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if (! empty($tickets['nodes'])) { |
|
195 | + if ( ! empty($tickets['nodes'])) { |
|
196 | 196 | $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
197 | 197 | |
198 | - if (! empty($ticketIn)) { |
|
198 | + if ( ! empty($ticketIn)) { |
|
199 | 199 | $prices = $this->getGraphQLPrices($ticketIn); |
200 | 200 | } |
201 | 201 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | protected function getGraphQLDatetimes($eventId) |
249 | 249 | { |
250 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
250 | + $field_key = lcfirst($this->namespace).'Datetimes'; |
|
251 | 251 | $query = <<<QUERY |
252 | 252 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs) { |
253 | 253 | {$field_key}(where: \$where) { |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | ]; |
289 | 289 | |
290 | 290 | $responseData = $this->makeGraphQLRequest($data); |
291 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
291 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function getGraphQLTickets(array $datetimeIn) |
301 | 301 | { |
302 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
302 | + $field_key = lcfirst($this->namespace).'Tickets'; |
|
303 | 303 | $query = <<<QUERY |
304 | 304 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs) { |
305 | 305 | {$field_key}(where: \$where) { |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | ]; |
343 | 343 | |
344 | 344 | $responseData = $this->makeGraphQLRequest($data); |
345 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
345 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | */ |
354 | 354 | protected function getGraphQLPrices(array $ticketIn) |
355 | 355 | { |
356 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
356 | + $field_key = lcfirst($this->namespace).'Prices'; |
|
357 | 357 | $query = <<<QUERY |
358 | 358 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs) { |
359 | 359 | {$field_key}(where: \$where) { |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | ]; |
390 | 390 | |
391 | 391 | $responseData = $this->makeGraphQLRequest($data); |
392 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
392 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | */ |
400 | 400 | protected function getGraphQLPriceTypes() |
401 | 401 | { |
402 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
402 | + $field_key = lcfirst($this->namespace).'PriceTypes'; |
|
403 | 403 | $query = <<<QUERY |
404 | 404 | query GET_PRICES { |
405 | 405 | {$field_key} { |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | ]; |
427 | 427 | |
428 | 428 | $responseData = $this->makeGraphQLRequest($data); |
429 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
429 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | ]; |
462 | 462 | |
463 | 463 | $responseData = $this->makeGraphQLRequest($data); |
464 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
464 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | ]; |
489 | 489 | |
490 | 490 | $responseData = $this->makeGraphQLRequest($data); |
491 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
491 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | { |
502 | 502 | try { |
503 | 503 | $response = graphql($data); |
504 | - if (!empty($response['data'])) { |
|
504 | + if ( ! empty($response['data'])) { |
|
505 | 505 | return $response['data']; |
506 | 506 | } |
507 | 507 | return null; |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | foreach ($related_models as $key => $model) { |
556 | 556 | // Get the IDs of related entities for the datetime ID. |
557 | 557 | $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
558 | - if (! empty($Ids)) { |
|
559 | - $data['datetimes'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
558 | + if ( ! empty($Ids)) { |
|
559 | + $data['datetimes'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | } |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | foreach ($related_models as $key => $model) { |
578 | 578 | // Get the IDs of related entities for the ticket ID. |
579 | 579 | $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
580 | - if (! empty($Ids)) { |
|
581 | - $data['tickets'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
580 | + if ( ! empty($Ids)) { |
|
581 | + $data['tickets'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
582 | 582 | } |
583 | 583 | } |
584 | 584 | } |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | foreach ($related_models as $key => $model) { |
597 | 597 | // Get the IDs of related entities for the price ID. |
598 | 598 | $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
599 | - if (! empty($Ids)) { |
|
600 | - $data['prices'][ $GID ][ $key ] = self::convertToGlobalId($model->item_name(), $Ids); |
|
599 | + if ( ! empty($Ids)) { |
|
600 | + $data['prices'][$GID][$key] = self::convertToGlobalId($model->item_name(), $Ids); |
|
601 | 601 | } |
602 | 602 | } |
603 | 603 | } |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | public static function convertToGlobalId($type, $ID) |
616 | 616 | { |
617 | 617 | if (is_array($ID)) { |
618 | - return array_map(function ($id) use ($type) { |
|
618 | + return array_map(function($id) use ($type) { |
|
619 | 619 | return self::convertToGlobalId($type, $id); |
620 | 620 | }, $ID); |
621 | 621 | } |
@@ -28,123 +28,123 @@ |
||
28 | 28 | class TicketMutation |
29 | 29 | { |
30 | 30 | |
31 | - /** |
|
32 | - * Maps the GraphQL input to a format that the model functions can use |
|
33 | - * |
|
34 | - * @param array $input Data coming from the GraphQL mutation query input |
|
35 | - * @return array |
|
36 | - */ |
|
37 | - public static function prepareFields(array $input) |
|
38 | - { |
|
39 | - $args = []; |
|
40 | - |
|
41 | - if (! empty($input['name'])) { |
|
42 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
43 | - } |
|
44 | - |
|
45 | - if (! empty($input['description'])) { |
|
46 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
47 | - } |
|
48 | - |
|
49 | - if (! empty($input['price'])) { |
|
50 | - $args['TKT_price'] = floatval($input['price']); |
|
51 | - } |
|
52 | - |
|
53 | - if (! empty($input['startDate'])) { |
|
54 | - $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
55 | - } |
|
56 | - |
|
57 | - if (! empty($input['endDate'])) { |
|
58 | - $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
59 | - } |
|
60 | - |
|
61 | - if (! empty($input['datetimes'])) { |
|
62 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
63 | - } |
|
64 | - |
|
65 | - if (! empty($input['prices'])) { |
|
66 | - $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
67 | - } |
|
68 | - |
|
69 | - if (array_key_exists('isTrashed', $input)) { |
|
70 | - $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
71 | - } |
|
72 | - |
|
73 | - // Likewise the other fields... |
|
74 | - |
|
75 | - return $args; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * Sets the related datetimes for the given ticket. |
|
80 | - * |
|
81 | - * @param EE_Ticket $entity The Ticket instance. |
|
82 | - * @param array $datetimes Array of datetime IDs to relate. |
|
83 | - */ |
|
84 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
85 | - { |
|
86 | - $relationName = 'Datetime'; |
|
87 | - // Remove all the existing related datetimes |
|
88 | - |
|
89 | - $entity->_remove_relations($relationName); |
|
90 | - // @todo replace loop with single query |
|
91 | - foreach ($datetimes as $ID) { |
|
92 | - $parts = Relay::fromGlobalId($ID); |
|
93 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
94 | - $entity->_add_relation_to( |
|
95 | - $parts['id'], |
|
96 | - $relationName |
|
97 | - ); |
|
98 | - } |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Sets the related prices for the given ticket. |
|
104 | - * |
|
105 | - * @param EE_Ticket $entity The Ticket instance. |
|
106 | - * @param array $prices Array of entity IDs to relate. |
|
107 | - */ |
|
108 | - public static function setRelatedPrices($entity, array $prices) |
|
109 | - { |
|
110 | - $relationName = 'Price'; |
|
111 | - // Remove all the existing related entities |
|
112 | - $entity->_remove_relations($relationName); |
|
113 | - |
|
114 | - // @todo replace loop with single query |
|
115 | - foreach ($prices as $ID) { |
|
116 | - $parts = Relay::fromGlobalId($ID); |
|
117 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
118 | - $entity->_add_relation_to( |
|
119 | - $parts['id'], |
|
120 | - $relationName |
|
121 | - ); |
|
122 | - } |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - /** |
|
128 | - * @param EE_Ticket $ticket_entity |
|
129 | - * @param EEM_Ticket $ticket_model |
|
130 | - * @throws DomainException |
|
131 | - * @throws EE_Error |
|
132 | - * @throws InvalidArgumentException |
|
133 | - * @throws InvalidDataTypeException |
|
134 | - * @throws InvalidInterfaceException |
|
135 | - * @throws ModelConfigurationException |
|
136 | - * @throws ReflectionException |
|
137 | - * @throws RestException |
|
138 | - * @throws UnexpectedEntityException |
|
139 | - * @since $VID:$ |
|
140 | - */ |
|
141 | - public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
142 | - { |
|
143 | - $price_model = EEM_Price::instance(); |
|
144 | - $default_prices = $price_model->get_all_default_prices(); |
|
145 | - foreach ($default_prices as $default_price) { |
|
146 | - $default_price->save(); |
|
147 | - $default_price->_add_relation_to($ticket_entity, 'Ticket'); |
|
148 | - } |
|
149 | - } |
|
31 | + /** |
|
32 | + * Maps the GraphQL input to a format that the model functions can use |
|
33 | + * |
|
34 | + * @param array $input Data coming from the GraphQL mutation query input |
|
35 | + * @return array |
|
36 | + */ |
|
37 | + public static function prepareFields(array $input) |
|
38 | + { |
|
39 | + $args = []; |
|
40 | + |
|
41 | + if (! empty($input['name'])) { |
|
42 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
43 | + } |
|
44 | + |
|
45 | + if (! empty($input['description'])) { |
|
46 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
47 | + } |
|
48 | + |
|
49 | + if (! empty($input['price'])) { |
|
50 | + $args['TKT_price'] = floatval($input['price']); |
|
51 | + } |
|
52 | + |
|
53 | + if (! empty($input['startDate'])) { |
|
54 | + $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
55 | + } |
|
56 | + |
|
57 | + if (! empty($input['endDate'])) { |
|
58 | + $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
59 | + } |
|
60 | + |
|
61 | + if (! empty($input['datetimes'])) { |
|
62 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
63 | + } |
|
64 | + |
|
65 | + if (! empty($input['prices'])) { |
|
66 | + $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
|
67 | + } |
|
68 | + |
|
69 | + if (array_key_exists('isTrashed', $input)) { |
|
70 | + $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
71 | + } |
|
72 | + |
|
73 | + // Likewise the other fields... |
|
74 | + |
|
75 | + return $args; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * Sets the related datetimes for the given ticket. |
|
80 | + * |
|
81 | + * @param EE_Ticket $entity The Ticket instance. |
|
82 | + * @param array $datetimes Array of datetime IDs to relate. |
|
83 | + */ |
|
84 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
85 | + { |
|
86 | + $relationName = 'Datetime'; |
|
87 | + // Remove all the existing related datetimes |
|
88 | + |
|
89 | + $entity->_remove_relations($relationName); |
|
90 | + // @todo replace loop with single query |
|
91 | + foreach ($datetimes as $ID) { |
|
92 | + $parts = Relay::fromGlobalId($ID); |
|
93 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
94 | + $entity->_add_relation_to( |
|
95 | + $parts['id'], |
|
96 | + $relationName |
|
97 | + ); |
|
98 | + } |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Sets the related prices for the given ticket. |
|
104 | + * |
|
105 | + * @param EE_Ticket $entity The Ticket instance. |
|
106 | + * @param array $prices Array of entity IDs to relate. |
|
107 | + */ |
|
108 | + public static function setRelatedPrices($entity, array $prices) |
|
109 | + { |
|
110 | + $relationName = 'Price'; |
|
111 | + // Remove all the existing related entities |
|
112 | + $entity->_remove_relations($relationName); |
|
113 | + |
|
114 | + // @todo replace loop with single query |
|
115 | + foreach ($prices as $ID) { |
|
116 | + $parts = Relay::fromGlobalId($ID); |
|
117 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
118 | + $entity->_add_relation_to( |
|
119 | + $parts['id'], |
|
120 | + $relationName |
|
121 | + ); |
|
122 | + } |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + /** |
|
128 | + * @param EE_Ticket $ticket_entity |
|
129 | + * @param EEM_Ticket $ticket_model |
|
130 | + * @throws DomainException |
|
131 | + * @throws EE_Error |
|
132 | + * @throws InvalidArgumentException |
|
133 | + * @throws InvalidDataTypeException |
|
134 | + * @throws InvalidInterfaceException |
|
135 | + * @throws ModelConfigurationException |
|
136 | + * @throws ReflectionException |
|
137 | + * @throws RestException |
|
138 | + * @throws UnexpectedEntityException |
|
139 | + * @since $VID:$ |
|
140 | + */ |
|
141 | + public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
142 | + { |
|
143 | + $price_model = EEM_Price::instance(); |
|
144 | + $default_prices = $price_model->get_all_default_prices(); |
|
145 | + foreach ($default_prices as $default_price) { |
|
146 | + $default_price->save(); |
|
147 | + $default_price->_add_relation_to($ticket_entity, 'Ticket'); |
|
148 | + } |
|
149 | + } |
|
150 | 150 | } |
@@ -38,31 +38,31 @@ discard block |
||
38 | 38 | { |
39 | 39 | $args = []; |
40 | 40 | |
41 | - if (! empty($input['name'])) { |
|
41 | + if ( ! empty($input['name'])) { |
|
42 | 42 | $args['TKT_name'] = sanitize_text_field($input['name']); |
43 | 43 | } |
44 | 44 | |
45 | - if (! empty($input['description'])) { |
|
45 | + if ( ! empty($input['description'])) { |
|
46 | 46 | $args['TKT_description'] = sanitize_text_field($input['description']); |
47 | 47 | } |
48 | 48 | |
49 | - if (! empty($input['price'])) { |
|
49 | + if ( ! empty($input['price'])) { |
|
50 | 50 | $args['TKT_price'] = floatval($input['price']); |
51 | 51 | } |
52 | 52 | |
53 | - if (! empty($input['startDate'])) { |
|
53 | + if ( ! empty($input['startDate'])) { |
|
54 | 54 | $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
55 | 55 | } |
56 | 56 | |
57 | - if (! empty($input['endDate'])) { |
|
57 | + if ( ! empty($input['endDate'])) { |
|
58 | 58 | $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
59 | 59 | } |
60 | 60 | |
61 | - if (! empty($input['datetimes'])) { |
|
61 | + if ( ! empty($input['datetimes'])) { |
|
62 | 62 | $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
63 | 63 | } |
64 | 64 | |
65 | - if (! empty($input['prices'])) { |
|
65 | + if ( ! empty($input['prices'])) { |
|
66 | 66 | $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
67 | 67 | } |
68 | 68 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | // @todo replace loop with single query |
91 | 91 | foreach ($datetimes as $ID) { |
92 | 92 | $parts = Relay::fromGlobalId($ID); |
93 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
93 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
94 | 94 | $entity->_add_relation_to( |
95 | 95 | $parts['id'], |
96 | 96 | $relationName |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | // @todo replace loop with single query |
115 | 115 | foreach ($prices as $ID) { |
116 | 116 | $parts = Relay::fromGlobalId($ID); |
117 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
117 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
118 | 118 | $entity->_add_relation_to( |
119 | 119 | $parts['id'], |
120 | 120 | $relationName |
@@ -13,54 +13,54 @@ |
||
13 | 13 | class PriceMutation |
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 | - * @return array |
|
21 | - */ |
|
22 | - public static function prepareFields(array $input) |
|
23 | - { |
|
24 | - $args = []; |
|
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 | + * @return array |
|
21 | + */ |
|
22 | + public static function prepareFields(array $input) |
|
23 | + { |
|
24 | + $args = []; |
|
25 | 25 | |
26 | - if (! empty($input['priceType'])) { |
|
27 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
28 | - $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
29 | - } |
|
26 | + if (! empty($input['priceType'])) { |
|
27 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
|
28 | + $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
29 | + } |
|
30 | 30 | |
31 | - if (! empty($input['name'])) { |
|
32 | - $args['PRC_name'] = sanitize_text_field($input['name']); |
|
33 | - } |
|
31 | + if (! empty($input['name'])) { |
|
32 | + $args['PRC_name'] = sanitize_text_field($input['name']); |
|
33 | + } |
|
34 | 34 | |
35 | - if (! empty($input['desc'])) { |
|
36 | - $args['PRC_desc'] = sanitize_text_field($input['desc']); |
|
37 | - } |
|
35 | + if (! empty($input['desc'])) { |
|
36 | + $args['PRC_desc'] = sanitize_text_field($input['desc']); |
|
37 | + } |
|
38 | 38 | |
39 | - if (! empty($input['amount'])) { |
|
40 | - $args['PRC_amount'] = floatval($input['amount']); |
|
41 | - } |
|
39 | + if (! empty($input['amount'])) { |
|
40 | + $args['PRC_amount'] = floatval($input['amount']); |
|
41 | + } |
|
42 | 42 | |
43 | - if (array_key_exists('isDefault', $input)) { |
|
44 | - $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
45 | - } |
|
43 | + if (array_key_exists('isDefault', $input)) { |
|
44 | + $args['PRC_is_default'] = (bool) $input['isDefault']; |
|
45 | + } |
|
46 | 46 | |
47 | - if (array_key_exists('isTrashed', $input)) { |
|
48 | - $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
49 | - } |
|
47 | + if (array_key_exists('isTrashed', $input)) { |
|
48 | + $args['PRC_deleted'] = (bool) $input['isTrashed']; |
|
49 | + } |
|
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
52 | - $args['PRC_overrides'] = intval($input['overrides']); |
|
53 | - } |
|
51 | + if (! empty($input['overrides'])) { |
|
52 | + $args['PRC_overrides'] = intval($input['overrides']); |
|
53 | + } |
|
54 | 54 | |
55 | - if (! empty($input['order'])) { |
|
56 | - $args['PRC_order'] = intval($input['order']); |
|
57 | - } |
|
55 | + if (! empty($input['order'])) { |
|
56 | + $args['PRC_order'] = intval($input['order']); |
|
57 | + } |
|
58 | 58 | |
59 | - if (! empty($input['parent'])) { |
|
60 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
61 | - $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | - } |
|
59 | + if (! empty($input['parent'])) { |
|
60 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
61 | + $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
|
62 | + } |
|
63 | 63 | |
64 | - return $args; |
|
65 | - } |
|
64 | + return $args; |
|
65 | + } |
|
66 | 66 | } |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | { |
24 | 24 | $args = []; |
25 | 25 | |
26 | - if (! empty($input['priceType'])) { |
|
26 | + if ( ! empty($input['priceType'])) { |
|
27 | 27 | $parts = Relay::fromGlobalId(sanitize_text_field($input['priceType'])); |
28 | 28 | $args['PRT_ID'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
29 | 29 | } |
30 | 30 | |
31 | - if (! empty($input['name'])) { |
|
31 | + if ( ! empty($input['name'])) { |
|
32 | 32 | $args['PRC_name'] = sanitize_text_field($input['name']); |
33 | 33 | } |
34 | 34 | |
35 | - if (! empty($input['desc'])) { |
|
35 | + if ( ! empty($input['desc'])) { |
|
36 | 36 | $args['PRC_desc'] = sanitize_text_field($input['desc']); |
37 | 37 | } |
38 | 38 | |
39 | - if (! empty($input['amount'])) { |
|
39 | + if ( ! empty($input['amount'])) { |
|
40 | 40 | $args['PRC_amount'] = floatval($input['amount']); |
41 | 41 | } |
42 | 42 | |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | $args['PRC_deleted'] = (bool) $input['isTrashed']; |
49 | 49 | } |
50 | 50 | |
51 | - if (! empty($input['overrides'])) { |
|
51 | + if ( ! empty($input['overrides'])) { |
|
52 | 52 | $args['PRC_overrides'] = intval($input['overrides']); |
53 | 53 | } |
54 | 54 | |
55 | - if (! empty($input['order'])) { |
|
55 | + if ( ! empty($input['order'])) { |
|
56 | 56 | $args['PRC_order'] = intval($input['order']); |
57 | 57 | } |
58 | 58 | |
59 | - if (! empty($input['parent'])) { |
|
59 | + if ( ! empty($input['parent'])) { |
|
60 | 60 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
61 | 61 | $args['PRC_parent'] = ! empty($parts['id']) ? absint($parts['id']) : 0; |
62 | 62 | } |
@@ -20,78 +20,78 @@ |
||
20 | 20 | class DatetimeMutation |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * Maps the GraphQL input to a format that the model functions can use |
|
25 | - * |
|
26 | - * @param array $input Data coming from the GraphQL mutation query input |
|
27 | - * @return array |
|
28 | - */ |
|
29 | - public static function prepareFields(array $input) |
|
30 | - { |
|
31 | - $args = []; |
|
32 | - |
|
33 | - if (! empty($input['eventId'])) { |
|
34 | - $args['EVT_ID'] = absint($input['eventId']); |
|
35 | - } elseif (! empty($input['event'])) { |
|
36 | - $parts = Relay::fromGlobalId($input['event']); |
|
37 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
38 | - } |
|
39 | - |
|
40 | - if (! empty($input['name'])) { |
|
41 | - $args['DTT_name'] = sanitize_text_field($input['name']); |
|
42 | - } |
|
43 | - |
|
44 | - if (! empty($input['description'])) { |
|
45 | - $args['DTT_description'] = sanitize_text_field($input['description']); |
|
46 | - } |
|
47 | - |
|
48 | - if (! empty($input['startDate'])) { |
|
49 | - $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
50 | - } |
|
51 | - |
|
52 | - if (! empty($input['endDate'])) { |
|
53 | - $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
54 | - } |
|
55 | - |
|
56 | - if (! empty($input['tickets'])) { |
|
57 | - $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
58 | - } |
|
59 | - |
|
60 | - if (array_key_exists('isTrashed', $input)) { |
|
61 | - $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
62 | - } |
|
63 | - |
|
64 | - // Likewise the other fields... |
|
65 | - |
|
66 | - return $args; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Sets the related tickets for the given datetime. |
|
72 | - * |
|
73 | - * @param EE_Datetime $entity The datetime instance. |
|
74 | - * @param array $tickets Array of ticket IDs to relate. |
|
75 | - * @throws EE_Error |
|
76 | - * @throws InvalidDataTypeException |
|
77 | - * @throws InvalidInterfaceException |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws ReflectionException |
|
80 | - */ |
|
81 | - public static function setRelatedTickets($entity, array $tickets) |
|
82 | - { |
|
83 | - $relationName = 'Ticket'; |
|
84 | - // Remove all the existing related tickets |
|
85 | - $entity->_remove_relations($relationName); |
|
86 | - |
|
87 | - foreach ($tickets as $ID) { |
|
88 | - $parts = Relay::fromGlobalId($ID); |
|
89 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
90 | - $entity->_add_relation_to( |
|
91 | - $parts['id'], |
|
92 | - $relationName |
|
93 | - ); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
23 | + /** |
|
24 | + * Maps the GraphQL input to a format that the model functions can use |
|
25 | + * |
|
26 | + * @param array $input Data coming from the GraphQL mutation query input |
|
27 | + * @return array |
|
28 | + */ |
|
29 | + public static function prepareFields(array $input) |
|
30 | + { |
|
31 | + $args = []; |
|
32 | + |
|
33 | + if (! empty($input['eventId'])) { |
|
34 | + $args['EVT_ID'] = absint($input['eventId']); |
|
35 | + } elseif (! empty($input['event'])) { |
|
36 | + $parts = Relay::fromGlobalId($input['event']); |
|
37 | + $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
38 | + } |
|
39 | + |
|
40 | + if (! empty($input['name'])) { |
|
41 | + $args['DTT_name'] = sanitize_text_field($input['name']); |
|
42 | + } |
|
43 | + |
|
44 | + if (! empty($input['description'])) { |
|
45 | + $args['DTT_description'] = sanitize_text_field($input['description']); |
|
46 | + } |
|
47 | + |
|
48 | + if (! empty($input['startDate'])) { |
|
49 | + $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
50 | + } |
|
51 | + |
|
52 | + if (! empty($input['endDate'])) { |
|
53 | + $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
54 | + } |
|
55 | + |
|
56 | + if (! empty($input['tickets'])) { |
|
57 | + $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
|
58 | + } |
|
59 | + |
|
60 | + if (array_key_exists('isTrashed', $input)) { |
|
61 | + $args['DTT_deleted'] = (bool) $input['isTrashed']; |
|
62 | + } |
|
63 | + |
|
64 | + // Likewise the other fields... |
|
65 | + |
|
66 | + return $args; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Sets the related tickets for the given datetime. |
|
72 | + * |
|
73 | + * @param EE_Datetime $entity The datetime instance. |
|
74 | + * @param array $tickets Array of ticket IDs to relate. |
|
75 | + * @throws EE_Error |
|
76 | + * @throws InvalidDataTypeException |
|
77 | + * @throws InvalidInterfaceException |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws ReflectionException |
|
80 | + */ |
|
81 | + public static function setRelatedTickets($entity, array $tickets) |
|
82 | + { |
|
83 | + $relationName = 'Ticket'; |
|
84 | + // Remove all the existing related tickets |
|
85 | + $entity->_remove_relations($relationName); |
|
86 | + |
|
87 | + foreach ($tickets as $ID) { |
|
88 | + $parts = Relay::fromGlobalId($ID); |
|
89 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
90 | + $entity->_add_relation_to( |
|
91 | + $parts['id'], |
|
92 | + $relationName |
|
93 | + ); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | 97 | } |
@@ -30,30 +30,30 @@ discard block |
||
30 | 30 | { |
31 | 31 | $args = []; |
32 | 32 | |
33 | - if (! empty($input['eventId'])) { |
|
33 | + if ( ! empty($input['eventId'])) { |
|
34 | 34 | $args['EVT_ID'] = absint($input['eventId']); |
35 | - } elseif (! empty($input['event'])) { |
|
35 | + } elseif ( ! empty($input['event'])) { |
|
36 | 36 | $parts = Relay::fromGlobalId($input['event']); |
37 | - $args['EVT_ID'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
37 | + $args['EVT_ID'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
38 | 38 | } |
39 | 39 | |
40 | - if (! empty($input['name'])) { |
|
40 | + if ( ! empty($input['name'])) { |
|
41 | 41 | $args['DTT_name'] = sanitize_text_field($input['name']); |
42 | 42 | } |
43 | 43 | |
44 | - if (! empty($input['description'])) { |
|
44 | + if ( ! empty($input['description'])) { |
|
45 | 45 | $args['DTT_description'] = sanitize_text_field($input['description']); |
46 | 46 | } |
47 | 47 | |
48 | - if (! empty($input['startDate'])) { |
|
48 | + if ( ! empty($input['startDate'])) { |
|
49 | 49 | $args['DTT_EVT_start'] = new DateTime(sanitize_text_field($input['startDate'])); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($input['endDate'])) { |
|
52 | + if ( ! empty($input['endDate'])) { |
|
53 | 53 | $args['DTT_EVT_end'] = new DateTime(sanitize_text_field($input['endDate'])); |
54 | 54 | } |
55 | 55 | |
56 | - if (! empty($input['tickets'])) { |
|
56 | + if ( ! empty($input['tickets'])) { |
|
57 | 57 | $args['tickets'] = array_map('sanitize_text_field', (array) $input['tickets']); |
58 | 58 | } |
59 | 59 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | foreach ($tickets as $ID) { |
88 | 88 | $parts = Relay::fromGlobalId($ID); |
89 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
89 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
90 | 90 | $entity->_add_relation_to( |
91 | 91 | $parts['id'], |
92 | 92 | $relationName |
@@ -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 GraphQLField( |
|
207 | - 'isTrashed', |
|
208 | - 'Boolean', |
|
209 | - null, |
|
210 | - esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
211 | - null, |
|
212 | - [$this, 'getIsTrashed'] |
|
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 GraphQLField( |
|
207 | + 'isTrashed', |
|
208 | + 'Boolean', |
|
209 | + null, |
|
210 | + esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
211 | + null, |
|
212 | + [$this, 'getIsTrashed'] |
|
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 getIsTrashed(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 getIsTrashed(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 | } |
@@ -25,215 +25,215 @@ |
||
25 | 25 | class Price extends TypeBase |
26 | 26 | { |
27 | 27 | |
28 | - /** |
|
29 | - * Price constructor. |
|
30 | - * |
|
31 | - * @param EEM_Price $price_model |
|
32 | - */ |
|
33 | - public function __construct(EEM_Price $price_model) |
|
34 | - { |
|
35 | - $this->model = $price_model; |
|
36 | - $this->setName($this->namespace . 'Price'); |
|
37 | - $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct(); |
|
40 | - } |
|
28 | + /** |
|
29 | + * Price constructor. |
|
30 | + * |
|
31 | + * @param EEM_Price $price_model |
|
32 | + */ |
|
33 | + public function __construct(EEM_Price $price_model) |
|
34 | + { |
|
35 | + $this->model = $price_model; |
|
36 | + $this->setName($this->namespace . 'Price'); |
|
37 | + $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct(); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields() |
|
48 | - { |
|
49 | - return [ |
|
50 | - new GraphQLField( |
|
51 | - 'id', |
|
52 | - ['non_null' => 'ID'], |
|
53 | - null, |
|
54 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLOutputField( |
|
57 | - 'dbId', |
|
58 | - ['non_null' => 'Int'], |
|
59 | - 'ID', |
|
60 | - esc_html__('Price ID', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLField( |
|
63 | - 'name', |
|
64 | - 'String', |
|
65 | - 'name', |
|
66 | - esc_html__('Price Name', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'amount', |
|
70 | - 'Float', |
|
71 | - 'amount', |
|
72 | - esc_html__('Price Amount', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'desc', |
|
76 | - 'String', |
|
77 | - 'desc', |
|
78 | - esc_html__('Price description', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLField( |
|
81 | - 'overrides', |
|
82 | - 'Int', |
|
83 | - 'overrides', |
|
84 | - esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'order', |
|
88 | - 'Int', |
|
89 | - 'order', |
|
90 | - esc_html__('Order of Application of Price.', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLOutputField( |
|
93 | - 'parent', |
|
94 | - $this->name(), |
|
95 | - null, |
|
96 | - esc_html__('The parent price of the current price', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLInputField( |
|
99 | - 'parent', |
|
100 | - 'ID', |
|
101 | - null, |
|
102 | - esc_html__('The parent price ID', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLOutputField( |
|
105 | - 'priceType', |
|
106 | - $this->namespace . 'PriceType', |
|
107 | - 'type_obj', |
|
108 | - esc_html__('The related price type object.', 'event_espresso') |
|
109 | - ), |
|
110 | - new GraphQLOutputField( |
|
111 | - 'priceTypeOrder', |
|
112 | - 'Int', |
|
113 | - 'type_order', |
|
114 | - esc_html__('Order of Application of Price type.', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLInputField( |
|
117 | - 'priceType', |
|
118 | - 'ID', |
|
119 | - null, |
|
120 | - esc_html__('The price type ID', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLField( |
|
123 | - 'isTrashed', |
|
124 | - 'Boolean', |
|
125 | - 'deleted', |
|
126 | - esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLField( |
|
129 | - 'isDefault', |
|
130 | - 'Boolean', |
|
131 | - 'is_default', |
|
132 | - esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLOutputField( |
|
135 | - 'isPercent', |
|
136 | - 'Boolean', |
|
137 | - 'is_percent', |
|
138 | - esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
139 | - ), |
|
140 | - new GraphQLOutputField( |
|
141 | - 'isBasePrice', |
|
142 | - 'Boolean', |
|
143 | - 'is_base_price', |
|
144 | - esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
145 | - ), |
|
146 | - new GraphQLOutputField( |
|
147 | - 'isDiscount', |
|
148 | - 'Boolean', |
|
149 | - 'is_discount', |
|
150 | - esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLOutputField( |
|
153 | - 'isTax', |
|
154 | - 'Boolean', |
|
155 | - 'is_tax', |
|
156 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
157 | - ), |
|
158 | - new GraphQLOutputField( |
|
159 | - 'wpUser', |
|
160 | - 'User', |
|
161 | - null, |
|
162 | - esc_html__('Price Creator', 'event_espresso') |
|
163 | - ), |
|
164 | - new GraphQLInputField( |
|
165 | - 'wpUser', |
|
166 | - 'Int', |
|
167 | - null, |
|
168 | - esc_html__('Price Creator ID', 'event_espresso') |
|
169 | - ), |
|
170 | - ]; |
|
171 | - } |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields() |
|
48 | + { |
|
49 | + return [ |
|
50 | + new GraphQLField( |
|
51 | + 'id', |
|
52 | + ['non_null' => 'ID'], |
|
53 | + null, |
|
54 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLOutputField( |
|
57 | + 'dbId', |
|
58 | + ['non_null' => 'Int'], |
|
59 | + 'ID', |
|
60 | + esc_html__('Price ID', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLField( |
|
63 | + 'name', |
|
64 | + 'String', |
|
65 | + 'name', |
|
66 | + esc_html__('Price Name', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'amount', |
|
70 | + 'Float', |
|
71 | + 'amount', |
|
72 | + esc_html__('Price Amount', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'desc', |
|
76 | + 'String', |
|
77 | + 'desc', |
|
78 | + esc_html__('Price description', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLField( |
|
81 | + 'overrides', |
|
82 | + 'Int', |
|
83 | + 'overrides', |
|
84 | + esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'order', |
|
88 | + 'Int', |
|
89 | + 'order', |
|
90 | + esc_html__('Order of Application of Price.', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLOutputField( |
|
93 | + 'parent', |
|
94 | + $this->name(), |
|
95 | + null, |
|
96 | + esc_html__('The parent price of the current price', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLInputField( |
|
99 | + 'parent', |
|
100 | + 'ID', |
|
101 | + null, |
|
102 | + esc_html__('The parent price ID', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLOutputField( |
|
105 | + 'priceType', |
|
106 | + $this->namespace . 'PriceType', |
|
107 | + 'type_obj', |
|
108 | + esc_html__('The related price type object.', 'event_espresso') |
|
109 | + ), |
|
110 | + new GraphQLOutputField( |
|
111 | + 'priceTypeOrder', |
|
112 | + 'Int', |
|
113 | + 'type_order', |
|
114 | + esc_html__('Order of Application of Price type.', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLInputField( |
|
117 | + 'priceType', |
|
118 | + 'ID', |
|
119 | + null, |
|
120 | + esc_html__('The price type ID', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLField( |
|
123 | + 'isTrashed', |
|
124 | + 'Boolean', |
|
125 | + 'deleted', |
|
126 | + esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLField( |
|
129 | + 'isDefault', |
|
130 | + 'Boolean', |
|
131 | + 'is_default', |
|
132 | + esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLOutputField( |
|
135 | + 'isPercent', |
|
136 | + 'Boolean', |
|
137 | + 'is_percent', |
|
138 | + esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
139 | + ), |
|
140 | + new GraphQLOutputField( |
|
141 | + 'isBasePrice', |
|
142 | + 'Boolean', |
|
143 | + 'is_base_price', |
|
144 | + esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
145 | + ), |
|
146 | + new GraphQLOutputField( |
|
147 | + 'isDiscount', |
|
148 | + 'Boolean', |
|
149 | + 'is_discount', |
|
150 | + esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLOutputField( |
|
153 | + 'isTax', |
|
154 | + 'Boolean', |
|
155 | + 'is_tax', |
|
156 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
157 | + ), |
|
158 | + new GraphQLOutputField( |
|
159 | + 'wpUser', |
|
160 | + 'User', |
|
161 | + null, |
|
162 | + esc_html__('Price Creator', 'event_espresso') |
|
163 | + ), |
|
164 | + new GraphQLInputField( |
|
165 | + 'wpUser', |
|
166 | + 'Int', |
|
167 | + null, |
|
168 | + esc_html__('Price Creator ID', 'event_espresso') |
|
169 | + ), |
|
170 | + ]; |
|
171 | + } |
|
172 | 172 | |
173 | 173 | |
174 | - /** |
|
175 | - * @param array $inputFields The mutation input fields. |
|
176 | - * @throws InvalidArgumentException |
|
177 | - * @throws ReflectionException |
|
178 | - * @since $VID:$ |
|
179 | - */ |
|
180 | - public function registerMutations(array $inputFields) |
|
181 | - { |
|
182 | - // Register mutation to update an entity. |
|
183 | - register_graphql_mutation( |
|
184 | - 'update' . $this->name(), |
|
185 | - [ |
|
186 | - 'inputFields' => $inputFields, |
|
187 | - 'outputFields' => [ |
|
188 | - lcfirst($this->name()) => [ |
|
189 | - 'type' => $this->name(), |
|
190 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
191 | - ], |
|
192 | - ], |
|
193 | - 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
194 | - ] |
|
195 | - ); |
|
196 | - // Register mutation to delete an entity. |
|
197 | - register_graphql_mutation( |
|
198 | - 'delete' . $this->name(), |
|
199 | - [ |
|
200 | - 'inputFields' => [ |
|
201 | - 'id' => $inputFields['id'], |
|
202 | - 'deletePermanently' => [ |
|
203 | - 'type' => 'Boolean', |
|
204 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
205 | - ], |
|
206 | - ], |
|
207 | - 'outputFields' => [ |
|
208 | - lcfirst($this->name()) => [ |
|
209 | - 'type' => $this->name(), |
|
210 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
211 | - 'resolve' => static function ($payload) { |
|
212 | - $deleted = (object) $payload['deleted']; |
|
174 | + /** |
|
175 | + * @param array $inputFields The mutation input fields. |
|
176 | + * @throws InvalidArgumentException |
|
177 | + * @throws ReflectionException |
|
178 | + * @since $VID:$ |
|
179 | + */ |
|
180 | + public function registerMutations(array $inputFields) |
|
181 | + { |
|
182 | + // Register mutation to update an entity. |
|
183 | + register_graphql_mutation( |
|
184 | + 'update' . $this->name(), |
|
185 | + [ |
|
186 | + 'inputFields' => $inputFields, |
|
187 | + 'outputFields' => [ |
|
188 | + lcfirst($this->name()) => [ |
|
189 | + 'type' => $this->name(), |
|
190 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
191 | + ], |
|
192 | + ], |
|
193 | + 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
194 | + ] |
|
195 | + ); |
|
196 | + // Register mutation to delete an entity. |
|
197 | + register_graphql_mutation( |
|
198 | + 'delete' . $this->name(), |
|
199 | + [ |
|
200 | + 'inputFields' => [ |
|
201 | + 'id' => $inputFields['id'], |
|
202 | + 'deletePermanently' => [ |
|
203 | + 'type' => 'Boolean', |
|
204 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
205 | + ], |
|
206 | + ], |
|
207 | + 'outputFields' => [ |
|
208 | + lcfirst($this->name()) => [ |
|
209 | + 'type' => $this->name(), |
|
210 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
211 | + 'resolve' => static function ($payload) { |
|
212 | + $deleted = (object) $payload['deleted']; |
|
213 | 213 | |
214 | - return ! empty($deleted) ? $deleted : null; |
|
215 | - }, |
|
216 | - ], |
|
217 | - ], |
|
218 | - 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
219 | - ] |
|
220 | - ); |
|
214 | + return ! empty($deleted) ? $deleted : null; |
|
215 | + }, |
|
216 | + ], |
|
217 | + ], |
|
218 | + 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
219 | + ] |
|
220 | + ); |
|
221 | 221 | |
222 | - // remove primary key from input. |
|
223 | - unset($inputFields['id']); |
|
224 | - // Register mutation to update an entity. |
|
225 | - register_graphql_mutation( |
|
226 | - 'create' . $this->name(), |
|
227 | - [ |
|
228 | - 'inputFields' => $inputFields, |
|
229 | - 'outputFields' => [ |
|
230 | - lcfirst($this->name()) => [ |
|
231 | - 'type' => $this->name(), |
|
232 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
233 | - ], |
|
234 | - ], |
|
235 | - 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
236 | - ] |
|
237 | - ); |
|
238 | - } |
|
222 | + // remove primary key from input. |
|
223 | + unset($inputFields['id']); |
|
224 | + // Register mutation to update an entity. |
|
225 | + register_graphql_mutation( |
|
226 | + 'create' . $this->name(), |
|
227 | + [ |
|
228 | + 'inputFields' => $inputFields, |
|
229 | + 'outputFields' => [ |
|
230 | + lcfirst($this->name()) => [ |
|
231 | + 'type' => $this->name(), |
|
232 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
233 | + ], |
|
234 | + ], |
|
235 | + 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
236 | + ] |
|
237 | + ); |
|
238 | + } |
|
239 | 239 | } |
@@ -22,100 +22,100 @@ |
||
22 | 22 | class PriceType extends TypeBase |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * PriceType constructor. |
|
27 | - * |
|
28 | - * @param EEM_Price_Type $price_type_model |
|
29 | - */ |
|
30 | - public function __construct(EEM_Price_Type $price_type_model) |
|
31 | - { |
|
32 | - $this->model = $price_type_model; |
|
33 | - $this->setName($this->namespace. 'PriceType'); |
|
34 | - $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | - $this->setIsCustomPostType(false); |
|
36 | - parent::__construct(); |
|
37 | - } |
|
25 | + /** |
|
26 | + * PriceType constructor. |
|
27 | + * |
|
28 | + * @param EEM_Price_Type $price_type_model |
|
29 | + */ |
|
30 | + public function __construct(EEM_Price_Type $price_type_model) |
|
31 | + { |
|
32 | + $this->model = $price_type_model; |
|
33 | + $this->setName($this->namespace. 'PriceType'); |
|
34 | + $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | + $this->setIsCustomPostType(false); |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return GraphQLFieldInterface[] |
|
42 | - * @since $VID:$ |
|
43 | - */ |
|
44 | - public function getFields() |
|
45 | - { |
|
46 | - return [ |
|
47 | - new GraphQLField( |
|
48 | - 'id', |
|
49 | - ['non_null' => 'ID'], |
|
50 | - null, |
|
51 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | - ), |
|
53 | - new GraphQLOutputField( |
|
54 | - 'dbId', |
|
55 | - ['non_null' => 'Int'], |
|
56 | - 'ID', |
|
57 | - esc_html__('Price type ID', 'event_espresso') |
|
58 | - ), |
|
59 | - new GraphQLField( |
|
60 | - 'baseType', |
|
61 | - $this->namespace . 'PriceBaseTypeEnum', |
|
62 | - 'base_type', |
|
63 | - esc_html__('Price Base type', 'event_espresso') |
|
64 | - ), |
|
65 | - new GraphQLField( |
|
66 | - 'isBasePrice', |
|
67 | - 'Boolean', |
|
68 | - 'is_base_price', |
|
69 | - esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLField( |
|
72 | - 'isTrashed', |
|
73 | - 'Boolean', |
|
74 | - 'deleted', |
|
75 | - esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLOutputField( |
|
78 | - 'isDiscount', |
|
79 | - 'Boolean', |
|
80 | - 'is_discount', |
|
81 | - esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
82 | - ), |
|
83 | - new GraphQLField( |
|
84 | - 'isPercent', |
|
85 | - 'Boolean', |
|
86 | - 'is_percent', |
|
87 | - esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
88 | - ), |
|
89 | - new GraphQLOutputField( |
|
90 | - 'isTax', |
|
91 | - 'Boolean', |
|
92 | - 'is_tax', |
|
93 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
94 | - ), |
|
95 | - new GraphQLField( |
|
96 | - 'name', |
|
97 | - 'String', |
|
98 | - 'name', |
|
99 | - esc_html__('Price type Name', 'event_espresso') |
|
100 | - ), |
|
101 | - new GraphQLField( |
|
102 | - 'order', |
|
103 | - 'Int', |
|
104 | - 'order', |
|
105 | - esc_html__('Order in which price should be applied.', 'event_espresso') |
|
106 | - ), |
|
107 | - new GraphQLOutputField( |
|
108 | - 'wpUser', |
|
109 | - 'User', |
|
110 | - null, |
|
111 | - esc_html__('Price Type Creator', 'event_espresso') |
|
112 | - ), |
|
113 | - new GraphQLInputField( |
|
114 | - 'wpUser', |
|
115 | - 'Int', |
|
116 | - null, |
|
117 | - esc_html__('Price Type Creator ID', 'event_espresso') |
|
118 | - ), |
|
119 | - ]; |
|
120 | - } |
|
40 | + /** |
|
41 | + * @return GraphQLFieldInterface[] |
|
42 | + * @since $VID:$ |
|
43 | + */ |
|
44 | + public function getFields() |
|
45 | + { |
|
46 | + return [ |
|
47 | + new GraphQLField( |
|
48 | + 'id', |
|
49 | + ['non_null' => 'ID'], |
|
50 | + null, |
|
51 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | + ), |
|
53 | + new GraphQLOutputField( |
|
54 | + 'dbId', |
|
55 | + ['non_null' => 'Int'], |
|
56 | + 'ID', |
|
57 | + esc_html__('Price type ID', 'event_espresso') |
|
58 | + ), |
|
59 | + new GraphQLField( |
|
60 | + 'baseType', |
|
61 | + $this->namespace . 'PriceBaseTypeEnum', |
|
62 | + 'base_type', |
|
63 | + esc_html__('Price Base type', 'event_espresso') |
|
64 | + ), |
|
65 | + new GraphQLField( |
|
66 | + 'isBasePrice', |
|
67 | + 'Boolean', |
|
68 | + 'is_base_price', |
|
69 | + esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLField( |
|
72 | + 'isTrashed', |
|
73 | + 'Boolean', |
|
74 | + 'deleted', |
|
75 | + esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLOutputField( |
|
78 | + 'isDiscount', |
|
79 | + 'Boolean', |
|
80 | + 'is_discount', |
|
81 | + esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
82 | + ), |
|
83 | + new GraphQLField( |
|
84 | + 'isPercent', |
|
85 | + 'Boolean', |
|
86 | + 'is_percent', |
|
87 | + esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
88 | + ), |
|
89 | + new GraphQLOutputField( |
|
90 | + 'isTax', |
|
91 | + 'Boolean', |
|
92 | + 'is_tax', |
|
93 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
94 | + ), |
|
95 | + new GraphQLField( |
|
96 | + 'name', |
|
97 | + 'String', |
|
98 | + 'name', |
|
99 | + esc_html__('Price type Name', 'event_espresso') |
|
100 | + ), |
|
101 | + new GraphQLField( |
|
102 | + 'order', |
|
103 | + 'Int', |
|
104 | + 'order', |
|
105 | + esc_html__('Order in which price should be applied.', 'event_espresso') |
|
106 | + ), |
|
107 | + new GraphQLOutputField( |
|
108 | + 'wpUser', |
|
109 | + 'User', |
|
110 | + null, |
|
111 | + esc_html__('Price Type Creator', 'event_espresso') |
|
112 | + ), |
|
113 | + new GraphQLInputField( |
|
114 | + 'wpUser', |
|
115 | + 'Int', |
|
116 | + null, |
|
117 | + esc_html__('Price Type Creator ID', 'event_espresso') |
|
118 | + ), |
|
119 | + ]; |
|
120 | + } |
|
121 | 121 | } |
@@ -33,326 +33,326 @@ |
||
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 | - 'isTrashed', |
|
173 | - 'Boolean', |
|
174 | - 'deleted', |
|
175 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
176 | - ), |
|
177 | - new GraphQLField( |
|
178 | - 'order', |
|
179 | - 'Int', |
|
180 | - 'order', |
|
181 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLField( |
|
184 | - 'row', |
|
185 | - 'Int', |
|
186 | - 'row', |
|
187 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
188 | - ), |
|
189 | - new GraphQLOutputField( |
|
190 | - 'wpUser', |
|
191 | - 'User', |
|
192 | - null, |
|
193 | - esc_html__('Ticket Creator', 'event_espresso') |
|
194 | - ), |
|
195 | - new GraphQLInputField( |
|
196 | - 'wpUser', |
|
197 | - 'Int', |
|
198 | - null, |
|
199 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
200 | - ), |
|
201 | - new GraphQLOutputField( |
|
202 | - 'parent', |
|
203 | - $this->name(), |
|
204 | - null, |
|
205 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLInputField( |
|
208 | - 'parent', |
|
209 | - 'ID', |
|
210 | - null, |
|
211 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
212 | - ), |
|
213 | - new GraphQLField( |
|
214 | - 'reverseCalculate', |
|
215 | - 'Boolean', |
|
216 | - 'reverse_calculate', |
|
217 | - esc_html__( |
|
218 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
219 | - 'event_espresso' |
|
220 | - ) |
|
221 | - ), |
|
222 | - new GraphQLField( |
|
223 | - 'isFree', |
|
224 | - 'Boolean', |
|
225 | - 'is_free', |
|
226 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
227 | - ), |
|
228 | - new GraphQLOutputField( |
|
229 | - 'event', |
|
230 | - $this->namespace . 'Event', |
|
231 | - null, |
|
232 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
233 | - ), |
|
234 | - new GraphQLInputField( |
|
235 | - 'datetimes', |
|
236 | - ['list_of' => 'ID'], |
|
237 | - null, |
|
238 | - sprintf( |
|
239 | - '%1$s %2$s', |
|
240 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
241 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
242 | - ) |
|
243 | - ), |
|
244 | - new GraphQLInputField( |
|
245 | - 'prices', |
|
246 | - ['list_of' => 'ID'], |
|
247 | - null, |
|
248 | - sprintf( |
|
249 | - '%1$s %2$s', |
|
250 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
251 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
252 | - ) |
|
253 | - ), |
|
254 | - new GraphQLOutputField( |
|
255 | - 'status', |
|
256 | - $this->namespace . 'TicketStatusEnum', |
|
257 | - 'ticket_status', |
|
258 | - esc_html__('Ticket status', 'event_espresso') |
|
259 | - ), |
|
260 | - new GraphQLOutputField( |
|
261 | - 'isSoldOut', |
|
262 | - 'Boolean', |
|
263 | - null, |
|
264 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
265 | - null, |
|
266 | - [$this, 'getIsSoldOut'] |
|
267 | - ), |
|
268 | - ]; |
|
269 | - } |
|
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 | + 'isTrashed', |
|
173 | + 'Boolean', |
|
174 | + 'deleted', |
|
175 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
176 | + ), |
|
177 | + new GraphQLField( |
|
178 | + 'order', |
|
179 | + 'Int', |
|
180 | + 'order', |
|
181 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLField( |
|
184 | + 'row', |
|
185 | + 'Int', |
|
186 | + 'row', |
|
187 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
188 | + ), |
|
189 | + new GraphQLOutputField( |
|
190 | + 'wpUser', |
|
191 | + 'User', |
|
192 | + null, |
|
193 | + esc_html__('Ticket Creator', 'event_espresso') |
|
194 | + ), |
|
195 | + new GraphQLInputField( |
|
196 | + 'wpUser', |
|
197 | + 'Int', |
|
198 | + null, |
|
199 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
200 | + ), |
|
201 | + new GraphQLOutputField( |
|
202 | + 'parent', |
|
203 | + $this->name(), |
|
204 | + null, |
|
205 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLInputField( |
|
208 | + 'parent', |
|
209 | + 'ID', |
|
210 | + null, |
|
211 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
212 | + ), |
|
213 | + new GraphQLField( |
|
214 | + 'reverseCalculate', |
|
215 | + 'Boolean', |
|
216 | + 'reverse_calculate', |
|
217 | + esc_html__( |
|
218 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
219 | + 'event_espresso' |
|
220 | + ) |
|
221 | + ), |
|
222 | + new GraphQLField( |
|
223 | + 'isFree', |
|
224 | + 'Boolean', |
|
225 | + 'is_free', |
|
226 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
227 | + ), |
|
228 | + new GraphQLOutputField( |
|
229 | + 'event', |
|
230 | + $this->namespace . 'Event', |
|
231 | + null, |
|
232 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
233 | + ), |
|
234 | + new GraphQLInputField( |
|
235 | + 'datetimes', |
|
236 | + ['list_of' => 'ID'], |
|
237 | + null, |
|
238 | + sprintf( |
|
239 | + '%1$s %2$s', |
|
240 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
241 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
242 | + ) |
|
243 | + ), |
|
244 | + new GraphQLInputField( |
|
245 | + 'prices', |
|
246 | + ['list_of' => 'ID'], |
|
247 | + null, |
|
248 | + sprintf( |
|
249 | + '%1$s %2$s', |
|
250 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
251 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
252 | + ) |
|
253 | + ), |
|
254 | + new GraphQLOutputField( |
|
255 | + 'status', |
|
256 | + $this->namespace . 'TicketStatusEnum', |
|
257 | + 'ticket_status', |
|
258 | + esc_html__('Ticket status', 'event_espresso') |
|
259 | + ), |
|
260 | + new GraphQLOutputField( |
|
261 | + 'isSoldOut', |
|
262 | + 'Boolean', |
|
263 | + null, |
|
264 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
265 | + null, |
|
266 | + [$this, 'getIsSoldOut'] |
|
267 | + ), |
|
268 | + ]; |
|
269 | + } |
|
270 | 270 | |
271 | 271 | |
272 | - /** |
|
273 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
274 | - * @param array $args The inputArgs on the field |
|
275 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
276 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
277 | - * @return string |
|
278 | - * @throws Exception |
|
279 | - * @throws InvalidArgumentException |
|
280 | - * @throws InvalidDataTypeException |
|
281 | - * @throws InvalidInterfaceException |
|
282 | - * @throws ReflectionException |
|
283 | - * @throws UserError |
|
284 | - * @throws UnexpectedEntityException |
|
285 | - * @since $VID:$ |
|
286 | - */ |
|
287 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
288 | - { |
|
289 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
290 | - } |
|
272 | + /** |
|
273 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
274 | + * @param array $args The inputArgs on the field |
|
275 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
276 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
277 | + * @return string |
|
278 | + * @throws Exception |
|
279 | + * @throws InvalidArgumentException |
|
280 | + * @throws InvalidDataTypeException |
|
281 | + * @throws InvalidInterfaceException |
|
282 | + * @throws ReflectionException |
|
283 | + * @throws UserError |
|
284 | + * @throws UnexpectedEntityException |
|
285 | + * @since $VID:$ |
|
286 | + */ |
|
287 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
288 | + { |
|
289 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
290 | + } |
|
291 | 291 | |
292 | 292 | |
293 | - /** |
|
294 | - * @param array $inputFields The mutation input fields. |
|
295 | - * @throws InvalidArgumentException |
|
296 | - * @throws ReflectionException |
|
297 | - * @since $VID:$ |
|
298 | - */ |
|
299 | - public function registerMutations(array $inputFields) |
|
300 | - { |
|
301 | - // Register mutation to update an entity. |
|
302 | - register_graphql_mutation( |
|
303 | - 'update' . $this->name(), |
|
304 | - [ |
|
305 | - 'inputFields' => $inputFields, |
|
306 | - 'outputFields' => [ |
|
307 | - lcfirst($this->name()) => [ |
|
308 | - 'type' => $this->name(), |
|
309 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
310 | - ], |
|
311 | - ], |
|
312 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
313 | - ] |
|
314 | - ); |
|
315 | - // Register mutation to delete an entity. |
|
316 | - register_graphql_mutation( |
|
317 | - 'delete' . $this->name(), |
|
318 | - [ |
|
319 | - 'inputFields' => [ |
|
320 | - 'id' => $inputFields['id'], |
|
321 | - 'deletePermanently' => [ |
|
322 | - 'type' => 'Boolean', |
|
323 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
324 | - ], |
|
325 | - ], |
|
326 | - 'outputFields' => [ |
|
327 | - lcfirst($this->name()) => [ |
|
328 | - 'type' => $this->name(), |
|
329 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
330 | - 'resolve' => static function ($payload) { |
|
331 | - $deleted = (object) $payload['deleted']; |
|
293 | + /** |
|
294 | + * @param array $inputFields The mutation input fields. |
|
295 | + * @throws InvalidArgumentException |
|
296 | + * @throws ReflectionException |
|
297 | + * @since $VID:$ |
|
298 | + */ |
|
299 | + public function registerMutations(array $inputFields) |
|
300 | + { |
|
301 | + // Register mutation to update an entity. |
|
302 | + register_graphql_mutation( |
|
303 | + 'update' . $this->name(), |
|
304 | + [ |
|
305 | + 'inputFields' => $inputFields, |
|
306 | + 'outputFields' => [ |
|
307 | + lcfirst($this->name()) => [ |
|
308 | + 'type' => $this->name(), |
|
309 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
310 | + ], |
|
311 | + ], |
|
312 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
313 | + ] |
|
314 | + ); |
|
315 | + // Register mutation to delete an entity. |
|
316 | + register_graphql_mutation( |
|
317 | + 'delete' . $this->name(), |
|
318 | + [ |
|
319 | + 'inputFields' => [ |
|
320 | + 'id' => $inputFields['id'], |
|
321 | + 'deletePermanently' => [ |
|
322 | + 'type' => 'Boolean', |
|
323 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
324 | + ], |
|
325 | + ], |
|
326 | + 'outputFields' => [ |
|
327 | + lcfirst($this->name()) => [ |
|
328 | + 'type' => $this->name(), |
|
329 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
330 | + 'resolve' => static function ($payload) { |
|
331 | + $deleted = (object) $payload['deleted']; |
|
332 | 332 | |
333 | - return ! empty($deleted) ? $deleted : null; |
|
334 | - }, |
|
335 | - ], |
|
336 | - ], |
|
337 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
338 | - ] |
|
339 | - ); |
|
333 | + return ! empty($deleted) ? $deleted : null; |
|
334 | + }, |
|
335 | + ], |
|
336 | + ], |
|
337 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
338 | + ] |
|
339 | + ); |
|
340 | 340 | |
341 | - // remove primary key from input. |
|
342 | - unset($inputFields['id']); |
|
343 | - // Register mutation to update an entity. |
|
344 | - register_graphql_mutation( |
|
345 | - 'create' . $this->name(), |
|
346 | - [ |
|
347 | - 'inputFields' => $inputFields, |
|
348 | - 'outputFields' => [ |
|
349 | - lcfirst($this->name()) => [ |
|
350 | - 'type' => $this->name(), |
|
351 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
352 | - ], |
|
353 | - ], |
|
354 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
355 | - ] |
|
356 | - ); |
|
357 | - } |
|
341 | + // remove primary key from input. |
|
342 | + unset($inputFields['id']); |
|
343 | + // Register mutation to update an entity. |
|
344 | + register_graphql_mutation( |
|
345 | + 'create' . $this->name(), |
|
346 | + [ |
|
347 | + 'inputFields' => $inputFields, |
|
348 | + 'outputFields' => [ |
|
349 | + lcfirst($this->name()) => [ |
|
350 | + 'type' => $this->name(), |
|
351 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
352 | + ], |
|
353 | + ], |
|
354 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
355 | + ] |
|
356 | + ); |
|
357 | + } |
|
358 | 358 | } |