@@ -35,225 +35,225 @@ discard block |
||
35 | 35 | class AdvancedEditorData |
36 | 36 | { |
37 | 37 | |
38 | - /** |
|
39 | - * @var string $namespace The graphql namespace/prefix. |
|
40 | - */ |
|
41 | - protected $namespace = 'Espresso'; |
|
42 | - |
|
43 | - /** |
|
44 | - * @var EE_Event |
|
45 | - */ |
|
46 | - protected $event; |
|
47 | - |
|
48 | - /** |
|
49 | - * @var EE_Admin_Config |
|
50 | - */ |
|
51 | - protected $admin_config; |
|
52 | - /** |
|
53 | - * @var EEM_Datetime $datetime_model |
|
54 | - */ |
|
55 | - protected $datetime_model; |
|
56 | - /** |
|
57 | - * @var EEM_Price $price_model |
|
58 | - */ |
|
59 | - protected $price_model; |
|
60 | - /** |
|
61 | - * @var EEM_Ticket $ticket_model |
|
62 | - */ |
|
63 | - protected $ticket_model; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * AdvancedEditorAdminForm constructor. |
|
68 | - * |
|
69 | - * @param EE_Event $event |
|
70 | - * @param EE_Admin_Config $admin_config |
|
71 | - * @param EEM_Datetime $datetime_model |
|
72 | - * @param EEM_Price $price_model |
|
73 | - * @param EEM_Ticket $ticket_model |
|
74 | - */ |
|
75 | - public function __construct( |
|
76 | - EE_Event $event, |
|
77 | - EE_Admin_Config $admin_config, |
|
78 | - EEM_Datetime $datetime_model, |
|
79 | - EEM_Price $price_model, |
|
80 | - EEM_Ticket $ticket_model |
|
81 | - ) { |
|
82 | - $this->event = $event; |
|
83 | - $this->admin_config = $admin_config; |
|
84 | - $this->datetime_model = $datetime_model; |
|
85 | - $this->price_model = $price_model; |
|
86 | - $this->ticket_model = $ticket_model; |
|
87 | - add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * @throws EE_Error |
|
93 | - * @throws InvalidArgumentException |
|
94 | - * @throws InvalidDataTypeException |
|
95 | - * @throws InvalidInterfaceException |
|
96 | - * @throws ModelConfigurationException |
|
97 | - * @throws ReflectionException |
|
98 | - * @throws UnexpectedEntityException |
|
99 | - * @throws DomainException |
|
100 | - * @since $VID:$ |
|
101 | - */ |
|
102 | - public function loadScriptsStyles() |
|
103 | - { |
|
104 | - if ($this->admin_config->useAdvancedEditor()) { |
|
105 | - $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
106 | - if (! $eventId) { |
|
107 | - global $post; |
|
108 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
109 | - $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
110 | - ? $post->ID |
|
111 | - : $eventId; |
|
112 | - } |
|
113 | - if ($eventId) { |
|
114 | - $data = $this->getEditorData($eventId); |
|
115 | - $data = wp_json_encode($data); |
|
116 | - add_action( |
|
117 | - 'admin_footer', |
|
118 | - static function () use ($data) { |
|
119 | - wp_add_inline_script( |
|
120 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
121 | - " |
|
38 | + /** |
|
39 | + * @var string $namespace The graphql namespace/prefix. |
|
40 | + */ |
|
41 | + protected $namespace = 'Espresso'; |
|
42 | + |
|
43 | + /** |
|
44 | + * @var EE_Event |
|
45 | + */ |
|
46 | + protected $event; |
|
47 | + |
|
48 | + /** |
|
49 | + * @var EE_Admin_Config |
|
50 | + */ |
|
51 | + protected $admin_config; |
|
52 | + /** |
|
53 | + * @var EEM_Datetime $datetime_model |
|
54 | + */ |
|
55 | + protected $datetime_model; |
|
56 | + /** |
|
57 | + * @var EEM_Price $price_model |
|
58 | + */ |
|
59 | + protected $price_model; |
|
60 | + /** |
|
61 | + * @var EEM_Ticket $ticket_model |
|
62 | + */ |
|
63 | + protected $ticket_model; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * AdvancedEditorAdminForm constructor. |
|
68 | + * |
|
69 | + * @param EE_Event $event |
|
70 | + * @param EE_Admin_Config $admin_config |
|
71 | + * @param EEM_Datetime $datetime_model |
|
72 | + * @param EEM_Price $price_model |
|
73 | + * @param EEM_Ticket $ticket_model |
|
74 | + */ |
|
75 | + public function __construct( |
|
76 | + EE_Event $event, |
|
77 | + EE_Admin_Config $admin_config, |
|
78 | + EEM_Datetime $datetime_model, |
|
79 | + EEM_Price $price_model, |
|
80 | + EEM_Ticket $ticket_model |
|
81 | + ) { |
|
82 | + $this->event = $event; |
|
83 | + $this->admin_config = $admin_config; |
|
84 | + $this->datetime_model = $datetime_model; |
|
85 | + $this->price_model = $price_model; |
|
86 | + $this->ticket_model = $ticket_model; |
|
87 | + add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * @throws EE_Error |
|
93 | + * @throws InvalidArgumentException |
|
94 | + * @throws InvalidDataTypeException |
|
95 | + * @throws InvalidInterfaceException |
|
96 | + * @throws ModelConfigurationException |
|
97 | + * @throws ReflectionException |
|
98 | + * @throws UnexpectedEntityException |
|
99 | + * @throws DomainException |
|
100 | + * @since $VID:$ |
|
101 | + */ |
|
102 | + public function loadScriptsStyles() |
|
103 | + { |
|
104 | + if ($this->admin_config->useAdvancedEditor()) { |
|
105 | + $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
106 | + if (! $eventId) { |
|
107 | + global $post; |
|
108 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
109 | + $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
|
110 | + ? $post->ID |
|
111 | + : $eventId; |
|
112 | + } |
|
113 | + if ($eventId) { |
|
114 | + $data = $this->getEditorData($eventId); |
|
115 | + $data = wp_json_encode($data); |
|
116 | + add_action( |
|
117 | + 'admin_footer', |
|
118 | + static function () use ($data) { |
|
119 | + wp_add_inline_script( |
|
120 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
121 | + " |
|
122 | 122 | var eeEditorData={$data}; |
123 | 123 | ", |
124 | - 'before' |
|
125 | - ); |
|
126 | - } |
|
127 | - ); |
|
128 | - add_action( |
|
129 | - 'admin_footer', |
|
130 | - static function () use ($data) { |
|
131 | - wp_add_inline_script( |
|
132 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
133 | - " |
|
124 | + 'before' |
|
125 | + ); |
|
126 | + } |
|
127 | + ); |
|
128 | + add_action( |
|
129 | + 'admin_footer', |
|
130 | + static function () use ($data) { |
|
131 | + wp_add_inline_script( |
|
132 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
|
133 | + " |
|
134 | 134 | var eeEditorData={$data}; |
135 | 135 | ", |
136 | - 'before' |
|
137 | - ); |
|
138 | - } |
|
139 | - ); |
|
140 | - } |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - |
|
145 | - /** |
|
146 | - * @param int $eventId |
|
147 | - * @return array |
|
148 | - * @throws EE_Error |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidInterfaceException |
|
151 | - * @throws ModelConfigurationException |
|
152 | - * @throws UnexpectedEntityException |
|
153 | - * @throws InvalidArgumentException |
|
154 | - * @throws ReflectionException |
|
155 | - * @throws DomainException |
|
156 | - * @since $VID:$ |
|
157 | - */ |
|
158 | - protected function getEditorData($eventId) |
|
159 | - { |
|
160 | - $event = $this->getEventGraphQLData($eventId); |
|
161 | - $event['dbId'] = $eventId; |
|
162 | - |
|
163 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
164 | - $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
165 | - |
|
166 | - $currentUser = $this->getGraphQLCurrentUser(); |
|
167 | - |
|
168 | - $generalSettings = $this->getGraphQLGeneralSettings(); |
|
169 | - |
|
170 | - $i18n = self::getJedLocaleData('event_espresso'); |
|
171 | - |
|
172 | - $assets_url = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
173 | - |
|
174 | - return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assets_url'); |
|
175 | - } |
|
176 | - |
|
177 | - |
|
178 | - /** |
|
179 | - * @param int $eventId |
|
180 | - * @return array |
|
181 | - * @since $VID:$ |
|
182 | - */ |
|
183 | - protected function getEventGraphQLData($eventId) |
|
184 | - { |
|
185 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
186 | - |
|
187 | - if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
188 | - $this->addDefaultEntities($eventId); |
|
189 | - $datetimes = $this->getGraphQLDatetimes($eventId); |
|
190 | - } |
|
191 | - |
|
192 | - if (! empty($datetimes['nodes'])) { |
|
193 | - $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
194 | - |
|
195 | - if (! empty($datetimeIn)) { |
|
196 | - $tickets = $this->getGraphQLTickets($datetimeIn); |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - if (! empty($tickets['nodes'])) { |
|
201 | - $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
202 | - |
|
203 | - if (! empty($ticketIn)) { |
|
204 | - $prices = $this->getGraphQLPrices($ticketIn); |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - $priceTypes = $this->getGraphQLPriceTypes(); |
|
209 | - |
|
210 | - $relations = $this->getRelationalData($eventId); |
|
211 | - |
|
212 | - return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * @param int $eventId |
|
217 | - * @throws DomainException |
|
218 | - * @throws EE_Error |
|
219 | - * @throws InvalidArgumentException |
|
220 | - * @throws InvalidDataTypeException |
|
221 | - * @throws InvalidInterfaceException |
|
222 | - * @throws ModelConfigurationException |
|
223 | - * @throws ReflectionException |
|
224 | - * @throws UnexpectedEntityException |
|
225 | - * @since $VID:$ |
|
226 | - */ |
|
227 | - protected function addDefaultEntities($eventId) |
|
228 | - { |
|
229 | - $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
230 | - if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
231 | - $default_date = $default_dates[0]; |
|
232 | - $default_date->save(); |
|
233 | - $default_date->_add_relation_to($eventId, 'Event'); |
|
234 | - $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
235 | - $default_prices = $this->price_model->get_all_default_prices(); |
|
236 | - foreach ($default_tickets as $default_ticket) { |
|
237 | - $default_ticket->save(); |
|
238 | - $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
239 | - foreach ($default_prices as $default_price) { |
|
240 | - $default_price->save(); |
|
241 | - $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * @param int $eventId |
|
250 | - * @return array|null |
|
251 | - * @since $VID:$ |
|
252 | - */ |
|
253 | - protected function getGraphQLDatetimes($eventId) |
|
254 | - { |
|
255 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
256 | - $query = <<<QUERY |
|
136 | + 'before' |
|
137 | + ); |
|
138 | + } |
|
139 | + ); |
|
140 | + } |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + |
|
145 | + /** |
|
146 | + * @param int $eventId |
|
147 | + * @return array |
|
148 | + * @throws EE_Error |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidInterfaceException |
|
151 | + * @throws ModelConfigurationException |
|
152 | + * @throws UnexpectedEntityException |
|
153 | + * @throws InvalidArgumentException |
|
154 | + * @throws ReflectionException |
|
155 | + * @throws DomainException |
|
156 | + * @since $VID:$ |
|
157 | + */ |
|
158 | + protected function getEditorData($eventId) |
|
159 | + { |
|
160 | + $event = $this->getEventGraphQLData($eventId); |
|
161 | + $event['dbId'] = $eventId; |
|
162 | + |
|
163 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
164 | + $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
165 | + |
|
166 | + $currentUser = $this->getGraphQLCurrentUser(); |
|
167 | + |
|
168 | + $generalSettings = $this->getGraphQLGeneralSettings(); |
|
169 | + |
|
170 | + $i18n = self::getJedLocaleData('event_espresso'); |
|
171 | + |
|
172 | + $assets_url = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
173 | + |
|
174 | + return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assets_url'); |
|
175 | + } |
|
176 | + |
|
177 | + |
|
178 | + /** |
|
179 | + * @param int $eventId |
|
180 | + * @return array |
|
181 | + * @since $VID:$ |
|
182 | + */ |
|
183 | + protected function getEventGraphQLData($eventId) |
|
184 | + { |
|
185 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
186 | + |
|
187 | + if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
188 | + $this->addDefaultEntities($eventId); |
|
189 | + $datetimes = $this->getGraphQLDatetimes($eventId); |
|
190 | + } |
|
191 | + |
|
192 | + if (! empty($datetimes['nodes'])) { |
|
193 | + $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
194 | + |
|
195 | + if (! empty($datetimeIn)) { |
|
196 | + $tickets = $this->getGraphQLTickets($datetimeIn); |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + if (! empty($tickets['nodes'])) { |
|
201 | + $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
|
202 | + |
|
203 | + if (! empty($ticketIn)) { |
|
204 | + $prices = $this->getGraphQLPrices($ticketIn); |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + $priceTypes = $this->getGraphQLPriceTypes(); |
|
209 | + |
|
210 | + $relations = $this->getRelationalData($eventId); |
|
211 | + |
|
212 | + return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * @param int $eventId |
|
217 | + * @throws DomainException |
|
218 | + * @throws EE_Error |
|
219 | + * @throws InvalidArgumentException |
|
220 | + * @throws InvalidDataTypeException |
|
221 | + * @throws InvalidInterfaceException |
|
222 | + * @throws ModelConfigurationException |
|
223 | + * @throws ReflectionException |
|
224 | + * @throws UnexpectedEntityException |
|
225 | + * @since $VID:$ |
|
226 | + */ |
|
227 | + protected function addDefaultEntities($eventId) |
|
228 | + { |
|
229 | + $default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
230 | + if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
231 | + $default_date = $default_dates[0]; |
|
232 | + $default_date->save(); |
|
233 | + $default_date->_add_relation_to($eventId, 'Event'); |
|
234 | + $default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
235 | + $default_prices = $this->price_model->get_all_default_prices(); |
|
236 | + foreach ($default_tickets as $default_ticket) { |
|
237 | + $default_ticket->save(); |
|
238 | + $default_ticket->_add_relation_to($default_date, 'Datetime'); |
|
239 | + foreach ($default_prices as $default_price) { |
|
240 | + $default_price->save(); |
|
241 | + $default_price->_add_relation_to($default_ticket, 'Ticket'); |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * @param int $eventId |
|
250 | + * @return array|null |
|
251 | + * @since $VID:$ |
|
252 | + */ |
|
253 | + protected function getGraphQLDatetimes($eventId) |
|
254 | + { |
|
255 | + $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
256 | + $query = <<<QUERY |
|
257 | 257 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
258 | 258 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
259 | 259 | nodes { |
@@ -281,31 +281,31 @@ discard block |
||
281 | 281 | } |
282 | 282 | } |
283 | 283 | QUERY; |
284 | - $data = [ |
|
285 | - 'operation_name' => 'GET_DATETIMES', |
|
286 | - 'variables' => [ |
|
287 | - 'first' => 100, |
|
288 | - 'where' => [ |
|
289 | - 'eventId' => $eventId, |
|
290 | - ], |
|
291 | - ], |
|
292 | - 'query' => $query, |
|
293 | - ]; |
|
294 | - |
|
295 | - $responseData = $this->makeGraphQLRequest($data); |
|
296 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * @param array $datetimeIn |
|
302 | - * @return array|null |
|
303 | - * @since $VID:$ |
|
304 | - */ |
|
305 | - protected function getGraphQLTickets(array $datetimeIn) |
|
306 | - { |
|
307 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
308 | - $query = <<<QUERY |
|
284 | + $data = [ |
|
285 | + 'operation_name' => 'GET_DATETIMES', |
|
286 | + 'variables' => [ |
|
287 | + 'first' => 100, |
|
288 | + 'where' => [ |
|
289 | + 'eventId' => $eventId, |
|
290 | + ], |
|
291 | + ], |
|
292 | + 'query' => $query, |
|
293 | + ]; |
|
294 | + |
|
295 | + $responseData = $this->makeGraphQLRequest($data); |
|
296 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * @param array $datetimeIn |
|
302 | + * @return array|null |
|
303 | + * @since $VID:$ |
|
304 | + */ |
|
305 | + protected function getGraphQLTickets(array $datetimeIn) |
|
306 | + { |
|
307 | + $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
308 | + $query = <<<QUERY |
|
309 | 309 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) { |
310 | 310 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
311 | 311 | nodes { |
@@ -339,31 +339,31 @@ discard block |
||
339 | 339 | } |
340 | 340 | } |
341 | 341 | QUERY; |
342 | - $data = [ |
|
343 | - 'operation_name' => 'GET_TICKETS', |
|
344 | - 'variables' => [ |
|
345 | - 'first' => 100, |
|
346 | - 'where' => [ |
|
347 | - 'datetimeIn' => $datetimeIn, |
|
348 | - ], |
|
349 | - ], |
|
350 | - 'query' => $query, |
|
351 | - ]; |
|
352 | - |
|
353 | - $responseData = $this->makeGraphQLRequest($data); |
|
354 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - /** |
|
359 | - * @param array $ticketIn |
|
360 | - * @return array|null |
|
361 | - * @since $VID:$ |
|
362 | - */ |
|
363 | - protected function getGraphQLPrices(array $ticketIn) |
|
364 | - { |
|
365 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
366 | - $query = <<<QUERY |
|
342 | + $data = [ |
|
343 | + 'operation_name' => 'GET_TICKETS', |
|
344 | + 'variables' => [ |
|
345 | + 'first' => 100, |
|
346 | + 'where' => [ |
|
347 | + 'datetimeIn' => $datetimeIn, |
|
348 | + ], |
|
349 | + ], |
|
350 | + 'query' => $query, |
|
351 | + ]; |
|
352 | + |
|
353 | + $responseData = $this->makeGraphQLRequest($data); |
|
354 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + /** |
|
359 | + * @param array $ticketIn |
|
360 | + * @return array|null |
|
361 | + * @since $VID:$ |
|
362 | + */ |
|
363 | + protected function getGraphQLPrices(array $ticketIn) |
|
364 | + { |
|
365 | + $field_key = lcfirst($this->namespace) . 'Prices'; |
|
366 | + $query = <<<QUERY |
|
367 | 367 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
368 | 368 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
369 | 369 | nodes { |
@@ -386,30 +386,30 @@ discard block |
||
386 | 386 | } |
387 | 387 | } |
388 | 388 | QUERY; |
389 | - $data = [ |
|
390 | - 'operation_name' => 'GET_PRICES', |
|
391 | - 'variables' => [ |
|
392 | - 'first' => 100, |
|
393 | - 'where' => [ |
|
394 | - 'ticketIn' => $ticketIn, |
|
395 | - ], |
|
396 | - ], |
|
397 | - 'query' => $query, |
|
398 | - ]; |
|
399 | - |
|
400 | - $responseData = $this->makeGraphQLRequest($data); |
|
401 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
402 | - } |
|
403 | - |
|
404 | - |
|
405 | - /** |
|
406 | - * @return array|null |
|
407 | - * @since $VID:$ |
|
408 | - */ |
|
409 | - protected function getGraphQLPriceTypes() |
|
410 | - { |
|
411 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
412 | - $query = <<<QUERY |
|
389 | + $data = [ |
|
390 | + 'operation_name' => 'GET_PRICES', |
|
391 | + 'variables' => [ |
|
392 | + 'first' => 100, |
|
393 | + 'where' => [ |
|
394 | + 'ticketIn' => $ticketIn, |
|
395 | + ], |
|
396 | + ], |
|
397 | + 'query' => $query, |
|
398 | + ]; |
|
399 | + |
|
400 | + $responseData = $this->makeGraphQLRequest($data); |
|
401 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
402 | + } |
|
403 | + |
|
404 | + |
|
405 | + /** |
|
406 | + * @return array|null |
|
407 | + * @since $VID:$ |
|
408 | + */ |
|
409 | + protected function getGraphQLPriceTypes() |
|
410 | + { |
|
411 | + $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
412 | + $query = <<<QUERY |
|
413 | 413 | query GET_PRICE_TYPES(\$first: Int, \$last: Int ) { |
414 | 414 | {$field_key}(first: \$first, last: \$last) { |
415 | 415 | nodes { |
@@ -429,27 +429,27 @@ discard block |
||
429 | 429 | } |
430 | 430 | } |
431 | 431 | QUERY; |
432 | - $data = [ |
|
433 | - 'operation_name' => 'GET_PRICE_TYPES', |
|
434 | - 'variables' => [ |
|
435 | - 'first' => 100, |
|
436 | - ], |
|
437 | - 'query' => $query, |
|
438 | - ]; |
|
439 | - |
|
440 | - $responseData = $this->makeGraphQLRequest($data); |
|
441 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
442 | - } |
|
443 | - |
|
444 | - |
|
445 | - /** |
|
446 | - * @return array|null |
|
447 | - * @since $VID:$ |
|
448 | - */ |
|
449 | - protected function getGraphQLCurrentUser() |
|
450 | - { |
|
451 | - $field_key = 'viewer'; |
|
452 | - $query = <<<QUERY |
|
432 | + $data = [ |
|
433 | + 'operation_name' => 'GET_PRICE_TYPES', |
|
434 | + 'variables' => [ |
|
435 | + 'first' => 100, |
|
436 | + ], |
|
437 | + 'query' => $query, |
|
438 | + ]; |
|
439 | + |
|
440 | + $responseData = $this->makeGraphQLRequest($data); |
|
441 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
442 | + } |
|
443 | + |
|
444 | + |
|
445 | + /** |
|
446 | + * @return array|null |
|
447 | + * @since $VID:$ |
|
448 | + */ |
|
449 | + protected function getGraphQLCurrentUser() |
|
450 | + { |
|
451 | + $field_key = 'viewer'; |
|
452 | + $query = <<<QUERY |
|
453 | 453 | query GET_CURRENT_USER { |
454 | 454 | {$field_key} { |
455 | 455 | description |
@@ -467,24 +467,24 @@ discard block |
||
467 | 467 | } |
468 | 468 | } |
469 | 469 | QUERY; |
470 | - $data = [ |
|
471 | - 'operation_name' => 'GET_CURRENT_USER', |
|
472 | - 'query' => $query, |
|
473 | - ]; |
|
474 | - |
|
475 | - $responseData = $this->makeGraphQLRequest($data); |
|
476 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
477 | - } |
|
478 | - |
|
479 | - |
|
480 | - /** |
|
481 | - * @return array|null |
|
482 | - * @since $VID:$ |
|
483 | - */ |
|
484 | - protected function getGraphQLGeneralSettings() |
|
485 | - { |
|
486 | - $field_key = 'generalSettings'; |
|
487 | - $query = <<<QUERY |
|
470 | + $data = [ |
|
471 | + 'operation_name' => 'GET_CURRENT_USER', |
|
472 | + 'query' => $query, |
|
473 | + ]; |
|
474 | + |
|
475 | + $responseData = $this->makeGraphQLRequest($data); |
|
476 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
477 | + } |
|
478 | + |
|
479 | + |
|
480 | + /** |
|
481 | + * @return array|null |
|
482 | + * @since $VID:$ |
|
483 | + */ |
|
484 | + protected function getGraphQLGeneralSettings() |
|
485 | + { |
|
486 | + $field_key = 'generalSettings'; |
|
487 | + $query = <<<QUERY |
|
488 | 488 | query GET_GENERAL_SETTINGS { |
489 | 489 | {$field_key} { |
490 | 490 | dateFormat |
@@ -494,166 +494,166 @@ discard block |
||
494 | 494 | } |
495 | 495 | } |
496 | 496 | QUERY; |
497 | - $data = [ |
|
498 | - 'operation_name' => 'GET_CURRENT_USER', |
|
499 | - 'query' => $query, |
|
500 | - ]; |
|
501 | - |
|
502 | - $responseData = $this->makeGraphQLRequest($data); |
|
503 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
504 | - } |
|
505 | - |
|
506 | - |
|
507 | - /** |
|
508 | - * @param array $data |
|
509 | - * @return array |
|
510 | - * @since $VID:$ |
|
511 | - */ |
|
512 | - protected function makeGraphQLRequest($data) |
|
513 | - { |
|
514 | - try { |
|
515 | - $response = graphql($data); |
|
516 | - if (!empty($response['data'])) { |
|
517 | - return $response['data']; |
|
518 | - } |
|
519 | - return null; |
|
520 | - } catch (\Exception $e) { |
|
521 | - // do something with the errors thrown |
|
522 | - return null; |
|
523 | - } |
|
524 | - } |
|
525 | - |
|
526 | - |
|
527 | - /** |
|
528 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
529 | - * @param array $args The inputArgs on the field |
|
530 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
531 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
532 | - * @return string |
|
533 | - * @throws EE_Error |
|
534 | - * @throws Exception |
|
535 | - * @throws InvalidArgumentException |
|
536 | - * @throws InvalidDataTypeException |
|
537 | - * @throws InvalidInterfaceException |
|
538 | - * @throws ReflectionException |
|
539 | - * @throws UserError |
|
540 | - * @throws UnexpectedEntityException |
|
541 | - * @since $VID:$ |
|
542 | - */ |
|
543 | - public static function getRelationalData($eventId) |
|
544 | - { |
|
545 | - $data = [ |
|
546 | - 'datetimes' => [], |
|
547 | - 'tickets' => [], |
|
548 | - 'prices' => [], |
|
549 | - ]; |
|
550 | - |
|
551 | - $eem_datetime = EEM_Datetime::instance(); |
|
552 | - $eem_ticket = EEM_Ticket::instance(); |
|
553 | - $eem_price = EEM_Price::instance(); |
|
554 | - $eem_price_type = EEM_Price_Type::instance(); |
|
555 | - |
|
556 | - // PROCESS DATETIMES |
|
557 | - $related_models = [ |
|
558 | - 'tickets' => $eem_ticket, |
|
559 | - ]; |
|
560 | - // Get the IDs of event datetimes. |
|
561 | - $datetimeIds = $eem_datetime->get_col([[ |
|
562 | - 'EVT_ID' => $eventId, |
|
563 | - 'DTT_deleted' => ['IN', [true, false]], |
|
564 | - ]]); |
|
565 | - foreach ($datetimeIds as $datetimeId) { |
|
566 | - $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
567 | - foreach ($related_models as $key => $model) { |
|
568 | - // Get the IDs of related entities for the datetime ID. |
|
569 | - $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
570 | - $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
571 | - } |
|
572 | - } |
|
573 | - |
|
574 | - // PROCESS TICKETS |
|
575 | - $related_models = [ |
|
576 | - 'datetimes' => $eem_datetime, |
|
577 | - 'prices' => $eem_price, |
|
578 | - ]; |
|
579 | - // Get the IDs of all datetime tickets. |
|
580 | - $ticketIds = $eem_ticket->get_col([[ |
|
581 | - 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
582 | - 'TKT_deleted' => ['IN', [true, false]], |
|
583 | - ]]); |
|
584 | - foreach ($ticketIds as $ticketId) { |
|
585 | - $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
586 | - |
|
587 | - foreach ($related_models as $key => $model) { |
|
588 | - // Get the IDs of related entities for the ticket ID. |
|
589 | - $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
590 | - $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
591 | - } |
|
592 | - } |
|
593 | - |
|
594 | - // PROCESS PRICES |
|
595 | - $related_models = [ |
|
596 | - 'tickets' => $eem_ticket, |
|
597 | - 'priceTypes' => $eem_price_type, |
|
598 | - ]; |
|
599 | - // Get the IDs of all ticket prices. |
|
600 | - $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
601 | - foreach ($priceIds as $priceId) { |
|
602 | - $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
603 | - |
|
604 | - foreach ($related_models as $key => $model) { |
|
605 | - // Get the IDs of related entities for the price ID. |
|
606 | - $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
607 | - $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
608 | - } |
|
609 | - } |
|
610 | - |
|
611 | - return $data; |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Convert the DB ID into GID |
|
616 | - * |
|
617 | - * @param string $type |
|
618 | - * @param int|int[] $ID |
|
619 | - * @return mixed |
|
620 | - */ |
|
621 | - public static function convertToGlobalId($type, $ID) |
|
622 | - { |
|
623 | - if (is_array($ID)) { |
|
624 | - return array_map(function ($id) use ($type) { |
|
625 | - return self::convertToGlobalId($type, $id); |
|
626 | - }, $ID); |
|
627 | - } |
|
628 | - return Relay::toGlobalId($type, $ID); |
|
629 | - } |
|
630 | - |
|
631 | - |
|
632 | - /** |
|
633 | - * Returns Jed-formatted localization data. |
|
634 | - * |
|
635 | - * @param string $domain Translation domain. |
|
636 | - * @return array |
|
637 | - */ |
|
638 | - public static function getJedLocaleData($domain) |
|
639 | - { |
|
640 | - $translations = get_translations_for_domain($domain); |
|
641 | - |
|
642 | - $locale = array( |
|
643 | - '' => array( |
|
644 | - 'domain' => $domain, |
|
645 | - 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
646 | - ), |
|
647 | - ); |
|
648 | - |
|
649 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
650 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
651 | - } |
|
652 | - |
|
653 | - foreach ($translations->entries as $msgid => $entry) { |
|
654 | - $locale[ $msgid ] = $entry->translations; |
|
655 | - } |
|
656 | - |
|
657 | - return $locale; |
|
658 | - } |
|
497 | + $data = [ |
|
498 | + 'operation_name' => 'GET_CURRENT_USER', |
|
499 | + 'query' => $query, |
|
500 | + ]; |
|
501 | + |
|
502 | + $responseData = $this->makeGraphQLRequest($data); |
|
503 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
504 | + } |
|
505 | + |
|
506 | + |
|
507 | + /** |
|
508 | + * @param array $data |
|
509 | + * @return array |
|
510 | + * @since $VID:$ |
|
511 | + */ |
|
512 | + protected function makeGraphQLRequest($data) |
|
513 | + { |
|
514 | + try { |
|
515 | + $response = graphql($data); |
|
516 | + if (!empty($response['data'])) { |
|
517 | + return $response['data']; |
|
518 | + } |
|
519 | + return null; |
|
520 | + } catch (\Exception $e) { |
|
521 | + // do something with the errors thrown |
|
522 | + return null; |
|
523 | + } |
|
524 | + } |
|
525 | + |
|
526 | + |
|
527 | + /** |
|
528 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
529 | + * @param array $args The inputArgs on the field |
|
530 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
531 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
532 | + * @return string |
|
533 | + * @throws EE_Error |
|
534 | + * @throws Exception |
|
535 | + * @throws InvalidArgumentException |
|
536 | + * @throws InvalidDataTypeException |
|
537 | + * @throws InvalidInterfaceException |
|
538 | + * @throws ReflectionException |
|
539 | + * @throws UserError |
|
540 | + * @throws UnexpectedEntityException |
|
541 | + * @since $VID:$ |
|
542 | + */ |
|
543 | + public static function getRelationalData($eventId) |
|
544 | + { |
|
545 | + $data = [ |
|
546 | + 'datetimes' => [], |
|
547 | + 'tickets' => [], |
|
548 | + 'prices' => [], |
|
549 | + ]; |
|
550 | + |
|
551 | + $eem_datetime = EEM_Datetime::instance(); |
|
552 | + $eem_ticket = EEM_Ticket::instance(); |
|
553 | + $eem_price = EEM_Price::instance(); |
|
554 | + $eem_price_type = EEM_Price_Type::instance(); |
|
555 | + |
|
556 | + // PROCESS DATETIMES |
|
557 | + $related_models = [ |
|
558 | + 'tickets' => $eem_ticket, |
|
559 | + ]; |
|
560 | + // Get the IDs of event datetimes. |
|
561 | + $datetimeIds = $eem_datetime->get_col([[ |
|
562 | + 'EVT_ID' => $eventId, |
|
563 | + 'DTT_deleted' => ['IN', [true, false]], |
|
564 | + ]]); |
|
565 | + foreach ($datetimeIds as $datetimeId) { |
|
566 | + $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
567 | + foreach ($related_models as $key => $model) { |
|
568 | + // Get the IDs of related entities for the datetime ID. |
|
569 | + $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
570 | + $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
571 | + } |
|
572 | + } |
|
573 | + |
|
574 | + // PROCESS TICKETS |
|
575 | + $related_models = [ |
|
576 | + 'datetimes' => $eem_datetime, |
|
577 | + 'prices' => $eem_price, |
|
578 | + ]; |
|
579 | + // Get the IDs of all datetime tickets. |
|
580 | + $ticketIds = $eem_ticket->get_col([[ |
|
581 | + 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
582 | + 'TKT_deleted' => ['IN', [true, false]], |
|
583 | + ]]); |
|
584 | + foreach ($ticketIds as $ticketId) { |
|
585 | + $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
586 | + |
|
587 | + foreach ($related_models as $key => $model) { |
|
588 | + // Get the IDs of related entities for the ticket ID. |
|
589 | + $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
590 | + $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
591 | + } |
|
592 | + } |
|
593 | + |
|
594 | + // PROCESS PRICES |
|
595 | + $related_models = [ |
|
596 | + 'tickets' => $eem_ticket, |
|
597 | + 'priceTypes' => $eem_price_type, |
|
598 | + ]; |
|
599 | + // Get the IDs of all ticket prices. |
|
600 | + $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
601 | + foreach ($priceIds as $priceId) { |
|
602 | + $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
603 | + |
|
604 | + foreach ($related_models as $key => $model) { |
|
605 | + // Get the IDs of related entities for the price ID. |
|
606 | + $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
607 | + $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
608 | + } |
|
609 | + } |
|
610 | + |
|
611 | + return $data; |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Convert the DB ID into GID |
|
616 | + * |
|
617 | + * @param string $type |
|
618 | + * @param int|int[] $ID |
|
619 | + * @return mixed |
|
620 | + */ |
|
621 | + public static function convertToGlobalId($type, $ID) |
|
622 | + { |
|
623 | + if (is_array($ID)) { |
|
624 | + return array_map(function ($id) use ($type) { |
|
625 | + return self::convertToGlobalId($type, $id); |
|
626 | + }, $ID); |
|
627 | + } |
|
628 | + return Relay::toGlobalId($type, $ID); |
|
629 | + } |
|
630 | + |
|
631 | + |
|
632 | + /** |
|
633 | + * Returns Jed-formatted localization data. |
|
634 | + * |
|
635 | + * @param string $domain Translation domain. |
|
636 | + * @return array |
|
637 | + */ |
|
638 | + public static function getJedLocaleData($domain) |
|
639 | + { |
|
640 | + $translations = get_translations_for_domain($domain); |
|
641 | + |
|
642 | + $locale = array( |
|
643 | + '' => array( |
|
644 | + 'domain' => $domain, |
|
645 | + 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
646 | + ), |
|
647 | + ); |
|
648 | + |
|
649 | + if (! empty($translations->headers['Plural-Forms'])) { |
|
650 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
651 | + } |
|
652 | + |
|
653 | + foreach ($translations->entries as $msgid => $entry) { |
|
654 | + $locale[ $msgid ] = $entry->translations; |
|
655 | + } |
|
656 | + |
|
657 | + return $locale; |
|
658 | + } |
|
659 | 659 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | { |
104 | 104 | if ($this->admin_config->useAdvancedEditor()) { |
105 | 105 | $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
106 | - if (! $eventId) { |
|
106 | + if ( ! $eventId) { |
|
107 | 107 | global $post; |
108 | 108 | $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
109 | 109 | $eventId = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events' |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | $data = wp_json_encode($data); |
116 | 116 | add_action( |
117 | 117 | 'admin_footer', |
118 | - static function () use ($data) { |
|
118 | + static function() use ($data) { |
|
119 | 119 | wp_add_inline_script( |
120 | 120 | EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
121 | 121 | " |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | ); |
128 | 128 | add_action( |
129 | 129 | 'admin_footer', |
130 | - static function () use ($data) { |
|
130 | + static function() use ($data) { |
|
131 | 131 | wp_add_inline_script( |
132 | 132 | EspressoEditorAssetManager::JS_HANDLE_EDITOR_PROTOTYPE, |
133 | 133 | " |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $event = $this->getEventGraphQLData($eventId); |
161 | 161 | $event['dbId'] = $eventId; |
162 | 162 | |
163 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
163 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()).Router::$route : ''; |
|
164 | 164 | $graphqlEndpoint = esc_url($graphqlEndpoint); |
165 | 165 | |
166 | 166 | $currentUser = $this->getGraphQLCurrentUser(); |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | $i18n = self::getJedLocaleData('event_espresso'); |
171 | 171 | |
172 | - $assets_url = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
172 | + $assets_url = EE_PLUGIN_DIR_URL.'assets/dist/'; |
|
173 | 173 | |
174 | 174 | return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assets_url'); |
175 | 175 | } |
@@ -189,18 +189,18 @@ discard block |
||
189 | 189 | $datetimes = $this->getGraphQLDatetimes($eventId); |
190 | 190 | } |
191 | 191 | |
192 | - if (! empty($datetimes['nodes'])) { |
|
192 | + if ( ! empty($datetimes['nodes'])) { |
|
193 | 193 | $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
194 | 194 | |
195 | - if (! empty($datetimeIn)) { |
|
195 | + if ( ! empty($datetimeIn)) { |
|
196 | 196 | $tickets = $this->getGraphQLTickets($datetimeIn); |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | - if (! empty($tickets['nodes'])) { |
|
200 | + if ( ! empty($tickets['nodes'])) { |
|
201 | 201 | $ticketIn = wp_list_pluck($tickets['nodes'], 'id'); |
202 | 202 | |
203 | - if (! empty($ticketIn)) { |
|
203 | + if ( ! empty($ticketIn)) { |
|
204 | 204 | $prices = $this->getGraphQLPrices($ticketIn); |
205 | 205 | } |
206 | 206 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | */ |
253 | 253 | protected function getGraphQLDatetimes($eventId) |
254 | 254 | { |
255 | - $field_key = lcfirst($this->namespace) . 'Datetimes'; |
|
255 | + $field_key = lcfirst($this->namespace).'Datetimes'; |
|
256 | 256 | $query = <<<QUERY |
257 | 257 | query GET_DATETIMES(\$where: {$this->namespace}RootQueryDatetimesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
258 | 258 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -293,7 +293,7 @@ discard block |
||
293 | 293 | ]; |
294 | 294 | |
295 | 295 | $responseData = $this->makeGraphQLRequest($data); |
296 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
296 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | */ |
305 | 305 | protected function getGraphQLTickets(array $datetimeIn) |
306 | 306 | { |
307 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
307 | + $field_key = lcfirst($this->namespace).'Tickets'; |
|
308 | 308 | $query = <<<QUERY |
309 | 309 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) { |
310 | 310 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | ]; |
352 | 352 | |
353 | 353 | $responseData = $this->makeGraphQLRequest($data); |
354 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
354 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | */ |
363 | 363 | protected function getGraphQLPrices(array $ticketIn) |
364 | 364 | { |
365 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
365 | + $field_key = lcfirst($this->namespace).'Prices'; |
|
366 | 366 | $query = <<<QUERY |
367 | 367 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
368 | 368 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | ]; |
399 | 399 | |
400 | 400 | $responseData = $this->makeGraphQLRequest($data); |
401 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
401 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | */ |
409 | 409 | protected function getGraphQLPriceTypes() |
410 | 410 | { |
411 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
411 | + $field_key = lcfirst($this->namespace).'PriceTypes'; |
|
412 | 412 | $query = <<<QUERY |
413 | 413 | query GET_PRICE_TYPES(\$first: Int, \$last: Int ) { |
414 | 414 | {$field_key}(first: \$first, last: \$last) { |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | ]; |
439 | 439 | |
440 | 440 | $responseData = $this->makeGraphQLRequest($data); |
441 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
441 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
442 | 442 | } |
443 | 443 | |
444 | 444 | |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | ]; |
474 | 474 | |
475 | 475 | $responseData = $this->makeGraphQLRequest($data); |
476 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
476 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | ]; |
501 | 501 | |
502 | 502 | $responseData = $this->makeGraphQLRequest($data); |
503 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
503 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | |
@@ -513,7 +513,7 @@ discard block |
||
513 | 513 | { |
514 | 514 | try { |
515 | 515 | $response = graphql($data); |
516 | - if (!empty($response['data'])) { |
|
516 | + if ( ! empty($response['data'])) { |
|
517 | 517 | return $response['data']; |
518 | 518 | } |
519 | 519 | return null; |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | foreach ($related_models as $key => $model) { |
568 | 568 | // Get the IDs of related entities for the datetime ID. |
569 | 569 | $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
570 | - $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
570 | + $data['datetimes'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | foreach ($related_models as $key => $model) { |
588 | 588 | // Get the IDs of related entities for the ticket ID. |
589 | 589 | $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
590 | - $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
590 | + $data['tickets'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | foreach ($related_models as $key => $model) { |
605 | 605 | // Get the IDs of related entities for the price ID. |
606 | 606 | $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
607 | - $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
607 | + $data['prices'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
608 | 608 | } |
609 | 609 | } |
610 | 610 | |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | public static function convertToGlobalId($type, $ID) |
622 | 622 | { |
623 | 623 | if (is_array($ID)) { |
624 | - return array_map(function ($id) use ($type) { |
|
624 | + return array_map(function($id) use ($type) { |
|
625 | 625 | return self::convertToGlobalId($type, $id); |
626 | 626 | }, $ID); |
627 | 627 | } |
@@ -646,12 +646,12 @@ discard block |
||
646 | 646 | ), |
647 | 647 | ); |
648 | 648 | |
649 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
649 | + if ( ! empty($translations->headers['Plural-Forms'])) { |
|
650 | 650 | $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
651 | 651 | } |
652 | 652 | |
653 | 653 | foreach ($translations->entries as $msgid => $entry) { |
654 | - $locale[ $msgid ] = $entry->translations; |
|
654 | + $locale[$msgid] = $entry->translations; |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | return $locale; |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | /** |
54 | 54 | * FieldResolver constructor. |
55 | 55 | * |
56 | - * @param mixed $model The model instance. |
|
56 | + * @param \EEM_Base $model The model instance. |
|
57 | 57 | * @param array $fields The fields registered for the type. |
58 | 58 | */ |
59 | 59 | public function __construct($model, array $fields) |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * Resolve the global ID |
127 | 127 | * |
128 | - * @param mixed $source |
|
128 | + * @param EE_Base_Class $source |
|
129 | 129 | * @return string|null |
130 | 130 | * @throws Exception |
131 | 131 | * @since $VID:$ |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * Resolve the cache ID |
143 | 143 | * |
144 | - * @param mixed $source |
|
144 | + * @param EE_Base_Class $source |
|
145 | 145 | * @return string |
146 | 146 | * @since $VID:$ |
147 | 147 | */ |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | |
159 | 159 | /** |
160 | - * @param mixed $source |
|
160 | + * @param EE_Base_Class $source |
|
161 | 161 | * @param $args |
162 | 162 | * @param $context |
163 | 163 | * @return Deferred|null |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | |
176 | 176 | /** |
177 | - * @param mixed $source |
|
177 | + * @param EE_Base_Class $source |
|
178 | 178 | * @return EE_Base_Class|null |
179 | 179 | * @throws EE_Error |
180 | 180 | * @throws InvalidArgumentException |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | |
191 | 191 | |
192 | 192 | /** |
193 | - * @param mixed $source |
|
193 | + * @param EE_Base_Class $source |
|
194 | 194 | * @param $args |
195 | 195 | * @param $context |
196 | 196 | * @return Deferred|null |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | |
226 | 226 | /** |
227 | - * @param mixed $source The source instance. |
|
227 | + * @param EE_Base_Class $source The source instance. |
|
228 | 228 | * @return EE_Base_Class|null |
229 | 229 | * @throws EE_Error |
230 | 230 | * @throws InvalidArgumentException |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | |
252 | 252 | /** |
253 | - * @param mixed $source The source instance. |
|
253 | + * @param EE_Base_Class $source The source instance. |
|
254 | 254 | * @return EE_Base_Class|null |
255 | 255 | * @throws EE_Error |
256 | 256 | * @throws InvalidArgumentException |
@@ -39,241 +39,241 @@ |
||
39 | 39 | class FieldResolver extends ResolverBase |
40 | 40 | { |
41 | 41 | |
42 | - /** |
|
43 | - * @var mixed $model |
|
44 | - */ |
|
45 | - protected $model; |
|
42 | + /** |
|
43 | + * @var mixed $model |
|
44 | + */ |
|
45 | + protected $model; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var array $fields . |
|
49 | - */ |
|
50 | - protected $fields; |
|
47 | + /** |
|
48 | + * @var array $fields . |
|
49 | + */ |
|
50 | + protected $fields; |
|
51 | 51 | |
52 | 52 | |
53 | - /** |
|
54 | - * FieldResolver constructor. |
|
55 | - * |
|
56 | - * @param mixed $model The model instance. |
|
57 | - * @param array $fields The fields registered for the type. |
|
58 | - */ |
|
59 | - public function __construct($model, array $fields) |
|
60 | - { |
|
61 | - $this->model = $model; |
|
62 | - $this->fields = $fields; |
|
63 | - } |
|
53 | + /** |
|
54 | + * FieldResolver constructor. |
|
55 | + * |
|
56 | + * @param mixed $model The model instance. |
|
57 | + * @param array $fields The fields registered for the type. |
|
58 | + */ |
|
59 | + public function __construct($model, array $fields) |
|
60 | + { |
|
61 | + $this->model = $model; |
|
62 | + $this->fields = $fields; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | - /** |
|
67 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
68 | - * @param array $args The inputArgs on the field |
|
69 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
70 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
71 | - * @return string |
|
72 | - * @throws EE_Error |
|
73 | - * @throws Exception |
|
74 | - * @throws InvalidArgumentException |
|
75 | - * @throws InvalidDataTypeException |
|
76 | - * @throws InvalidInterfaceException |
|
77 | - * @throws ReflectionException |
|
78 | - * @throws UserError |
|
79 | - * @throws UnexpectedEntityException |
|
80 | - * @since $VID:$ |
|
81 | - */ |
|
82 | - public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
83 | - { |
|
84 | - $fieldName = $info->fieldName; |
|
85 | - $field = isset($this->fields[ $fieldName ]) ? $this->fields[ $fieldName ] : null; |
|
86 | - // Field should exist in teh registered fields |
|
87 | - if ($field instanceof GraphQLField) { |
|
88 | - // check if the field should be resolved. |
|
89 | - if (! $field->shouldResolve()) { |
|
90 | - return null; |
|
91 | - } |
|
92 | - // Give priority to the internal resolver. |
|
93 | - if ($field->hasInternalResolver()) { |
|
94 | - return $field->resolve($source, $args, $context, $info); |
|
95 | - } |
|
96 | - if (! ($source instanceof EE_Base_Class)) { |
|
97 | - return null; |
|
98 | - } |
|
99 | - // Check if the field has a key mapped to model. |
|
100 | - if (! empty($field->key())) { |
|
101 | - $value = $source->{$field->key()}(); |
|
102 | - return $field->mayBeFormatValue($value, $source); |
|
103 | - } |
|
104 | - switch ($fieldName) { |
|
105 | - case 'id': // the global ID |
|
106 | - return $this->resolveId($source); |
|
107 | - case 'cacheId': |
|
108 | - return $this->resolveCacheId($source); |
|
109 | - case 'parent': |
|
110 | - return $this->resolveParent($source); |
|
111 | - case 'event': |
|
112 | - return $this->resolveEvent($source, $args, $context); |
|
113 | - case 'wpUser': |
|
114 | - return $this->resolveWpUser($source, $args, $context); |
|
115 | - case 'state': // Venue |
|
116 | - return $this->resolveState($source); |
|
117 | - case 'country': // State, Venue |
|
118 | - return $this->resolveCountry($source); |
|
119 | - } |
|
120 | - } |
|
121 | - return null; |
|
122 | - } |
|
66 | + /** |
|
67 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
68 | + * @param array $args The inputArgs on the field |
|
69 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
70 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
71 | + * @return string |
|
72 | + * @throws EE_Error |
|
73 | + * @throws Exception |
|
74 | + * @throws InvalidArgumentException |
|
75 | + * @throws InvalidDataTypeException |
|
76 | + * @throws InvalidInterfaceException |
|
77 | + * @throws ReflectionException |
|
78 | + * @throws UserError |
|
79 | + * @throws UnexpectedEntityException |
|
80 | + * @since $VID:$ |
|
81 | + */ |
|
82 | + public function resolve($source, array $args, AppContext $context, ResolveInfo $info) |
|
83 | + { |
|
84 | + $fieldName = $info->fieldName; |
|
85 | + $field = isset($this->fields[ $fieldName ]) ? $this->fields[ $fieldName ] : null; |
|
86 | + // Field should exist in teh registered fields |
|
87 | + if ($field instanceof GraphQLField) { |
|
88 | + // check if the field should be resolved. |
|
89 | + if (! $field->shouldResolve()) { |
|
90 | + return null; |
|
91 | + } |
|
92 | + // Give priority to the internal resolver. |
|
93 | + if ($field->hasInternalResolver()) { |
|
94 | + return $field->resolve($source, $args, $context, $info); |
|
95 | + } |
|
96 | + if (! ($source instanceof EE_Base_Class)) { |
|
97 | + return null; |
|
98 | + } |
|
99 | + // Check if the field has a key mapped to model. |
|
100 | + if (! empty($field->key())) { |
|
101 | + $value = $source->{$field->key()}(); |
|
102 | + return $field->mayBeFormatValue($value, $source); |
|
103 | + } |
|
104 | + switch ($fieldName) { |
|
105 | + case 'id': // the global ID |
|
106 | + return $this->resolveId($source); |
|
107 | + case 'cacheId': |
|
108 | + return $this->resolveCacheId($source); |
|
109 | + case 'parent': |
|
110 | + return $this->resolveParent($source); |
|
111 | + case 'event': |
|
112 | + return $this->resolveEvent($source, $args, $context); |
|
113 | + case 'wpUser': |
|
114 | + return $this->resolveWpUser($source, $args, $context); |
|
115 | + case 'state': // Venue |
|
116 | + return $this->resolveState($source); |
|
117 | + case 'country': // State, Venue |
|
118 | + return $this->resolveCountry($source); |
|
119 | + } |
|
120 | + } |
|
121 | + return null; |
|
122 | + } |
|
123 | 123 | |
124 | 124 | |
125 | - /** |
|
126 | - * Resolve the global ID |
|
127 | - * |
|
128 | - * @param mixed $source |
|
129 | - * @return string|null |
|
130 | - * @throws Exception |
|
131 | - * @since $VID:$ |
|
132 | - */ |
|
133 | - public function resolveId($source) |
|
134 | - { |
|
135 | - $ID = $source instanceof EE_Base_Class ? $source->ID() : 0; |
|
125 | + /** |
|
126 | + * Resolve the global ID |
|
127 | + * |
|
128 | + * @param mixed $source |
|
129 | + * @return string|null |
|
130 | + * @throws Exception |
|
131 | + * @since $VID:$ |
|
132 | + */ |
|
133 | + public function resolveId($source) |
|
134 | + { |
|
135 | + $ID = $source instanceof EE_Base_Class ? $source->ID() : 0; |
|
136 | 136 | |
137 | - return $ID ? Relay::toGlobalId($this->model->item_name(), $ID) : null; |
|
138 | - } |
|
137 | + return $ID ? Relay::toGlobalId($this->model->item_name(), $ID) : null; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | |
141 | - /** |
|
142 | - * Resolve the cache ID |
|
143 | - * |
|
144 | - * @param mixed $source |
|
145 | - * @return string |
|
146 | - * @since $VID:$ |
|
147 | - */ |
|
148 | - public function resolveCacheId($source) |
|
149 | - { |
|
150 | - $model_name = $this->model->item_name(); |
|
151 | - $ID = $source->ID(); |
|
152 | - // Since cacheId does not need to be globally unique |
|
153 | - // $uniqid is sufficient, still adding the model name and ID |
|
154 | - // may be we need/use them in future. |
|
155 | - return uniqid("{$model_name}:{$ID}:", true); |
|
156 | - } |
|
141 | + /** |
|
142 | + * Resolve the cache ID |
|
143 | + * |
|
144 | + * @param mixed $source |
|
145 | + * @return string |
|
146 | + * @since $VID:$ |
|
147 | + */ |
|
148 | + public function resolveCacheId($source) |
|
149 | + { |
|
150 | + $model_name = $this->model->item_name(); |
|
151 | + $ID = $source->ID(); |
|
152 | + // Since cacheId does not need to be globally unique |
|
153 | + // $uniqid is sufficient, still adding the model name and ID |
|
154 | + // may be we need/use them in future. |
|
155 | + return uniqid("{$model_name}:{$ID}:", true); |
|
156 | + } |
|
157 | 157 | |
158 | 158 | |
159 | - /** |
|
160 | - * @param mixed $source |
|
161 | - * @param $args |
|
162 | - * @param $context |
|
163 | - * @return Deferred|null |
|
164 | - * @throws Exception |
|
165 | - * @since $VID:$ |
|
166 | - */ |
|
167 | - public function resolveWpUser($source, $args, $context) |
|
168 | - { |
|
169 | - $user_id = $source->wp_user(); |
|
170 | - return $user_id |
|
171 | - ? DataSource::resolve_user($user_id, $context) |
|
172 | - : null; |
|
173 | - } |
|
159 | + /** |
|
160 | + * @param mixed $source |
|
161 | + * @param $args |
|
162 | + * @param $context |
|
163 | + * @return Deferred|null |
|
164 | + * @throws Exception |
|
165 | + * @since $VID:$ |
|
166 | + */ |
|
167 | + public function resolveWpUser($source, $args, $context) |
|
168 | + { |
|
169 | + $user_id = $source->wp_user(); |
|
170 | + return $user_id |
|
171 | + ? DataSource::resolve_user($user_id, $context) |
|
172 | + : null; |
|
173 | + } |
|
174 | 174 | |
175 | 175 | |
176 | - /** |
|
177 | - * @param mixed $source |
|
178 | - * @return EE_Base_Class|null |
|
179 | - * @throws EE_Error |
|
180 | - * @throws InvalidArgumentException |
|
181 | - * @throws InvalidDataTypeException |
|
182 | - * @throws InvalidInterfaceException |
|
183 | - * @throws ReflectionException |
|
184 | - * @since $VID:$ |
|
185 | - */ |
|
186 | - public function resolveParent($source) |
|
187 | - { |
|
188 | - return $this->model->get_one_by_ID($source->parent()); |
|
189 | - } |
|
176 | + /** |
|
177 | + * @param mixed $source |
|
178 | + * @return EE_Base_Class|null |
|
179 | + * @throws EE_Error |
|
180 | + * @throws InvalidArgumentException |
|
181 | + * @throws InvalidDataTypeException |
|
182 | + * @throws InvalidInterfaceException |
|
183 | + * @throws ReflectionException |
|
184 | + * @since $VID:$ |
|
185 | + */ |
|
186 | + public function resolveParent($source) |
|
187 | + { |
|
188 | + return $this->model->get_one_by_ID($source->parent()); |
|
189 | + } |
|
190 | 190 | |
191 | 191 | |
192 | - /** |
|
193 | - * @param mixed $source |
|
194 | - * @param $args |
|
195 | - * @param $context |
|
196 | - * @return Deferred|null |
|
197 | - * @throws EE_Error |
|
198 | - * @throws InvalidArgumentException |
|
199 | - * @throws InvalidDataTypeException |
|
200 | - * @throws InvalidInterfaceException |
|
201 | - * @throws ReflectionException |
|
202 | - * @throws UserError |
|
203 | - * @throws UnexpectedEntityException |
|
204 | - * @since $VID:$ |
|
205 | - */ |
|
206 | - public function resolveEvent($source, $args, $context) |
|
207 | - { |
|
208 | - switch (true) { |
|
209 | - case $source instanceof EE_Datetime: |
|
210 | - $event = $source->event(); |
|
211 | - break; |
|
212 | - case $source instanceof EE_Venue: |
|
213 | - case $source instanceof EE_Ticket: |
|
214 | - $event = $source->get_related_event(); |
|
215 | - break; |
|
216 | - default: |
|
217 | - $event = null; |
|
218 | - break; |
|
219 | - } |
|
220 | - return $event instanceof EE_Event |
|
221 | - ? DataSource::resolve_post_object($event->ID(), $context) |
|
222 | - : null; |
|
223 | - } |
|
192 | + /** |
|
193 | + * @param mixed $source |
|
194 | + * @param $args |
|
195 | + * @param $context |
|
196 | + * @return Deferred|null |
|
197 | + * @throws EE_Error |
|
198 | + * @throws InvalidArgumentException |
|
199 | + * @throws InvalidDataTypeException |
|
200 | + * @throws InvalidInterfaceException |
|
201 | + * @throws ReflectionException |
|
202 | + * @throws UserError |
|
203 | + * @throws UnexpectedEntityException |
|
204 | + * @since $VID:$ |
|
205 | + */ |
|
206 | + public function resolveEvent($source, $args, $context) |
|
207 | + { |
|
208 | + switch (true) { |
|
209 | + case $source instanceof EE_Datetime: |
|
210 | + $event = $source->event(); |
|
211 | + break; |
|
212 | + case $source instanceof EE_Venue: |
|
213 | + case $source instanceof EE_Ticket: |
|
214 | + $event = $source->get_related_event(); |
|
215 | + break; |
|
216 | + default: |
|
217 | + $event = null; |
|
218 | + break; |
|
219 | + } |
|
220 | + return $event instanceof EE_Event |
|
221 | + ? DataSource::resolve_post_object($event->ID(), $context) |
|
222 | + : null; |
|
223 | + } |
|
224 | 224 | |
225 | 225 | |
226 | - /** |
|
227 | - * @param mixed $source The source instance. |
|
228 | - * @return EE_Base_Class|null |
|
229 | - * @throws EE_Error |
|
230 | - * @throws InvalidArgumentException |
|
231 | - * @throws InvalidDataTypeException |
|
232 | - * @throws InvalidInterfaceException |
|
233 | - * @since $VID:$ |
|
234 | - */ |
|
235 | - public function resolveState($source) |
|
236 | - { |
|
237 | - switch (true) { |
|
238 | - case $source instanceof EE_Attendee: |
|
239 | - case $source instanceof EE_Venue: |
|
240 | - $state_id = $source->state_ID(); |
|
241 | - break; |
|
242 | - default: |
|
243 | - $state_id = null; |
|
244 | - break; |
|
245 | - } |
|
246 | - return $state_id |
|
247 | - ? EEM_State::instance()->get_one_by_ID($state_id) |
|
248 | - : null; |
|
249 | - } |
|
226 | + /** |
|
227 | + * @param mixed $source The source instance. |
|
228 | + * @return EE_Base_Class|null |
|
229 | + * @throws EE_Error |
|
230 | + * @throws InvalidArgumentException |
|
231 | + * @throws InvalidDataTypeException |
|
232 | + * @throws InvalidInterfaceException |
|
233 | + * @since $VID:$ |
|
234 | + */ |
|
235 | + public function resolveState($source) |
|
236 | + { |
|
237 | + switch (true) { |
|
238 | + case $source instanceof EE_Attendee: |
|
239 | + case $source instanceof EE_Venue: |
|
240 | + $state_id = $source->state_ID(); |
|
241 | + break; |
|
242 | + default: |
|
243 | + $state_id = null; |
|
244 | + break; |
|
245 | + } |
|
246 | + return $state_id |
|
247 | + ? EEM_State::instance()->get_one_by_ID($state_id) |
|
248 | + : null; |
|
249 | + } |
|
250 | 250 | |
251 | 251 | |
252 | - /** |
|
253 | - * @param mixed $source The source instance. |
|
254 | - * @return EE_Base_Class|null |
|
255 | - * @throws EE_Error |
|
256 | - * @throws InvalidArgumentException |
|
257 | - * @throws InvalidDataTypeException |
|
258 | - * @throws InvalidInterfaceException |
|
259 | - * @since $VID:$ |
|
260 | - */ |
|
261 | - public function resolveCountry($source) |
|
262 | - { |
|
263 | - switch (true) { |
|
264 | - case $source instanceof EE_State: |
|
265 | - $country_iso = $source->country_iso(); |
|
266 | - break; |
|
267 | - case $source instanceof EE_Venue: |
|
268 | - $country_iso = $source->country_ID(); |
|
269 | - break; |
|
270 | - default: |
|
271 | - $country_iso = null; |
|
272 | - break; |
|
273 | - } |
|
252 | + /** |
|
253 | + * @param mixed $source The source instance. |
|
254 | + * @return EE_Base_Class|null |
|
255 | + * @throws EE_Error |
|
256 | + * @throws InvalidArgumentException |
|
257 | + * @throws InvalidDataTypeException |
|
258 | + * @throws InvalidInterfaceException |
|
259 | + * @since $VID:$ |
|
260 | + */ |
|
261 | + public function resolveCountry($source) |
|
262 | + { |
|
263 | + switch (true) { |
|
264 | + case $source instanceof EE_State: |
|
265 | + $country_iso = $source->country_iso(); |
|
266 | + break; |
|
267 | + case $source instanceof EE_Venue: |
|
268 | + $country_iso = $source->country_ID(); |
|
269 | + break; |
|
270 | + default: |
|
271 | + $country_iso = null; |
|
272 | + break; |
|
273 | + } |
|
274 | 274 | |
275 | - return $country_iso |
|
276 | - ? EEM_Country::instance()->get_one_by_ID($country_iso) |
|
277 | - : null; |
|
278 | - } |
|
275 | + return $country_iso |
|
276 | + ? EEM_Country::instance()->get_one_by_ID($country_iso) |
|
277 | + : null; |
|
278 | + } |
|
279 | 279 | } |
@@ -20,77 +20,77 @@ |
||
20 | 20 | class State extends TypeBase |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * State constructor. |
|
25 | - * |
|
26 | - * @param EEM_State $state_model |
|
27 | - */ |
|
28 | - public function __construct(EEM_State $state_model) |
|
29 | - { |
|
30 | - $this->model = $state_model; |
|
31 | - $this->setName($this->namespace . 'State'); |
|
32 | - $this->setDescription(__('A state', 'event_espresso')); |
|
33 | - $this->setIsCustomPostType(false); |
|
23 | + /** |
|
24 | + * State constructor. |
|
25 | + * |
|
26 | + * @param EEM_State $state_model |
|
27 | + */ |
|
28 | + public function __construct(EEM_State $state_model) |
|
29 | + { |
|
30 | + $this->model = $state_model; |
|
31 | + $this->setName($this->namespace . 'State'); |
|
32 | + $this->setDescription(__('A state', 'event_espresso')); |
|
33 | + $this->setIsCustomPostType(false); |
|
34 | 34 | |
35 | - parent::__construct(); |
|
36 | - } |
|
35 | + parent::__construct(); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return GraphQLFieldInterface[] |
|
41 | - * @since $VID:$ |
|
42 | - */ |
|
43 | - public function getFields() |
|
44 | - { |
|
45 | - return [ |
|
46 | - new GraphQLField( |
|
47 | - 'id', |
|
48 | - ['non_null' => 'ID'], |
|
49 | - null, |
|
50 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
51 | - ), |
|
52 | - new GraphQLOutputField( |
|
53 | - 'dbId', |
|
54 | - ['non_null' => 'Int'], |
|
55 | - 'ID', |
|
56 | - esc_html__('State ID', 'event_espresso') |
|
57 | - ), |
|
58 | - new GraphQLField( |
|
59 | - 'abbreviation', |
|
60 | - 'String', |
|
61 | - 'abbrev', |
|
62 | - esc_html__('State Abbreviation', 'event_espresso') |
|
63 | - ), |
|
64 | - new GraphQLOutputField( |
|
65 | - 'cacheId', |
|
66 | - ['non_null' => 'String'], |
|
67 | - null, |
|
68 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
69 | - ), |
|
70 | - new GraphQLField( |
|
71 | - 'name', |
|
72 | - 'String', |
|
73 | - 'name', |
|
74 | - esc_html__('State Name', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLField( |
|
77 | - 'isActive', |
|
78 | - 'Boolean', |
|
79 | - 'active', |
|
80 | - esc_html__('State Active Flag', 'event_espresso') |
|
81 | - ), |
|
82 | - new GraphQLOutputField( |
|
83 | - 'country', |
|
84 | - $this->namespace . 'Country', |
|
85 | - null, |
|
86 | - esc_html__('Country for the state', 'event_espresso') |
|
87 | - ), |
|
88 | - new GraphQLInputField( |
|
89 | - 'country', |
|
90 | - 'String', |
|
91 | - null, |
|
92 | - esc_html__('Country ISO Code', 'event_espresso') |
|
93 | - ), |
|
94 | - ]; |
|
95 | - } |
|
39 | + /** |
|
40 | + * @return GraphQLFieldInterface[] |
|
41 | + * @since $VID:$ |
|
42 | + */ |
|
43 | + public function getFields() |
|
44 | + { |
|
45 | + return [ |
|
46 | + new GraphQLField( |
|
47 | + 'id', |
|
48 | + ['non_null' => 'ID'], |
|
49 | + null, |
|
50 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
51 | + ), |
|
52 | + new GraphQLOutputField( |
|
53 | + 'dbId', |
|
54 | + ['non_null' => 'Int'], |
|
55 | + 'ID', |
|
56 | + esc_html__('State ID', 'event_espresso') |
|
57 | + ), |
|
58 | + new GraphQLField( |
|
59 | + 'abbreviation', |
|
60 | + 'String', |
|
61 | + 'abbrev', |
|
62 | + esc_html__('State Abbreviation', 'event_espresso') |
|
63 | + ), |
|
64 | + new GraphQLOutputField( |
|
65 | + 'cacheId', |
|
66 | + ['non_null' => 'String'], |
|
67 | + null, |
|
68 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
69 | + ), |
|
70 | + new GraphQLField( |
|
71 | + 'name', |
|
72 | + 'String', |
|
73 | + 'name', |
|
74 | + esc_html__('State Name', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLField( |
|
77 | + 'isActive', |
|
78 | + 'Boolean', |
|
79 | + 'active', |
|
80 | + esc_html__('State Active Flag', 'event_espresso') |
|
81 | + ), |
|
82 | + new GraphQLOutputField( |
|
83 | + 'country', |
|
84 | + $this->namespace . 'Country', |
|
85 | + null, |
|
86 | + esc_html__('Country for the state', 'event_espresso') |
|
87 | + ), |
|
88 | + new GraphQLInputField( |
|
89 | + 'country', |
|
90 | + 'String', |
|
91 | + null, |
|
92 | + esc_html__('Country ISO Code', 'event_espresso') |
|
93 | + ), |
|
94 | + ]; |
|
95 | + } |
|
96 | 96 | } |
@@ -33,350 +33,350 @@ |
||
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 GraphQLOutputField( |
|
71 | - 'cacheId', |
|
72 | - ['non_null' => 'String'], |
|
73 | - null, |
|
74 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLInputField( |
|
77 | - 'datetimes', |
|
78 | - ['list_of' => 'ID'], |
|
79 | - null, |
|
80 | - sprintf( |
|
81 | - '%1$s %2$s', |
|
82 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
83 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
84 | - ) |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'description', |
|
88 | - 'String', |
|
89 | - 'description', |
|
90 | - esc_html__('Description of Ticket', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLField( |
|
93 | - 'endDate', |
|
94 | - 'String', |
|
95 | - 'end_date', |
|
96 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
97 | - [$this, 'formatDatetime'] |
|
98 | - ), |
|
99 | - new GraphQLOutputField( |
|
100 | - 'event', |
|
101 | - $this->namespace . 'Event', |
|
102 | - null, |
|
103 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'isDefault', |
|
107 | - 'Boolean', |
|
108 | - 'is_default', |
|
109 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLOutputField( |
|
112 | - 'isExpired', |
|
113 | - 'Boolean', |
|
114 | - 'is_expired', |
|
115 | - esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLOutputField( |
|
118 | - 'isFree', |
|
119 | - 'Boolean', |
|
120 | - 'is_free', |
|
121 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLOutputField( |
|
124 | - 'isOnSale', |
|
125 | - 'Boolean', |
|
126 | - 'is_on_sale', |
|
127 | - esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLOutputField( |
|
130 | - 'isPending', |
|
131 | - 'Boolean', |
|
132 | - 'is_pending', |
|
133 | - esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLField( |
|
136 | - 'isRequired', |
|
137 | - 'Boolean', |
|
138 | - 'required', |
|
139 | - esc_html__( |
|
140 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
141 | - 'event_espresso' |
|
142 | - ) |
|
143 | - ), |
|
144 | - new GraphQLOutputField( |
|
145 | - 'isSoldOut', |
|
146 | - 'Boolean', |
|
147 | - null, |
|
148 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
149 | - null, |
|
150 | - [$this, 'getIsSoldOut'] |
|
151 | - ), |
|
152 | - new GraphQLField( |
|
153 | - 'isTaxable', |
|
154 | - 'Boolean', |
|
155 | - 'taxable', |
|
156 | - esc_html__( |
|
157 | - 'Flag indicating whether there is tax applied on this ticket', |
|
158 | - 'event_espresso' |
|
159 | - ) |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'isTrashed', |
|
163 | - 'Boolean', |
|
164 | - 'deleted', |
|
165 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLField( |
|
168 | - 'max', |
|
169 | - 'Int', |
|
170 | - 'max', |
|
171 | - esc_html__( |
|
172 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
173 | - 'event_espresso' |
|
174 | - ), |
|
175 | - [$this, 'parseInfiniteValue'] |
|
176 | - ), |
|
177 | - new GraphQLField( |
|
178 | - 'min', |
|
179 | - 'Int', |
|
180 | - 'min', |
|
181 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
182 | - ), |
|
183 | - new GraphQLField( |
|
184 | - 'name', |
|
185 | - 'String', |
|
186 | - 'name', |
|
187 | - esc_html__('Ticket Name', 'event_espresso') |
|
188 | - ), |
|
189 | - new GraphQLField( |
|
190 | - 'order', |
|
191 | - 'Int', |
|
192 | - 'order', |
|
193 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
194 | - ), |
|
195 | - new GraphQLOutputField( |
|
196 | - 'parent', |
|
197 | - $this->name(), |
|
198 | - null, |
|
199 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | - ), |
|
201 | - new GraphQLInputField( |
|
202 | - 'parent', |
|
203 | - 'ID', |
|
204 | - null, |
|
205 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | - ), |
|
207 | - new GraphQLField( |
|
208 | - 'price', |
|
209 | - 'Float', |
|
210 | - 'price', |
|
211 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
212 | - ), |
|
213 | - new GraphQLInputField( |
|
214 | - 'prices', |
|
215 | - ['list_of' => 'ID'], |
|
216 | - null, |
|
217 | - sprintf( |
|
218 | - '%1$s %2$s', |
|
219 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
220 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | - ) |
|
222 | - ), |
|
223 | - new GraphQLField( |
|
224 | - 'quantity', |
|
225 | - 'Int', |
|
226 | - 'qty', |
|
227 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
228 | - [$this, 'parseInfiniteValue'] |
|
229 | - ), |
|
230 | - new GraphQLField( |
|
231 | - 'reserved', |
|
232 | - 'Int', |
|
233 | - 'reserved', |
|
234 | - esc_html__( |
|
235 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
236 | - 'event_espresso' |
|
237 | - ) |
|
238 | - ), |
|
239 | - new GraphQLField( |
|
240 | - 'reverseCalculate', |
|
241 | - 'Boolean', |
|
242 | - 'reverse_calculate', |
|
243 | - esc_html__( |
|
244 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
245 | - 'event_espresso' |
|
246 | - ) |
|
247 | - ), |
|
248 | - new GraphQLField( |
|
249 | - 'row', |
|
250 | - 'Int', |
|
251 | - 'row', |
|
252 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
253 | - ), |
|
254 | - new GraphQLField( |
|
255 | - 'sold', |
|
256 | - 'Int', |
|
257 | - 'sold', |
|
258 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
259 | - ), |
|
260 | - new GraphQLOutputField( |
|
261 | - 'status', |
|
262 | - $this->namespace . 'TicketStatusEnum', |
|
263 | - 'ticket_status', |
|
264 | - esc_html__('Ticket status', 'event_espresso') |
|
265 | - ), |
|
266 | - new GraphQLField( |
|
267 | - 'startDate', |
|
268 | - 'String', |
|
269 | - 'start_date', |
|
270 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
271 | - [$this, 'formatDatetime'] |
|
272 | - ), |
|
273 | - new GraphQLField( |
|
274 | - 'uses', |
|
275 | - 'Int', |
|
276 | - 'uses', |
|
277 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
278 | - [$this, 'parseInfiniteValue'] |
|
279 | - ), |
|
280 | - new GraphQLOutputField( |
|
281 | - 'wpUser', |
|
282 | - 'User', |
|
283 | - null, |
|
284 | - esc_html__('Ticket Creator', 'event_espresso') |
|
285 | - ), |
|
286 | - new GraphQLInputField( |
|
287 | - 'wpUser', |
|
288 | - 'Int', |
|
289 | - null, |
|
290 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
291 | - ), |
|
292 | - ]; |
|
293 | - } |
|
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 GraphQLOutputField( |
|
71 | + 'cacheId', |
|
72 | + ['non_null' => 'String'], |
|
73 | + null, |
|
74 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLInputField( |
|
77 | + 'datetimes', |
|
78 | + ['list_of' => 'ID'], |
|
79 | + null, |
|
80 | + sprintf( |
|
81 | + '%1$s %2$s', |
|
82 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
83 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
84 | + ) |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'description', |
|
88 | + 'String', |
|
89 | + 'description', |
|
90 | + esc_html__('Description of Ticket', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLField( |
|
93 | + 'endDate', |
|
94 | + 'String', |
|
95 | + 'end_date', |
|
96 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
97 | + [$this, 'formatDatetime'] |
|
98 | + ), |
|
99 | + new GraphQLOutputField( |
|
100 | + 'event', |
|
101 | + $this->namespace . 'Event', |
|
102 | + null, |
|
103 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'isDefault', |
|
107 | + 'Boolean', |
|
108 | + 'is_default', |
|
109 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLOutputField( |
|
112 | + 'isExpired', |
|
113 | + 'Boolean', |
|
114 | + 'is_expired', |
|
115 | + esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLOutputField( |
|
118 | + 'isFree', |
|
119 | + 'Boolean', |
|
120 | + 'is_free', |
|
121 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLOutputField( |
|
124 | + 'isOnSale', |
|
125 | + 'Boolean', |
|
126 | + 'is_on_sale', |
|
127 | + esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLOutputField( |
|
130 | + 'isPending', |
|
131 | + 'Boolean', |
|
132 | + 'is_pending', |
|
133 | + esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLField( |
|
136 | + 'isRequired', |
|
137 | + 'Boolean', |
|
138 | + 'required', |
|
139 | + esc_html__( |
|
140 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
141 | + 'event_espresso' |
|
142 | + ) |
|
143 | + ), |
|
144 | + new GraphQLOutputField( |
|
145 | + 'isSoldOut', |
|
146 | + 'Boolean', |
|
147 | + null, |
|
148 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
149 | + null, |
|
150 | + [$this, 'getIsSoldOut'] |
|
151 | + ), |
|
152 | + new GraphQLField( |
|
153 | + 'isTaxable', |
|
154 | + 'Boolean', |
|
155 | + 'taxable', |
|
156 | + esc_html__( |
|
157 | + 'Flag indicating whether there is tax applied on this ticket', |
|
158 | + 'event_espresso' |
|
159 | + ) |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'isTrashed', |
|
163 | + 'Boolean', |
|
164 | + 'deleted', |
|
165 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLField( |
|
168 | + 'max', |
|
169 | + 'Int', |
|
170 | + 'max', |
|
171 | + esc_html__( |
|
172 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
173 | + 'event_espresso' |
|
174 | + ), |
|
175 | + [$this, 'parseInfiniteValue'] |
|
176 | + ), |
|
177 | + new GraphQLField( |
|
178 | + 'min', |
|
179 | + 'Int', |
|
180 | + 'min', |
|
181 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
182 | + ), |
|
183 | + new GraphQLField( |
|
184 | + 'name', |
|
185 | + 'String', |
|
186 | + 'name', |
|
187 | + esc_html__('Ticket Name', 'event_espresso') |
|
188 | + ), |
|
189 | + new GraphQLField( |
|
190 | + 'order', |
|
191 | + 'Int', |
|
192 | + 'order', |
|
193 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
194 | + ), |
|
195 | + new GraphQLOutputField( |
|
196 | + 'parent', |
|
197 | + $this->name(), |
|
198 | + null, |
|
199 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
200 | + ), |
|
201 | + new GraphQLInputField( |
|
202 | + 'parent', |
|
203 | + 'ID', |
|
204 | + null, |
|
205 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
206 | + ), |
|
207 | + new GraphQLField( |
|
208 | + 'price', |
|
209 | + 'Float', |
|
210 | + 'price', |
|
211 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
212 | + ), |
|
213 | + new GraphQLInputField( |
|
214 | + 'prices', |
|
215 | + ['list_of' => 'ID'], |
|
216 | + null, |
|
217 | + sprintf( |
|
218 | + '%1$s %2$s', |
|
219 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
220 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
221 | + ) |
|
222 | + ), |
|
223 | + new GraphQLField( |
|
224 | + 'quantity', |
|
225 | + 'Int', |
|
226 | + 'qty', |
|
227 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
228 | + [$this, 'parseInfiniteValue'] |
|
229 | + ), |
|
230 | + new GraphQLField( |
|
231 | + 'reserved', |
|
232 | + 'Int', |
|
233 | + 'reserved', |
|
234 | + esc_html__( |
|
235 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
236 | + 'event_espresso' |
|
237 | + ) |
|
238 | + ), |
|
239 | + new GraphQLField( |
|
240 | + 'reverseCalculate', |
|
241 | + 'Boolean', |
|
242 | + 'reverse_calculate', |
|
243 | + esc_html__( |
|
244 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
245 | + 'event_espresso' |
|
246 | + ) |
|
247 | + ), |
|
248 | + new GraphQLField( |
|
249 | + 'row', |
|
250 | + 'Int', |
|
251 | + 'row', |
|
252 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
253 | + ), |
|
254 | + new GraphQLField( |
|
255 | + 'sold', |
|
256 | + 'Int', |
|
257 | + 'sold', |
|
258 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
259 | + ), |
|
260 | + new GraphQLOutputField( |
|
261 | + 'status', |
|
262 | + $this->namespace . 'TicketStatusEnum', |
|
263 | + 'ticket_status', |
|
264 | + esc_html__('Ticket status', 'event_espresso') |
|
265 | + ), |
|
266 | + new GraphQLField( |
|
267 | + 'startDate', |
|
268 | + 'String', |
|
269 | + 'start_date', |
|
270 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
271 | + [$this, 'formatDatetime'] |
|
272 | + ), |
|
273 | + new GraphQLField( |
|
274 | + 'uses', |
|
275 | + 'Int', |
|
276 | + 'uses', |
|
277 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
278 | + [$this, 'parseInfiniteValue'] |
|
279 | + ), |
|
280 | + new GraphQLOutputField( |
|
281 | + 'wpUser', |
|
282 | + 'User', |
|
283 | + null, |
|
284 | + esc_html__('Ticket Creator', 'event_espresso') |
|
285 | + ), |
|
286 | + new GraphQLInputField( |
|
287 | + 'wpUser', |
|
288 | + 'Int', |
|
289 | + null, |
|
290 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
291 | + ), |
|
292 | + ]; |
|
293 | + } |
|
294 | 294 | |
295 | 295 | |
296 | - /** |
|
297 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
298 | - * @param array $args The inputArgs on the field |
|
299 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
300 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
301 | - * @return string |
|
302 | - * @throws Exception |
|
303 | - * @throws InvalidArgumentException |
|
304 | - * @throws InvalidDataTypeException |
|
305 | - * @throws InvalidInterfaceException |
|
306 | - * @throws ReflectionException |
|
307 | - * @throws UserError |
|
308 | - * @throws UnexpectedEntityException |
|
309 | - * @since $VID:$ |
|
310 | - */ |
|
311 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
312 | - { |
|
313 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
314 | - } |
|
296 | + /** |
|
297 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
298 | + * @param array $args The inputArgs on the field |
|
299 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
300 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
301 | + * @return string |
|
302 | + * @throws Exception |
|
303 | + * @throws InvalidArgumentException |
|
304 | + * @throws InvalidDataTypeException |
|
305 | + * @throws InvalidInterfaceException |
|
306 | + * @throws ReflectionException |
|
307 | + * @throws UserError |
|
308 | + * @throws UnexpectedEntityException |
|
309 | + * @since $VID:$ |
|
310 | + */ |
|
311 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info) |
|
312 | + { |
|
313 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
314 | + } |
|
315 | 315 | |
316 | 316 | |
317 | - /** |
|
318 | - * @param array $inputFields The mutation input fields. |
|
319 | - * @throws InvalidArgumentException |
|
320 | - * @throws ReflectionException |
|
321 | - * @since $VID:$ |
|
322 | - */ |
|
323 | - public function registerMutations(array $inputFields) |
|
324 | - { |
|
325 | - // Register mutation to update an entity. |
|
326 | - register_graphql_mutation( |
|
327 | - 'update' . $this->name(), |
|
328 | - [ |
|
329 | - 'inputFields' => $inputFields, |
|
330 | - 'outputFields' => [ |
|
331 | - lcfirst($this->name()) => [ |
|
332 | - 'type' => $this->name(), |
|
333 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
334 | - ], |
|
335 | - ], |
|
336 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
337 | - ] |
|
338 | - ); |
|
339 | - // Register mutation to delete an entity. |
|
340 | - register_graphql_mutation( |
|
341 | - 'delete' . $this->name(), |
|
342 | - [ |
|
343 | - 'inputFields' => [ |
|
344 | - 'id' => $inputFields['id'], |
|
345 | - 'deletePermanently' => [ |
|
346 | - 'type' => 'Boolean', |
|
347 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
348 | - ], |
|
349 | - ], |
|
350 | - 'outputFields' => [ |
|
351 | - lcfirst($this->name()) => [ |
|
352 | - 'type' => $this->name(), |
|
353 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
354 | - 'resolve' => static function ($payload) { |
|
355 | - $deleted = (object) $payload['deleted']; |
|
317 | + /** |
|
318 | + * @param array $inputFields The mutation input fields. |
|
319 | + * @throws InvalidArgumentException |
|
320 | + * @throws ReflectionException |
|
321 | + * @since $VID:$ |
|
322 | + */ |
|
323 | + public function registerMutations(array $inputFields) |
|
324 | + { |
|
325 | + // Register mutation to update an entity. |
|
326 | + register_graphql_mutation( |
|
327 | + 'update' . $this->name(), |
|
328 | + [ |
|
329 | + 'inputFields' => $inputFields, |
|
330 | + 'outputFields' => [ |
|
331 | + lcfirst($this->name()) => [ |
|
332 | + 'type' => $this->name(), |
|
333 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
334 | + ], |
|
335 | + ], |
|
336 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
337 | + ] |
|
338 | + ); |
|
339 | + // Register mutation to delete an entity. |
|
340 | + register_graphql_mutation( |
|
341 | + 'delete' . $this->name(), |
|
342 | + [ |
|
343 | + 'inputFields' => [ |
|
344 | + 'id' => $inputFields['id'], |
|
345 | + 'deletePermanently' => [ |
|
346 | + 'type' => 'Boolean', |
|
347 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
348 | + ], |
|
349 | + ], |
|
350 | + 'outputFields' => [ |
|
351 | + lcfirst($this->name()) => [ |
|
352 | + 'type' => $this->name(), |
|
353 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
354 | + 'resolve' => static function ($payload) { |
|
355 | + $deleted = (object) $payload['deleted']; |
|
356 | 356 | |
357 | - return ! empty($deleted) ? $deleted : null; |
|
358 | - }, |
|
359 | - ], |
|
360 | - ], |
|
361 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
362 | - ] |
|
363 | - ); |
|
357 | + return ! empty($deleted) ? $deleted : null; |
|
358 | + }, |
|
359 | + ], |
|
360 | + ], |
|
361 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
362 | + ] |
|
363 | + ); |
|
364 | 364 | |
365 | - // remove primary key from input. |
|
366 | - unset($inputFields['id']); |
|
367 | - // Register mutation to update an entity. |
|
368 | - register_graphql_mutation( |
|
369 | - 'create' . $this->name(), |
|
370 | - [ |
|
371 | - 'inputFields' => $inputFields, |
|
372 | - 'outputFields' => [ |
|
373 | - lcfirst($this->name()) => [ |
|
374 | - 'type' => $this->name(), |
|
375 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
376 | - ], |
|
377 | - ], |
|
378 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
379 | - ] |
|
380 | - ); |
|
381 | - } |
|
365 | + // remove primary key from input. |
|
366 | + unset($inputFields['id']); |
|
367 | + // Register mutation to update an entity. |
|
368 | + register_graphql_mutation( |
|
369 | + 'create' . $this->name(), |
|
370 | + [ |
|
371 | + 'inputFields' => $inputFields, |
|
372 | + 'outputFields' => [ |
|
373 | + lcfirst($this->name()) => [ |
|
374 | + 'type' => $this->name(), |
|
375 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
376 | + ], |
|
377 | + ], |
|
378 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
379 | + ] |
|
380 | + ); |
|
381 | + } |
|
382 | 382 | } |
@@ -21,194 +21,194 @@ |
||
21 | 21 | class Venue extends TypeBase |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Venue constructor. |
|
26 | - * |
|
27 | - * @param EEM_Venue $venue_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Venue $venue_model) |
|
30 | - { |
|
31 | - $this->model = $venue_model; |
|
32 | - $this->setName($this->namespace . 'Venue'); |
|
33 | - $this->setIsCustomPostType(true); |
|
34 | - parent::__construct(); |
|
35 | - } |
|
24 | + /** |
|
25 | + * Venue constructor. |
|
26 | + * |
|
27 | + * @param EEM_Venue $venue_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Venue $venue_model) |
|
30 | + { |
|
31 | + $this->model = $venue_model; |
|
32 | + $this->setName($this->namespace . 'Venue'); |
|
33 | + $this->setIsCustomPostType(true); |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function getFields() |
|
43 | - { |
|
44 | - return [ |
|
45 | - new GraphQLOutputField( |
|
46 | - 'dbId', |
|
47 | - ['non_null' => 'Int'], |
|
48 | - 'ID', |
|
49 | - esc_html__('The venue ID.', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLOutputField( |
|
52 | - 'cacheId', |
|
53 | - ['non_null' => 'String'], |
|
54 | - null, |
|
55 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLField( |
|
58 | - 'name', |
|
59 | - 'String', |
|
60 | - 'name', |
|
61 | - esc_html__('Venue Name', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'desc', |
|
65 | - 'String', |
|
66 | - 'description', |
|
67 | - esc_html__('Venue Description', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLField( |
|
70 | - 'shortDesc', |
|
71 | - 'String', |
|
72 | - 'excerpt', |
|
73 | - esc_html__('Short Description of Venue', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLField( |
|
76 | - 'identifier', |
|
77 | - 'String', |
|
78 | - 'identifier', |
|
79 | - esc_html__('Venue Identifier', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLField( |
|
82 | - 'created', |
|
83 | - 'String', |
|
84 | - 'created', |
|
85 | - esc_html__('Date Venue Created', 'event_espresso') |
|
86 | - ), |
|
87 | - new GraphQLField( |
|
88 | - 'order', |
|
89 | - 'Int', |
|
90 | - 'order', |
|
91 | - esc_html__('Venue order', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLOutputField( |
|
94 | - 'wpUser', |
|
95 | - 'User', |
|
96 | - null, |
|
97 | - esc_html__('Venue Creator', 'event_espresso') |
|
98 | - ), |
|
99 | - new GraphQLInputField( |
|
100 | - 'wpUser', |
|
101 | - 'Int', |
|
102 | - null, |
|
103 | - esc_html__('Venue Creator ID', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'address', |
|
107 | - 'String', |
|
108 | - 'address', |
|
109 | - esc_html__('Venue Address line 1', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'address2', |
|
113 | - 'String', |
|
114 | - 'address2', |
|
115 | - esc_html__('Venue Address line 2', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'city', |
|
119 | - 'String', |
|
120 | - 'city', |
|
121 | - esc_html__('Venue City', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLOutputField( |
|
124 | - 'state', |
|
125 | - $this->namespace . 'State', |
|
126 | - null, |
|
127 | - esc_html__('Venue state', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLInputField( |
|
130 | - 'state', |
|
131 | - 'Int', |
|
132 | - null, |
|
133 | - esc_html__('State ID', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLOutputField( |
|
136 | - 'country', |
|
137 | - $this->namespace . 'Country', |
|
138 | - null, |
|
139 | - esc_html__('Venue country', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLInputField( |
|
142 | - 'country', |
|
143 | - 'String', |
|
144 | - null, |
|
145 | - esc_html__('Country ISO Code', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'zip', |
|
149 | - 'String', |
|
150 | - 'zip', |
|
151 | - esc_html__('Venue Zip/Postal Code', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'capacity', |
|
155 | - 'Int', |
|
156 | - 'capacity', |
|
157 | - esc_html__('Venue Capacity', 'event_espresso'), |
|
158 | - [$this, 'parseInfiniteValue'] |
|
159 | - ), |
|
160 | - new GraphQLField( |
|
161 | - 'phone', |
|
162 | - 'String', |
|
163 | - 'phone', |
|
164 | - esc_html__('Venue Phone', 'event_espresso') |
|
165 | - ), |
|
166 | - new GraphQLField( |
|
167 | - 'virtualPhone', |
|
168 | - 'String', |
|
169 | - 'virtual_phone', |
|
170 | - esc_html__('Call in Number', 'event_espresso') |
|
171 | - ), |
|
172 | - new GraphQLField( |
|
173 | - 'url', |
|
174 | - 'String', |
|
175 | - 'venue_url', |
|
176 | - esc_html__('Venue Website', 'event_espresso') |
|
177 | - ), |
|
178 | - new GraphQLField( |
|
179 | - 'virtualUrl', |
|
180 | - 'String', |
|
181 | - 'virtual_url', |
|
182 | - esc_html__('Virtual URL', 'event_espresso') |
|
183 | - ), |
|
184 | - new GraphQLField( |
|
185 | - 'googleMapLink', |
|
186 | - 'String', |
|
187 | - 'google_map_link', |
|
188 | - esc_html__('Google Map Link', 'event_espresso') |
|
189 | - ), |
|
190 | - new GraphQLField( |
|
191 | - 'enableForGmap', |
|
192 | - 'String', |
|
193 | - 'enable_for_gmap', |
|
194 | - esc_html__('Show Google Map?', 'event_espresso') |
|
195 | - ), |
|
196 | - ]; |
|
197 | - } |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function getFields() |
|
43 | + { |
|
44 | + return [ |
|
45 | + new GraphQLOutputField( |
|
46 | + 'dbId', |
|
47 | + ['non_null' => 'Int'], |
|
48 | + 'ID', |
|
49 | + esc_html__('The venue ID.', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLOutputField( |
|
52 | + 'cacheId', |
|
53 | + ['non_null' => 'String'], |
|
54 | + null, |
|
55 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLField( |
|
58 | + 'name', |
|
59 | + 'String', |
|
60 | + 'name', |
|
61 | + esc_html__('Venue Name', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'desc', |
|
65 | + 'String', |
|
66 | + 'description', |
|
67 | + esc_html__('Venue Description', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLField( |
|
70 | + 'shortDesc', |
|
71 | + 'String', |
|
72 | + 'excerpt', |
|
73 | + esc_html__('Short Description of Venue', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLField( |
|
76 | + 'identifier', |
|
77 | + 'String', |
|
78 | + 'identifier', |
|
79 | + esc_html__('Venue Identifier', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLField( |
|
82 | + 'created', |
|
83 | + 'String', |
|
84 | + 'created', |
|
85 | + esc_html__('Date Venue Created', 'event_espresso') |
|
86 | + ), |
|
87 | + new GraphQLField( |
|
88 | + 'order', |
|
89 | + 'Int', |
|
90 | + 'order', |
|
91 | + esc_html__('Venue order', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLOutputField( |
|
94 | + 'wpUser', |
|
95 | + 'User', |
|
96 | + null, |
|
97 | + esc_html__('Venue Creator', 'event_espresso') |
|
98 | + ), |
|
99 | + new GraphQLInputField( |
|
100 | + 'wpUser', |
|
101 | + 'Int', |
|
102 | + null, |
|
103 | + esc_html__('Venue Creator ID', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'address', |
|
107 | + 'String', |
|
108 | + 'address', |
|
109 | + esc_html__('Venue Address line 1', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'address2', |
|
113 | + 'String', |
|
114 | + 'address2', |
|
115 | + esc_html__('Venue Address line 2', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'city', |
|
119 | + 'String', |
|
120 | + 'city', |
|
121 | + esc_html__('Venue City', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLOutputField( |
|
124 | + 'state', |
|
125 | + $this->namespace . 'State', |
|
126 | + null, |
|
127 | + esc_html__('Venue state', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLInputField( |
|
130 | + 'state', |
|
131 | + 'Int', |
|
132 | + null, |
|
133 | + esc_html__('State ID', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLOutputField( |
|
136 | + 'country', |
|
137 | + $this->namespace . 'Country', |
|
138 | + null, |
|
139 | + esc_html__('Venue country', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLInputField( |
|
142 | + 'country', |
|
143 | + 'String', |
|
144 | + null, |
|
145 | + esc_html__('Country ISO Code', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'zip', |
|
149 | + 'String', |
|
150 | + 'zip', |
|
151 | + esc_html__('Venue Zip/Postal Code', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'capacity', |
|
155 | + 'Int', |
|
156 | + 'capacity', |
|
157 | + esc_html__('Venue Capacity', 'event_espresso'), |
|
158 | + [$this, 'parseInfiniteValue'] |
|
159 | + ), |
|
160 | + new GraphQLField( |
|
161 | + 'phone', |
|
162 | + 'String', |
|
163 | + 'phone', |
|
164 | + esc_html__('Venue Phone', 'event_espresso') |
|
165 | + ), |
|
166 | + new GraphQLField( |
|
167 | + 'virtualPhone', |
|
168 | + 'String', |
|
169 | + 'virtual_phone', |
|
170 | + esc_html__('Call in Number', 'event_espresso') |
|
171 | + ), |
|
172 | + new GraphQLField( |
|
173 | + 'url', |
|
174 | + 'String', |
|
175 | + 'venue_url', |
|
176 | + esc_html__('Venue Website', 'event_espresso') |
|
177 | + ), |
|
178 | + new GraphQLField( |
|
179 | + 'virtualUrl', |
|
180 | + 'String', |
|
181 | + 'virtual_url', |
|
182 | + esc_html__('Virtual URL', 'event_espresso') |
|
183 | + ), |
|
184 | + new GraphQLField( |
|
185 | + 'googleMapLink', |
|
186 | + 'String', |
|
187 | + 'google_map_link', |
|
188 | + esc_html__('Google Map Link', 'event_espresso') |
|
189 | + ), |
|
190 | + new GraphQLField( |
|
191 | + 'enableForGmap', |
|
192 | + 'String', |
|
193 | + 'enable_for_gmap', |
|
194 | + esc_html__('Show Google Map?', 'event_espresso') |
|
195 | + ), |
|
196 | + ]; |
|
197 | + } |
|
198 | 198 | |
199 | 199 | |
200 | - /** |
|
201 | - * Extends the existing WP GraphQL mutations. |
|
202 | - * |
|
203 | - * @since $VID:$ |
|
204 | - */ |
|
205 | - public function extendMutations() |
|
206 | - { |
|
207 | - add_action( |
|
208 | - 'graphql_post_object_mutation_update_additional_data', |
|
209 | - VenueUpdate::mutateFields($this->model, $this), |
|
210 | - 10, |
|
211 | - 6 |
|
212 | - ); |
|
213 | - } |
|
200 | + /** |
|
201 | + * Extends the existing WP GraphQL mutations. |
|
202 | + * |
|
203 | + * @since $VID:$ |
|
204 | + */ |
|
205 | + public function extendMutations() |
|
206 | + { |
|
207 | + add_action( |
|
208 | + 'graphql_post_object_mutation_update_additional_data', |
|
209 | + VenueUpdate::mutateFields($this->model, $this), |
|
210 | + 10, |
|
211 | + 6 |
|
212 | + ); |
|
213 | + } |
|
214 | 214 | } |
@@ -21,202 +21,202 @@ |
||
21 | 21 | class Event extends TypeBase |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * Event constructor. |
|
26 | - * |
|
27 | - * @param EEM_Event $event_model |
|
28 | - */ |
|
29 | - public function __construct(EEM_Event $event_model) |
|
30 | - { |
|
31 | - $this->model = $event_model; |
|
32 | - $this->setName($this->namespace . 'Event'); |
|
33 | - $this->setIsCustomPostType(true); |
|
34 | - parent::__construct(); |
|
35 | - } |
|
24 | + /** |
|
25 | + * Event constructor. |
|
26 | + * |
|
27 | + * @param EEM_Event $event_model |
|
28 | + */ |
|
29 | + public function __construct(EEM_Event $event_model) |
|
30 | + { |
|
31 | + $this->model = $event_model; |
|
32 | + $this->setName($this->namespace . 'Event'); |
|
33 | + $this->setIsCustomPostType(true); |
|
34 | + parent::__construct(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - * @since $VID:$ |
|
41 | - */ |
|
42 | - public function getFields() |
|
43 | - { |
|
44 | - return [ |
|
45 | - new GraphQLOutputField( |
|
46 | - 'dbId', |
|
47 | - ['non_null' => 'Int'], |
|
48 | - 'ID', |
|
49 | - esc_html__('The event ID.', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLOutputField( |
|
52 | - 'cacheId', |
|
53 | - ['non_null' => 'String'], |
|
54 | - null, |
|
55 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLField( |
|
58 | - 'name', |
|
59 | - 'String', |
|
60 | - 'name', |
|
61 | - esc_html__('Event Name', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLField( |
|
64 | - 'desc', |
|
65 | - 'String', |
|
66 | - 'description', |
|
67 | - esc_html__('Event Description', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLField( |
|
70 | - 'shortDesc', |
|
71 | - 'String', |
|
72 | - 'short_description', |
|
73 | - esc_html__('Event Short Description', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLField( |
|
76 | - 'created', |
|
77 | - 'String', |
|
78 | - 'created', |
|
79 | - esc_html__('Date/Time Event Created', 'event_espresso') |
|
80 | - ), |
|
81 | - new GraphQLOutputField( |
|
82 | - 'wpUser', |
|
83 | - 'User', |
|
84 | - null, |
|
85 | - esc_html__('Event Creator', 'event_espresso') |
|
86 | - ), |
|
87 | - new GraphQLInputField( |
|
88 | - 'wpUser', |
|
89 | - 'Int', |
|
90 | - null, |
|
91 | - esc_html__('Event Creator ID', 'event_espresso') |
|
92 | - ), |
|
93 | - new GraphQLField( |
|
94 | - 'order', |
|
95 | - 'Int', |
|
96 | - 'order', |
|
97 | - esc_html__('Event Menu Order', 'event_espresso') |
|
98 | - ), |
|
99 | - new GraphQLField( |
|
100 | - 'displayDesc', |
|
101 | - 'Boolean', |
|
102 | - 'display_description', |
|
103 | - esc_html__('Display Description Flag', 'event_espresso') |
|
104 | - ), |
|
105 | - new GraphQLField( |
|
106 | - 'displayTicketSelector', |
|
107 | - 'Boolean', |
|
108 | - 'display_ticket_selector', |
|
109 | - esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
110 | - ), |
|
111 | - new GraphQLField( |
|
112 | - 'visibleOn', |
|
113 | - 'String', |
|
114 | - 'visible_on', |
|
115 | - esc_html__('Event Visible Date', 'event_espresso') |
|
116 | - ), |
|
117 | - new GraphQLField( |
|
118 | - 'additionalLimit', |
|
119 | - 'Int', |
|
120 | - 'additional_limit', |
|
121 | - esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
122 | - ), |
|
123 | - new GraphQLField( |
|
124 | - 'phone', |
|
125 | - 'String', |
|
126 | - 'phone', |
|
127 | - esc_html__('Event Phone Number', 'event_espresso') |
|
128 | - ), |
|
129 | - new GraphQLField( |
|
130 | - 'memberOnly', |
|
131 | - 'Boolean', |
|
132 | - 'member_only', |
|
133 | - esc_html__('Member-Only Event Flag', 'event_espresso') |
|
134 | - ), |
|
135 | - new GraphQLField( |
|
136 | - 'allowOverflow', |
|
137 | - 'Boolean', |
|
138 | - 'allow_overflow', |
|
139 | - esc_html__('Allow Overflow on Event', 'event_espresso') |
|
140 | - ), |
|
141 | - new GraphQLField( |
|
142 | - 'timezoneString', |
|
143 | - 'String', |
|
144 | - 'timezone_string', |
|
145 | - esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
146 | - ), |
|
147 | - new GraphQLField( |
|
148 | - 'externalUrl', |
|
149 | - 'String', |
|
150 | - 'external_url', |
|
151 | - esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
152 | - ), |
|
153 | - new GraphQLField( |
|
154 | - 'donations', |
|
155 | - 'Boolean', |
|
156 | - 'donations', |
|
157 | - esc_html__('Accept Donations?', 'event_espresso') |
|
158 | - ), |
|
159 | - new GraphQLField( |
|
160 | - 'isSoldOut', |
|
161 | - 'Boolean', |
|
162 | - 'is_sold_out', |
|
163 | - esc_html__( |
|
164 | - 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
165 | - 'event_espresso' |
|
166 | - ) |
|
167 | - ), |
|
168 | - new GraphQLField( |
|
169 | - 'isPostponed', |
|
170 | - 'Boolean', |
|
171 | - 'is_postponed', |
|
172 | - esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
173 | - ), |
|
174 | - new GraphQLField( |
|
175 | - 'isCancelled', |
|
176 | - 'Boolean', |
|
177 | - 'is_cancelled', |
|
178 | - esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
179 | - ), |
|
180 | - new GraphQLOutputField( |
|
181 | - 'isUpcoming', |
|
182 | - 'Boolean', |
|
183 | - 'is_upcoming', |
|
184 | - esc_html__('Whether the event is upcoming', 'event_espresso') |
|
185 | - ), |
|
186 | - new GraphQLOutputField( |
|
187 | - 'isActive', |
|
188 | - 'Boolean', |
|
189 | - 'is_active', |
|
190 | - esc_html__('Flag indicating event is active', 'event_espresso') |
|
191 | - ), |
|
192 | - new GraphQLOutputField( |
|
193 | - 'isInactive', |
|
194 | - 'Boolean', |
|
195 | - 'is_inactive', |
|
196 | - esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
197 | - ), |
|
198 | - new GraphQLOutputField( |
|
199 | - 'isExpired', |
|
200 | - 'Boolean', |
|
201 | - 'is_expired', |
|
202 | - esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
203 | - ), |
|
204 | - ]; |
|
205 | - } |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + * @since $VID:$ |
|
41 | + */ |
|
42 | + public function getFields() |
|
43 | + { |
|
44 | + return [ |
|
45 | + new GraphQLOutputField( |
|
46 | + 'dbId', |
|
47 | + ['non_null' => 'Int'], |
|
48 | + 'ID', |
|
49 | + esc_html__('The event ID.', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLOutputField( |
|
52 | + 'cacheId', |
|
53 | + ['non_null' => 'String'], |
|
54 | + null, |
|
55 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLField( |
|
58 | + 'name', |
|
59 | + 'String', |
|
60 | + 'name', |
|
61 | + esc_html__('Event Name', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLField( |
|
64 | + 'desc', |
|
65 | + 'String', |
|
66 | + 'description', |
|
67 | + esc_html__('Event Description', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLField( |
|
70 | + 'shortDesc', |
|
71 | + 'String', |
|
72 | + 'short_description', |
|
73 | + esc_html__('Event Short Description', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLField( |
|
76 | + 'created', |
|
77 | + 'String', |
|
78 | + 'created', |
|
79 | + esc_html__('Date/Time Event Created', 'event_espresso') |
|
80 | + ), |
|
81 | + new GraphQLOutputField( |
|
82 | + 'wpUser', |
|
83 | + 'User', |
|
84 | + null, |
|
85 | + esc_html__('Event Creator', 'event_espresso') |
|
86 | + ), |
|
87 | + new GraphQLInputField( |
|
88 | + 'wpUser', |
|
89 | + 'Int', |
|
90 | + null, |
|
91 | + esc_html__('Event Creator ID', 'event_espresso') |
|
92 | + ), |
|
93 | + new GraphQLField( |
|
94 | + 'order', |
|
95 | + 'Int', |
|
96 | + 'order', |
|
97 | + esc_html__('Event Menu Order', 'event_espresso') |
|
98 | + ), |
|
99 | + new GraphQLField( |
|
100 | + 'displayDesc', |
|
101 | + 'Boolean', |
|
102 | + 'display_description', |
|
103 | + esc_html__('Display Description Flag', 'event_espresso') |
|
104 | + ), |
|
105 | + new GraphQLField( |
|
106 | + 'displayTicketSelector', |
|
107 | + 'Boolean', |
|
108 | + 'display_ticket_selector', |
|
109 | + esc_html__('Display Ticket Selector Flag', 'event_espresso') |
|
110 | + ), |
|
111 | + new GraphQLField( |
|
112 | + 'visibleOn', |
|
113 | + 'String', |
|
114 | + 'visible_on', |
|
115 | + esc_html__('Event Visible Date', 'event_espresso') |
|
116 | + ), |
|
117 | + new GraphQLField( |
|
118 | + 'additionalLimit', |
|
119 | + 'Int', |
|
120 | + 'additional_limit', |
|
121 | + esc_html__('Limit of Additional Registrations on Same Transaction', 'event_espresso') |
|
122 | + ), |
|
123 | + new GraphQLField( |
|
124 | + 'phone', |
|
125 | + 'String', |
|
126 | + 'phone', |
|
127 | + esc_html__('Event Phone Number', 'event_espresso') |
|
128 | + ), |
|
129 | + new GraphQLField( |
|
130 | + 'memberOnly', |
|
131 | + 'Boolean', |
|
132 | + 'member_only', |
|
133 | + esc_html__('Member-Only Event Flag', 'event_espresso') |
|
134 | + ), |
|
135 | + new GraphQLField( |
|
136 | + 'allowOverflow', |
|
137 | + 'Boolean', |
|
138 | + 'allow_overflow', |
|
139 | + esc_html__('Allow Overflow on Event', 'event_espresso') |
|
140 | + ), |
|
141 | + new GraphQLField( |
|
142 | + 'timezoneString', |
|
143 | + 'String', |
|
144 | + 'timezone_string', |
|
145 | + esc_html__('Timezone (name) for Event times', 'event_espresso') |
|
146 | + ), |
|
147 | + new GraphQLField( |
|
148 | + 'externalUrl', |
|
149 | + 'String', |
|
150 | + 'external_url', |
|
151 | + esc_html__('URL of Event Page if hosted elsewhere', 'event_espresso') |
|
152 | + ), |
|
153 | + new GraphQLField( |
|
154 | + 'donations', |
|
155 | + 'Boolean', |
|
156 | + 'donations', |
|
157 | + esc_html__('Accept Donations?', 'event_espresso') |
|
158 | + ), |
|
159 | + new GraphQLField( |
|
160 | + 'isSoldOut', |
|
161 | + 'Boolean', |
|
162 | + 'is_sold_out', |
|
163 | + esc_html__( |
|
164 | + 'Flag indicating whether the tickets sold for the event, met or exceed the registration limit', |
|
165 | + 'event_espresso' |
|
166 | + ) |
|
167 | + ), |
|
168 | + new GraphQLField( |
|
169 | + 'isPostponed', |
|
170 | + 'Boolean', |
|
171 | + 'is_postponed', |
|
172 | + esc_html__('Flag indicating whether the event is marked as postponed', 'event_espresso') |
|
173 | + ), |
|
174 | + new GraphQLField( |
|
175 | + 'isCancelled', |
|
176 | + 'Boolean', |
|
177 | + 'is_cancelled', |
|
178 | + esc_html__('Flag indicating whether the event is marked as cancelled', 'event_espresso') |
|
179 | + ), |
|
180 | + new GraphQLOutputField( |
|
181 | + 'isUpcoming', |
|
182 | + 'Boolean', |
|
183 | + 'is_upcoming', |
|
184 | + esc_html__('Whether the event is upcoming', 'event_espresso') |
|
185 | + ), |
|
186 | + new GraphQLOutputField( |
|
187 | + 'isActive', |
|
188 | + 'Boolean', |
|
189 | + 'is_active', |
|
190 | + esc_html__('Flag indicating event is active', 'event_espresso') |
|
191 | + ), |
|
192 | + new GraphQLOutputField( |
|
193 | + 'isInactive', |
|
194 | + 'Boolean', |
|
195 | + 'is_inactive', |
|
196 | + esc_html__('Flag indicating event is inactive', 'event_espresso') |
|
197 | + ), |
|
198 | + new GraphQLOutputField( |
|
199 | + 'isExpired', |
|
200 | + 'Boolean', |
|
201 | + 'is_expired', |
|
202 | + esc_html__('Flag indicating event is expired or not', 'event_espresso') |
|
203 | + ), |
|
204 | + ]; |
|
205 | + } |
|
206 | 206 | |
207 | 207 | |
208 | - /** |
|
209 | - * Extends the existing WP GraphQL mutations. |
|
210 | - * |
|
211 | - * @since $VID:$ |
|
212 | - */ |
|
213 | - public function extendMutations() |
|
214 | - { |
|
215 | - add_action( |
|
216 | - 'graphql_post_object_mutation_update_additional_data', |
|
217 | - EventUpdate::mutateFields($this->model, $this), |
|
218 | - 10, |
|
219 | - 6 |
|
220 | - ); |
|
221 | - } |
|
208 | + /** |
|
209 | + * Extends the existing WP GraphQL mutations. |
|
210 | + * |
|
211 | + * @since $VID:$ |
|
212 | + */ |
|
213 | + public function extendMutations() |
|
214 | + { |
|
215 | + add_action( |
|
216 | + 'graphql_post_object_mutation_update_additional_data', |
|
217 | + EventUpdate::mutateFields($this->model, $this), |
|
218 | + 10, |
|
219 | + 6 |
|
220 | + ); |
|
221 | + } |
|
222 | 222 | } |
@@ -19,115 +19,115 @@ |
||
19 | 19 | class Country extends TypeBase |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * Country constructor. |
|
24 | - * |
|
25 | - * @param EEM_Country $country_model |
|
26 | - */ |
|
27 | - public function __construct(EEM_Country $country_model) |
|
28 | - { |
|
29 | - $this->model = $country_model; |
|
30 | - $this->setName($this->namespace . 'Country'); |
|
31 | - $this->setDescription(__('A country', 'event_espresso')); |
|
32 | - $this->setIsCustomPostType(false); |
|
33 | - parent::__construct(); |
|
34 | - } |
|
22 | + /** |
|
23 | + * Country constructor. |
|
24 | + * |
|
25 | + * @param EEM_Country $country_model |
|
26 | + */ |
|
27 | + public function __construct(EEM_Country $country_model) |
|
28 | + { |
|
29 | + $this->model = $country_model; |
|
30 | + $this->setName($this->namespace . 'Country'); |
|
31 | + $this->setDescription(__('A country', 'event_espresso')); |
|
32 | + $this->setIsCustomPostType(false); |
|
33 | + parent::__construct(); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * @return GraphQLFieldInterface[] |
|
39 | - * @since $VID:$ |
|
40 | - */ |
|
41 | - public function getFields() |
|
42 | - { |
|
43 | - return [ |
|
44 | - new GraphQLField( |
|
45 | - 'id', |
|
46 | - ['non_null' => 'ID'], |
|
47 | - null, |
|
48 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
49 | - ), |
|
50 | - new GraphQLOutputField( |
|
51 | - 'cacheId', |
|
52 | - ['non_null' => 'String'], |
|
53 | - null, |
|
54 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'isActive', |
|
58 | - 'Boolean', |
|
59 | - null, // 'active', |
|
60 | - esc_html__( |
|
61 | - 'Flag that indicates if the country should appear in dropdown select lists', |
|
62 | - 'event_espresso' |
|
63 | - ) |
|
64 | - ), |
|
65 | - new GraphQLField( |
|
66 | - 'ISO', |
|
67 | - 'String', |
|
68 | - null, // 'ISO', |
|
69 | - esc_html__('Country ISO Code', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLField( |
|
72 | - 'ISO3', |
|
73 | - 'String', |
|
74 | - null, // 'ISO3', |
|
75 | - esc_html__('Country ISO3 Code', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLField( |
|
78 | - 'name', |
|
79 | - 'String', |
|
80 | - 'name', |
|
81 | - esc_html__('Country Name', 'event_espresso') |
|
82 | - ), |
|
83 | - new GraphQLField( |
|
84 | - 'currencyCode', |
|
85 | - 'String', |
|
86 | - 'currency_code', |
|
87 | - esc_html__('Country Currency Code', 'event_espresso') |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'currencySingular', |
|
91 | - 'String', |
|
92 | - 'currency_name_single', |
|
93 | - esc_html__('Currency Name Singular', 'event_espresso') |
|
94 | - ), |
|
95 | - new GraphQLField( |
|
96 | - 'currencyPlural', |
|
97 | - 'String', |
|
98 | - 'currency_name_plural', |
|
99 | - esc_html__('Currency Name Plural', 'event_espresso') |
|
100 | - ), |
|
101 | - new GraphQLField( |
|
102 | - 'currencySign', |
|
103 | - 'String', |
|
104 | - 'currency_sign', |
|
105 | - __('Currency Sign', 'event_espresso') |
|
106 | - ), |
|
107 | - new GraphQLField( |
|
108 | - 'currencySignBeforeNumber', |
|
109 | - 'String', |
|
110 | - 'currency_sign_before', |
|
111 | - esc_html__('Currency Sign Before Number', 'event_espresso') |
|
112 | - ), |
|
113 | - new GraphQLField( |
|
114 | - 'currencyDecimalPlaces', |
|
115 | - 'String', |
|
116 | - 'currency_decimal_places', |
|
117 | - esc_html__('Currency Decimal Places', 'event_espresso') |
|
118 | - ), |
|
119 | - new GraphQLField( |
|
120 | - 'currencyDecimalMark', |
|
121 | - 'String', |
|
122 | - 'currency_decimal_mark', |
|
123 | - esc_html__('Currency Decimal Mark', 'event_espresso') |
|
124 | - ), |
|
125 | - new GraphQLField( |
|
126 | - 'currencyThousandsSeparator', |
|
127 | - 'String', |
|
128 | - 'currency_thousands_separator', |
|
129 | - esc_html__('Currency Thousands Separator', 'event_espresso') |
|
130 | - ), |
|
131 | - ]; |
|
132 | - } |
|
37 | + /** |
|
38 | + * @return GraphQLFieldInterface[] |
|
39 | + * @since $VID:$ |
|
40 | + */ |
|
41 | + public function getFields() |
|
42 | + { |
|
43 | + return [ |
|
44 | + new GraphQLField( |
|
45 | + 'id', |
|
46 | + ['non_null' => 'ID'], |
|
47 | + null, |
|
48 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
49 | + ), |
|
50 | + new GraphQLOutputField( |
|
51 | + 'cacheId', |
|
52 | + ['non_null' => 'String'], |
|
53 | + null, |
|
54 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'isActive', |
|
58 | + 'Boolean', |
|
59 | + null, // 'active', |
|
60 | + esc_html__( |
|
61 | + 'Flag that indicates if the country should appear in dropdown select lists', |
|
62 | + 'event_espresso' |
|
63 | + ) |
|
64 | + ), |
|
65 | + new GraphQLField( |
|
66 | + 'ISO', |
|
67 | + 'String', |
|
68 | + null, // 'ISO', |
|
69 | + esc_html__('Country ISO Code', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLField( |
|
72 | + 'ISO3', |
|
73 | + 'String', |
|
74 | + null, // 'ISO3', |
|
75 | + esc_html__('Country ISO3 Code', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLField( |
|
78 | + 'name', |
|
79 | + 'String', |
|
80 | + 'name', |
|
81 | + esc_html__('Country Name', 'event_espresso') |
|
82 | + ), |
|
83 | + new GraphQLField( |
|
84 | + 'currencyCode', |
|
85 | + 'String', |
|
86 | + 'currency_code', |
|
87 | + esc_html__('Country Currency Code', 'event_espresso') |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'currencySingular', |
|
91 | + 'String', |
|
92 | + 'currency_name_single', |
|
93 | + esc_html__('Currency Name Singular', 'event_espresso') |
|
94 | + ), |
|
95 | + new GraphQLField( |
|
96 | + 'currencyPlural', |
|
97 | + 'String', |
|
98 | + 'currency_name_plural', |
|
99 | + esc_html__('Currency Name Plural', 'event_espresso') |
|
100 | + ), |
|
101 | + new GraphQLField( |
|
102 | + 'currencySign', |
|
103 | + 'String', |
|
104 | + 'currency_sign', |
|
105 | + __('Currency Sign', 'event_espresso') |
|
106 | + ), |
|
107 | + new GraphQLField( |
|
108 | + 'currencySignBeforeNumber', |
|
109 | + 'String', |
|
110 | + 'currency_sign_before', |
|
111 | + esc_html__('Currency Sign Before Number', 'event_espresso') |
|
112 | + ), |
|
113 | + new GraphQLField( |
|
114 | + 'currencyDecimalPlaces', |
|
115 | + 'String', |
|
116 | + 'currency_decimal_places', |
|
117 | + esc_html__('Currency Decimal Places', 'event_espresso') |
|
118 | + ), |
|
119 | + new GraphQLField( |
|
120 | + 'currencyDecimalMark', |
|
121 | + 'String', |
|
122 | + 'currency_decimal_mark', |
|
123 | + esc_html__('Currency Decimal Mark', 'event_espresso') |
|
124 | + ), |
|
125 | + new GraphQLField( |
|
126 | + 'currencyThousandsSeparator', |
|
127 | + 'String', |
|
128 | + 'currency_thousands_separator', |
|
129 | + esc_html__('Currency Thousands Separator', 'event_espresso') |
|
130 | + ), |
|
131 | + ]; |
|
132 | + } |
|
133 | 133 | } |
@@ -33,278 +33,278 @@ |
||
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 GraphQLOutputField( |
|
71 | - 'cacheId', |
|
72 | - ['non_null' => 'String'], |
|
73 | - null, |
|
74 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | - ), |
|
76 | - new GraphQLField( |
|
77 | - 'capacity', |
|
78 | - 'Int', |
|
79 | - 'reg_limit', |
|
80 | - esc_html__('Registration Limit for this time', 'event_espresso'), |
|
81 | - [$this, 'parseInfiniteValue'] |
|
82 | - ), |
|
83 | - new GraphQLField( |
|
84 | - 'description', |
|
85 | - 'String', |
|
86 | - 'description', |
|
87 | - esc_html__('Description for Datetime', 'event_espresso') |
|
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 GraphQLOutputField( |
|
97 | - 'event', |
|
98 | - $this->namespace . 'Event', |
|
99 | - null, |
|
100 | - esc_html__('Event of the datetime.', 'event_espresso') |
|
101 | - ), |
|
102 | - new GraphQLInputField( |
|
103 | - 'event', |
|
104 | - 'ID', |
|
105 | - null, |
|
106 | - esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
107 | - ), |
|
108 | - new GraphQLInputField( |
|
109 | - 'eventId', |
|
110 | - 'Int', |
|
111 | - null, |
|
112 | - esc_html__('Event ID of the datetime.', 'event_espresso') |
|
113 | - ), |
|
114 | - new GraphQLOutputField( |
|
115 | - 'isActive', |
|
116 | - 'Boolean', |
|
117 | - 'is_active', |
|
118 | - esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
119 | - ), |
|
120 | - new GraphQLOutputField( |
|
121 | - 'isExpired', |
|
122 | - 'Boolean', |
|
123 | - 'is_expired', |
|
124 | - esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
125 | - ), |
|
126 | - new GraphQLField( |
|
127 | - 'isPrimary', |
|
128 | - 'Boolean', |
|
129 | - 'is_primary', |
|
130 | - esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLOutputField( |
|
133 | - 'isSoldOut', |
|
134 | - 'Boolean', |
|
135 | - 'sold_out', |
|
136 | - esc_html__( |
|
137 | - 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
138 | - 'event_espresso' |
|
139 | - ) |
|
140 | - ), |
|
141 | - new GraphQLField( |
|
142 | - 'isTrashed', |
|
143 | - 'Boolean', |
|
144 | - null, |
|
145 | - esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
146 | - null, |
|
147 | - [$this, 'getIsTrashed'] |
|
148 | - ), |
|
149 | - new GraphQLOutputField( |
|
150 | - 'isUpcoming', |
|
151 | - 'Boolean', |
|
152 | - 'is_upcoming', |
|
153 | - esc_html__('Whether the date is upcoming', 'event_espresso') |
|
154 | - ), |
|
155 | - new GraphQLOutputField( |
|
156 | - 'length', |
|
157 | - 'Int', |
|
158 | - 'length', |
|
159 | - esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
160 | - ), |
|
161 | - new GraphQLField( |
|
162 | - 'name', |
|
163 | - 'String', |
|
164 | - 'name', |
|
165 | - esc_html__('Datetime Name', 'event_espresso') |
|
166 | - ), |
|
167 | - new GraphQLField( |
|
168 | - 'order', |
|
169 | - 'Int', |
|
170 | - 'order', |
|
171 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
172 | - ), |
|
173 | - new GraphQLOutputField( |
|
174 | - 'parent', |
|
175 | - $this->name(), |
|
176 | - null, |
|
177 | - esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
178 | - ), |
|
179 | - new GraphQLInputField( |
|
180 | - 'parent', |
|
181 | - 'ID', |
|
182 | - null, |
|
183 | - esc_html__('The parent datetime ID', 'event_espresso') |
|
184 | - ), |
|
185 | - new GraphQLField( |
|
186 | - 'reserved', |
|
187 | - 'Int', |
|
188 | - 'reserved', |
|
189 | - esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
190 | - ), |
|
191 | - new GraphQLField( |
|
192 | - 'startDate', |
|
193 | - 'String', |
|
194 | - 'start_date_and_time', |
|
195 | - esc_html__('Start date and time of the Event', 'event_espresso'), |
|
196 | - [$this, 'formatDatetime'] |
|
197 | - ), |
|
198 | - new GraphQLField( |
|
199 | - 'sold', |
|
200 | - 'Int', |
|
201 | - 'sold', |
|
202 | - esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
203 | - ), |
|
204 | - new GraphQLOutputField( |
|
205 | - 'status', |
|
206 | - $this->namespace . 'DatetimeStatusEnum', |
|
207 | - 'get_active_status', |
|
208 | - esc_html__('Datetime status', 'event_espresso') |
|
209 | - ), |
|
210 | - new GraphQLInputField( |
|
211 | - 'tickets', |
|
212 | - ['list_of' => 'ID'], |
|
213 | - null, |
|
214 | - sprintf( |
|
215 | - '%1$s %2$s', |
|
216 | - esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
217 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
218 | - ) |
|
219 | - ), |
|
220 | - ]; |
|
221 | - } |
|
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 GraphQLOutputField( |
|
71 | + 'cacheId', |
|
72 | + ['non_null' => 'String'], |
|
73 | + null, |
|
74 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
75 | + ), |
|
76 | + new GraphQLField( |
|
77 | + 'capacity', |
|
78 | + 'Int', |
|
79 | + 'reg_limit', |
|
80 | + esc_html__('Registration Limit for this time', 'event_espresso'), |
|
81 | + [$this, 'parseInfiniteValue'] |
|
82 | + ), |
|
83 | + new GraphQLField( |
|
84 | + 'description', |
|
85 | + 'String', |
|
86 | + 'description', |
|
87 | + esc_html__('Description for Datetime', 'event_espresso') |
|
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 GraphQLOutputField( |
|
97 | + 'event', |
|
98 | + $this->namespace . 'Event', |
|
99 | + null, |
|
100 | + esc_html__('Event of the datetime.', 'event_espresso') |
|
101 | + ), |
|
102 | + new GraphQLInputField( |
|
103 | + 'event', |
|
104 | + 'ID', |
|
105 | + null, |
|
106 | + esc_html__('Globally unique event ID of the datetime.', 'event_espresso') |
|
107 | + ), |
|
108 | + new GraphQLInputField( |
|
109 | + 'eventId', |
|
110 | + 'Int', |
|
111 | + null, |
|
112 | + esc_html__('Event ID of the datetime.', 'event_espresso') |
|
113 | + ), |
|
114 | + new GraphQLOutputField( |
|
115 | + 'isActive', |
|
116 | + 'Boolean', |
|
117 | + 'is_active', |
|
118 | + esc_html__('Flag indicating datetime is active', 'event_espresso') |
|
119 | + ), |
|
120 | + new GraphQLOutputField( |
|
121 | + 'isExpired', |
|
122 | + 'Boolean', |
|
123 | + 'is_expired', |
|
124 | + esc_html__('Flag indicating datetime is expired or not', 'event_espresso') |
|
125 | + ), |
|
126 | + new GraphQLField( |
|
127 | + 'isPrimary', |
|
128 | + 'Boolean', |
|
129 | + 'is_primary', |
|
130 | + esc_html__('Flag indicating datetime is primary one for event', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLOutputField( |
|
133 | + 'isSoldOut', |
|
134 | + 'Boolean', |
|
135 | + 'sold_out', |
|
136 | + esc_html__( |
|
137 | + 'Flag indicating whether the tickets sold for this datetime, met or exceed the registration limit', |
|
138 | + 'event_espresso' |
|
139 | + ) |
|
140 | + ), |
|
141 | + new GraphQLField( |
|
142 | + 'isTrashed', |
|
143 | + 'Boolean', |
|
144 | + null, |
|
145 | + esc_html__('Flag indicating datetime has been trashed.', 'event_espresso'), |
|
146 | + null, |
|
147 | + [$this, 'getIsTrashed'] |
|
148 | + ), |
|
149 | + new GraphQLOutputField( |
|
150 | + 'isUpcoming', |
|
151 | + 'Boolean', |
|
152 | + 'is_upcoming', |
|
153 | + esc_html__('Whether the date is upcoming', 'event_espresso') |
|
154 | + ), |
|
155 | + new GraphQLOutputField( |
|
156 | + 'length', |
|
157 | + 'Int', |
|
158 | + 'length', |
|
159 | + esc_html__('The length of the event (start to end time) in seconds', 'event_espresso') |
|
160 | + ), |
|
161 | + new GraphQLField( |
|
162 | + 'name', |
|
163 | + 'String', |
|
164 | + 'name', |
|
165 | + esc_html__('Datetime Name', 'event_espresso') |
|
166 | + ), |
|
167 | + new GraphQLField( |
|
168 | + 'order', |
|
169 | + 'Int', |
|
170 | + 'order', |
|
171 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
172 | + ), |
|
173 | + new GraphQLOutputField( |
|
174 | + 'parent', |
|
175 | + $this->name(), |
|
176 | + null, |
|
177 | + esc_html__('The parent datetime of the current datetime', 'event_espresso') |
|
178 | + ), |
|
179 | + new GraphQLInputField( |
|
180 | + 'parent', |
|
181 | + 'ID', |
|
182 | + null, |
|
183 | + esc_html__('The parent datetime ID', 'event_espresso') |
|
184 | + ), |
|
185 | + new GraphQLField( |
|
186 | + 'reserved', |
|
187 | + 'Int', |
|
188 | + 'reserved', |
|
189 | + esc_html__('Quantity of tickets reserved, but not yet fully purchased', 'event_espresso') |
|
190 | + ), |
|
191 | + new GraphQLField( |
|
192 | + 'startDate', |
|
193 | + 'String', |
|
194 | + 'start_date_and_time', |
|
195 | + esc_html__('Start date and time of the Event', 'event_espresso'), |
|
196 | + [$this, 'formatDatetime'] |
|
197 | + ), |
|
198 | + new GraphQLField( |
|
199 | + 'sold', |
|
200 | + 'Int', |
|
201 | + 'sold', |
|
202 | + esc_html__('How many sales for this Datetime that have occurred', 'event_espresso') |
|
203 | + ), |
|
204 | + new GraphQLOutputField( |
|
205 | + 'status', |
|
206 | + $this->namespace . 'DatetimeStatusEnum', |
|
207 | + 'get_active_status', |
|
208 | + esc_html__('Datetime status', 'event_espresso') |
|
209 | + ), |
|
210 | + new GraphQLInputField( |
|
211 | + 'tickets', |
|
212 | + ['list_of' => 'ID'], |
|
213 | + null, |
|
214 | + sprintf( |
|
215 | + '%1$s %2$s', |
|
216 | + esc_html__('Globally unique IDs of the tickets related to the datetime.', 'event_espresso'), |
|
217 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
218 | + ) |
|
219 | + ), |
|
220 | + ]; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | |
224 | - /** |
|
225 | - * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
226 | - * @param array $args The inputArgs on the field |
|
227 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
228 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
229 | - * @return string |
|
230 | - * @throws Exception |
|
231 | - * @throws InvalidArgumentException |
|
232 | - * @throws InvalidDataTypeException |
|
233 | - * @throws InvalidInterfaceException |
|
234 | - * @throws ReflectionException |
|
235 | - * @throws UserError |
|
236 | - * @throws UnexpectedEntityException |
|
237 | - * @since $VID:$ |
|
238 | - */ |
|
239 | - public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
240 | - { |
|
241 | - return (bool) $source->get('DTT_deleted'); |
|
242 | - } |
|
224 | + /** |
|
225 | + * @param EE_Datetime $source The source that's passed down the GraphQL queries |
|
226 | + * @param array $args The inputArgs on the field |
|
227 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
228 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
229 | + * @return string |
|
230 | + * @throws Exception |
|
231 | + * @throws InvalidArgumentException |
|
232 | + * @throws InvalidDataTypeException |
|
233 | + * @throws InvalidInterfaceException |
|
234 | + * @throws ReflectionException |
|
235 | + * @throws UserError |
|
236 | + * @throws UnexpectedEntityException |
|
237 | + * @since $VID:$ |
|
238 | + */ |
|
239 | + public function getIsTrashed(EE_Datetime $source, array $args, AppContext $context, ResolveInfo $info) |
|
240 | + { |
|
241 | + return (bool) $source->get('DTT_deleted'); |
|
242 | + } |
|
243 | 243 | |
244 | 244 | |
245 | - /** |
|
246 | - * @param array $inputFields The mutation input fields. |
|
247 | - * @throws InvalidArgumentException |
|
248 | - * @throws ReflectionException |
|
249 | - * @since $VID:$ |
|
250 | - */ |
|
251 | - public function registerMutations(array $inputFields) |
|
252 | - { |
|
253 | - // Register mutation to update an entity. |
|
254 | - register_graphql_mutation( |
|
255 | - 'update' . $this->name(), |
|
256 | - [ |
|
257 | - 'inputFields' => $inputFields, |
|
258 | - 'outputFields' => [ |
|
259 | - lcfirst($this->name()) => [ |
|
260 | - 'type' => $this->name(), |
|
261 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
262 | - ], |
|
263 | - ], |
|
264 | - 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
265 | - ] |
|
266 | - ); |
|
267 | - // Register mutation to delete an entity. |
|
268 | - register_graphql_mutation( |
|
269 | - 'delete' . $this->name(), |
|
270 | - [ |
|
271 | - 'inputFields' => [ |
|
272 | - 'id' => $inputFields['id'], |
|
273 | - 'deletePermanently' => [ |
|
274 | - 'type' => 'Boolean', |
|
275 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
276 | - ], |
|
277 | - ], |
|
278 | - 'outputFields' => [ |
|
279 | - lcfirst($this->name()) => [ |
|
280 | - 'type' => $this->name(), |
|
281 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
282 | - 'resolve' => static function ($payload) { |
|
283 | - $deleted = (object) $payload['deleted']; |
|
245 | + /** |
|
246 | + * @param array $inputFields The mutation input fields. |
|
247 | + * @throws InvalidArgumentException |
|
248 | + * @throws ReflectionException |
|
249 | + * @since $VID:$ |
|
250 | + */ |
|
251 | + public function registerMutations(array $inputFields) |
|
252 | + { |
|
253 | + // Register mutation to update an entity. |
|
254 | + register_graphql_mutation( |
|
255 | + 'update' . $this->name(), |
|
256 | + [ |
|
257 | + 'inputFields' => $inputFields, |
|
258 | + 'outputFields' => [ |
|
259 | + lcfirst($this->name()) => [ |
|
260 | + 'type' => $this->name(), |
|
261 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
262 | + ], |
|
263 | + ], |
|
264 | + 'mutateAndGetPayload' => DatetimeUpdate::mutateAndGetPayload($this->model, $this), |
|
265 | + ] |
|
266 | + ); |
|
267 | + // Register mutation to delete an entity. |
|
268 | + register_graphql_mutation( |
|
269 | + 'delete' . $this->name(), |
|
270 | + [ |
|
271 | + 'inputFields' => [ |
|
272 | + 'id' => $inputFields['id'], |
|
273 | + 'deletePermanently' => [ |
|
274 | + 'type' => 'Boolean', |
|
275 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
276 | + ], |
|
277 | + ], |
|
278 | + 'outputFields' => [ |
|
279 | + lcfirst($this->name()) => [ |
|
280 | + 'type' => $this->name(), |
|
281 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
282 | + 'resolve' => static function ($payload) { |
|
283 | + $deleted = (object) $payload['deleted']; |
|
284 | 284 | |
285 | - return ! empty($deleted) ? $deleted : null; |
|
286 | - }, |
|
287 | - ], |
|
288 | - ], |
|
289 | - 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
290 | - ] |
|
291 | - ); |
|
285 | + return ! empty($deleted) ? $deleted : null; |
|
286 | + }, |
|
287 | + ], |
|
288 | + ], |
|
289 | + 'mutateAndGetPayload' => DatetimeDelete::mutateAndGetPayload($this->model, $this), |
|
290 | + ] |
|
291 | + ); |
|
292 | 292 | |
293 | - // remove primary key from input. |
|
294 | - unset($inputFields['id']); |
|
295 | - // Register mutation to update an entity. |
|
296 | - register_graphql_mutation( |
|
297 | - 'create' . $this->name(), |
|
298 | - [ |
|
299 | - 'inputFields' => $inputFields, |
|
300 | - 'outputFields' => [ |
|
301 | - lcfirst($this->name()) => [ |
|
302 | - 'type' => $this->name(), |
|
303 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
304 | - ], |
|
305 | - ], |
|
306 | - 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
307 | - ] |
|
308 | - ); |
|
309 | - } |
|
293 | + // remove primary key from input. |
|
294 | + unset($inputFields['id']); |
|
295 | + // Register mutation to update an entity. |
|
296 | + register_graphql_mutation( |
|
297 | + 'create' . $this->name(), |
|
298 | + [ |
|
299 | + 'inputFields' => $inputFields, |
|
300 | + 'outputFields' => [ |
|
301 | + lcfirst($this->name()) => [ |
|
302 | + 'type' => $this->name(), |
|
303 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
304 | + ], |
|
305 | + ], |
|
306 | + 'mutateAndGetPayload' => DatetimeCreate::mutateAndGetPayload($this->model, $this), |
|
307 | + ] |
|
308 | + ); |
|
309 | + } |
|
310 | 310 | } |
@@ -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 | - 'amount', |
|
64 | - 'Float', |
|
65 | - 'amount', |
|
66 | - esc_html__('Price Amount', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLOutputField( |
|
69 | - 'cacheId', |
|
70 | - ['non_null' => 'String'], |
|
71 | - null, |
|
72 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'desc', |
|
76 | - 'String', |
|
77 | - 'desc', |
|
78 | - esc_html__('Price description', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLOutputField( |
|
81 | - 'isBasePrice', |
|
82 | - 'Boolean', |
|
83 | - 'is_base_price', |
|
84 | - esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLField( |
|
87 | - 'isDefault', |
|
88 | - 'Boolean', |
|
89 | - 'is_default', |
|
90 | - esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
91 | - ), |
|
92 | - new GraphQLOutputField( |
|
93 | - 'isDiscount', |
|
94 | - 'Boolean', |
|
95 | - 'is_discount', |
|
96 | - esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
97 | - ), |
|
98 | - new GraphQLOutputField( |
|
99 | - 'isPercent', |
|
100 | - 'Boolean', |
|
101 | - 'is_percent', |
|
102 | - esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLOutputField( |
|
105 | - 'isTax', |
|
106 | - 'Boolean', |
|
107 | - 'is_tax', |
|
108 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
109 | - ), |
|
110 | - new GraphQLField( |
|
111 | - 'isTrashed', |
|
112 | - 'Boolean', |
|
113 | - 'deleted', |
|
114 | - esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLField( |
|
117 | - 'name', |
|
118 | - 'String', |
|
119 | - 'name', |
|
120 | - esc_html__('Price Name', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLField( |
|
123 | - 'order', |
|
124 | - 'Int', |
|
125 | - 'order', |
|
126 | - esc_html__('Order of Application of Price.', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLField( |
|
129 | - 'overrides', |
|
130 | - 'Int', |
|
131 | - 'overrides', |
|
132 | - esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLOutputField( |
|
135 | - 'parent', |
|
136 | - $this->name(), |
|
137 | - null, |
|
138 | - esc_html__('The parent price of the current price', 'event_espresso') |
|
139 | - ), |
|
140 | - new GraphQLInputField( |
|
141 | - 'parent', |
|
142 | - 'ID', |
|
143 | - null, |
|
144 | - esc_html__('The parent price ID', 'event_espresso') |
|
145 | - ), |
|
146 | - new GraphQLOutputField( |
|
147 | - 'priceType', |
|
148 | - $this->namespace . 'PriceType', |
|
149 | - 'type_obj', |
|
150 | - esc_html__('The related price type object.', 'event_espresso') |
|
151 | - ), |
|
152 | - new GraphQLInputField( |
|
153 | - 'priceType', |
|
154 | - 'ID', |
|
155 | - null, |
|
156 | - esc_html__('The price type ID', '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 | + 'amount', |
|
64 | + 'Float', |
|
65 | + 'amount', |
|
66 | + esc_html__('Price Amount', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLOutputField( |
|
69 | + 'cacheId', |
|
70 | + ['non_null' => 'String'], |
|
71 | + null, |
|
72 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'desc', |
|
76 | + 'String', |
|
77 | + 'desc', |
|
78 | + esc_html__('Price description', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLOutputField( |
|
81 | + 'isBasePrice', |
|
82 | + 'Boolean', |
|
83 | + 'is_base_price', |
|
84 | + esc_html__('Flag indicating price is a base price type.', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLField( |
|
87 | + 'isDefault', |
|
88 | + 'Boolean', |
|
89 | + 'is_default', |
|
90 | + esc_html__('Flag indicating price is the default one.', 'event_espresso') |
|
91 | + ), |
|
92 | + new GraphQLOutputField( |
|
93 | + 'isDiscount', |
|
94 | + 'Boolean', |
|
95 | + 'is_discount', |
|
96 | + esc_html__('Flag indicating price is a discount.', 'event_espresso') |
|
97 | + ), |
|
98 | + new GraphQLOutputField( |
|
99 | + 'isPercent', |
|
100 | + 'Boolean', |
|
101 | + 'is_percent', |
|
102 | + esc_html__('Flag indicating price is a percentage.', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLOutputField( |
|
105 | + 'isTax', |
|
106 | + 'Boolean', |
|
107 | + 'is_tax', |
|
108 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
109 | + ), |
|
110 | + new GraphQLField( |
|
111 | + 'isTrashed', |
|
112 | + 'Boolean', |
|
113 | + 'deleted', |
|
114 | + esc_html__('Flag indicating price has been trashed.', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLField( |
|
117 | + 'name', |
|
118 | + 'String', |
|
119 | + 'name', |
|
120 | + esc_html__('Price Name', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLField( |
|
123 | + 'order', |
|
124 | + 'Int', |
|
125 | + 'order', |
|
126 | + esc_html__('Order of Application of Price.', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLField( |
|
129 | + 'overrides', |
|
130 | + 'Int', |
|
131 | + 'overrides', |
|
132 | + esc_html__('Price ID for a global Price that will be overridden by this Price.', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLOutputField( |
|
135 | + 'parent', |
|
136 | + $this->name(), |
|
137 | + null, |
|
138 | + esc_html__('The parent price of the current price', 'event_espresso') |
|
139 | + ), |
|
140 | + new GraphQLInputField( |
|
141 | + 'parent', |
|
142 | + 'ID', |
|
143 | + null, |
|
144 | + esc_html__('The parent price ID', 'event_espresso') |
|
145 | + ), |
|
146 | + new GraphQLOutputField( |
|
147 | + 'priceType', |
|
148 | + $this->namespace . 'PriceType', |
|
149 | + 'type_obj', |
|
150 | + esc_html__('The related price type object.', 'event_espresso') |
|
151 | + ), |
|
152 | + new GraphQLInputField( |
|
153 | + 'priceType', |
|
154 | + 'ID', |
|
155 | + null, |
|
156 | + esc_html__('The price type ID', '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 | } |