@@ -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 | - $assetsUrl = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
173 | - |
|
174 | - return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assetsUrl'); |
|
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 | + $assetsUrl = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
173 | + |
|
174 | + return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assetsUrl'); |
|
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 { |
@@ -282,31 +282,31 @@ discard block |
||
282 | 282 | } |
283 | 283 | } |
284 | 284 | QUERY; |
285 | - $data = [ |
|
286 | - 'operation_name' => 'GET_DATETIMES', |
|
287 | - 'variables' => [ |
|
288 | - 'first' => 100, |
|
289 | - 'where' => [ |
|
290 | - 'eventId' => $eventId, |
|
291 | - ], |
|
292 | - ], |
|
293 | - 'query' => $query, |
|
294 | - ]; |
|
295 | - |
|
296 | - $responseData = $this->makeGraphQLRequest($data); |
|
297 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * @param array $datetimeIn |
|
303 | - * @return array|null |
|
304 | - * @since $VID:$ |
|
305 | - */ |
|
306 | - protected function getGraphQLTickets(array $datetimeIn) |
|
307 | - { |
|
308 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
309 | - $query = <<<QUERY |
|
285 | + $data = [ |
|
286 | + 'operation_name' => 'GET_DATETIMES', |
|
287 | + 'variables' => [ |
|
288 | + 'first' => 100, |
|
289 | + 'where' => [ |
|
290 | + 'eventId' => $eventId, |
|
291 | + ], |
|
292 | + ], |
|
293 | + 'query' => $query, |
|
294 | + ]; |
|
295 | + |
|
296 | + $responseData = $this->makeGraphQLRequest($data); |
|
297 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * @param array $datetimeIn |
|
303 | + * @return array|null |
|
304 | + * @since $VID:$ |
|
305 | + */ |
|
306 | + protected function getGraphQLTickets(array $datetimeIn) |
|
307 | + { |
|
308 | + $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
309 | + $query = <<<QUERY |
|
310 | 310 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) { |
311 | 311 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
312 | 312 | nodes { |
@@ -341,31 +341,31 @@ discard block |
||
341 | 341 | } |
342 | 342 | } |
343 | 343 | QUERY; |
344 | - $data = [ |
|
345 | - 'operation_name' => 'GET_TICKETS', |
|
346 | - 'variables' => [ |
|
347 | - 'first' => 100, |
|
348 | - 'where' => [ |
|
349 | - 'datetimeIn' => $datetimeIn, |
|
350 | - ], |
|
351 | - ], |
|
352 | - 'query' => $query, |
|
353 | - ]; |
|
354 | - |
|
355 | - $responseData = $this->makeGraphQLRequest($data); |
|
356 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - /** |
|
361 | - * @param array $ticketIn |
|
362 | - * @return array|null |
|
363 | - * @since $VID:$ |
|
364 | - */ |
|
365 | - protected function getGraphQLPrices(array $ticketIn) |
|
366 | - { |
|
367 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
368 | - $query = <<<QUERY |
|
344 | + $data = [ |
|
345 | + 'operation_name' => 'GET_TICKETS', |
|
346 | + 'variables' => [ |
|
347 | + 'first' => 100, |
|
348 | + 'where' => [ |
|
349 | + 'datetimeIn' => $datetimeIn, |
|
350 | + ], |
|
351 | + ], |
|
352 | + 'query' => $query, |
|
353 | + ]; |
|
354 | + |
|
355 | + $responseData = $this->makeGraphQLRequest($data); |
|
356 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + /** |
|
361 | + * @param array $ticketIn |
|
362 | + * @return array|null |
|
363 | + * @since $VID:$ |
|
364 | + */ |
|
365 | + protected function getGraphQLPrices(array $ticketIn) |
|
366 | + { |
|
367 | + $field_key = lcfirst($this->namespace) . 'Prices'; |
|
368 | + $query = <<<QUERY |
|
369 | 369 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
370 | 370 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
371 | 371 | nodes { |
@@ -389,30 +389,30 @@ discard block |
||
389 | 389 | } |
390 | 390 | } |
391 | 391 | QUERY; |
392 | - $data = [ |
|
393 | - 'operation_name' => 'GET_PRICES', |
|
394 | - 'variables' => [ |
|
395 | - 'first' => 100, |
|
396 | - 'where' => [ |
|
397 | - 'ticketIn' => $ticketIn, |
|
398 | - ], |
|
399 | - ], |
|
400 | - 'query' => $query, |
|
401 | - ]; |
|
402 | - |
|
403 | - $responseData = $this->makeGraphQLRequest($data); |
|
404 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
405 | - } |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * @return array|null |
|
410 | - * @since $VID:$ |
|
411 | - */ |
|
412 | - protected function getGraphQLPriceTypes() |
|
413 | - { |
|
414 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
415 | - $query = <<<QUERY |
|
392 | + $data = [ |
|
393 | + 'operation_name' => 'GET_PRICES', |
|
394 | + 'variables' => [ |
|
395 | + 'first' => 100, |
|
396 | + 'where' => [ |
|
397 | + 'ticketIn' => $ticketIn, |
|
398 | + ], |
|
399 | + ], |
|
400 | + 'query' => $query, |
|
401 | + ]; |
|
402 | + |
|
403 | + $responseData = $this->makeGraphQLRequest($data); |
|
404 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
405 | + } |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * @return array|null |
|
410 | + * @since $VID:$ |
|
411 | + */ |
|
412 | + protected function getGraphQLPriceTypes() |
|
413 | + { |
|
414 | + $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
415 | + $query = <<<QUERY |
|
416 | 416 | query GET_PRICE_TYPES(\$first: Int, \$last: Int ) { |
417 | 417 | {$field_key}(first: \$first, last: \$last) { |
418 | 418 | nodes { |
@@ -433,27 +433,27 @@ discard block |
||
433 | 433 | } |
434 | 434 | } |
435 | 435 | QUERY; |
436 | - $data = [ |
|
437 | - 'operation_name' => 'GET_PRICE_TYPES', |
|
438 | - 'variables' => [ |
|
439 | - 'first' => 100, |
|
440 | - ], |
|
441 | - 'query' => $query, |
|
442 | - ]; |
|
443 | - |
|
444 | - $responseData = $this->makeGraphQLRequest($data); |
|
445 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * @return array|null |
|
451 | - * @since $VID:$ |
|
452 | - */ |
|
453 | - protected function getGraphQLCurrentUser() |
|
454 | - { |
|
455 | - $field_key = 'viewer'; |
|
456 | - $query = <<<QUERY |
|
436 | + $data = [ |
|
437 | + 'operation_name' => 'GET_PRICE_TYPES', |
|
438 | + 'variables' => [ |
|
439 | + 'first' => 100, |
|
440 | + ], |
|
441 | + 'query' => $query, |
|
442 | + ]; |
|
443 | + |
|
444 | + $responseData = $this->makeGraphQLRequest($data); |
|
445 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * @return array|null |
|
451 | + * @since $VID:$ |
|
452 | + */ |
|
453 | + protected function getGraphQLCurrentUser() |
|
454 | + { |
|
455 | + $field_key = 'viewer'; |
|
456 | + $query = <<<QUERY |
|
457 | 457 | query GET_CURRENT_USER { |
458 | 458 | {$field_key} { |
459 | 459 | description |
@@ -471,24 +471,24 @@ discard block |
||
471 | 471 | } |
472 | 472 | } |
473 | 473 | QUERY; |
474 | - $data = [ |
|
475 | - 'operation_name' => 'GET_CURRENT_USER', |
|
476 | - 'query' => $query, |
|
477 | - ]; |
|
478 | - |
|
479 | - $responseData = $this->makeGraphQLRequest($data); |
|
480 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * @return array|null |
|
486 | - * @since $VID:$ |
|
487 | - */ |
|
488 | - protected function getGraphQLGeneralSettings() |
|
489 | - { |
|
490 | - $field_key = 'generalSettings'; |
|
491 | - $query = <<<QUERY |
|
474 | + $data = [ |
|
475 | + 'operation_name' => 'GET_CURRENT_USER', |
|
476 | + 'query' => $query, |
|
477 | + ]; |
|
478 | + |
|
479 | + $responseData = $this->makeGraphQLRequest($data); |
|
480 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * @return array|null |
|
486 | + * @since $VID:$ |
|
487 | + */ |
|
488 | + protected function getGraphQLGeneralSettings() |
|
489 | + { |
|
490 | + $field_key = 'generalSettings'; |
|
491 | + $query = <<<QUERY |
|
492 | 492 | query GET_GENERAL_SETTINGS { |
493 | 493 | {$field_key} { |
494 | 494 | dateFormat |
@@ -498,166 +498,166 @@ discard block |
||
498 | 498 | } |
499 | 499 | } |
500 | 500 | QUERY; |
501 | - $data = [ |
|
502 | - 'operation_name' => 'GET_CURRENT_USER', |
|
503 | - 'query' => $query, |
|
504 | - ]; |
|
505 | - |
|
506 | - $responseData = $this->makeGraphQLRequest($data); |
|
507 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
508 | - } |
|
509 | - |
|
510 | - |
|
511 | - /** |
|
512 | - * @param array $data |
|
513 | - * @return array |
|
514 | - * @since $VID:$ |
|
515 | - */ |
|
516 | - protected function makeGraphQLRequest($data) |
|
517 | - { |
|
518 | - try { |
|
519 | - $response = graphql($data); |
|
520 | - if (!empty($response['data'])) { |
|
521 | - return $response['data']; |
|
522 | - } |
|
523 | - return null; |
|
524 | - } catch (\Exception $e) { |
|
525 | - // do something with the errors thrown |
|
526 | - return null; |
|
527 | - } |
|
528 | - } |
|
529 | - |
|
530 | - |
|
531 | - /** |
|
532 | - * @param mixed $source The source that's passed down the GraphQL queries |
|
533 | - * @param array $args The inputArgs on the field |
|
534 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
535 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
536 | - * @return string |
|
537 | - * @throws EE_Error |
|
538 | - * @throws Exception |
|
539 | - * @throws InvalidArgumentException |
|
540 | - * @throws InvalidDataTypeException |
|
541 | - * @throws InvalidInterfaceException |
|
542 | - * @throws ReflectionException |
|
543 | - * @throws UserError |
|
544 | - * @throws UnexpectedEntityException |
|
545 | - * @since $VID:$ |
|
546 | - */ |
|
547 | - public static function getRelationalData($eventId) |
|
548 | - { |
|
549 | - $data = [ |
|
550 | - 'datetimes' => [], |
|
551 | - 'tickets' => [], |
|
552 | - 'prices' => [], |
|
553 | - ]; |
|
554 | - |
|
555 | - $eem_datetime = EEM_Datetime::instance(); |
|
556 | - $eem_ticket = EEM_Ticket::instance(); |
|
557 | - $eem_price = EEM_Price::instance(); |
|
558 | - $eem_price_type = EEM_Price_Type::instance(); |
|
559 | - |
|
560 | - // PROCESS DATETIMES |
|
561 | - $related_models = [ |
|
562 | - 'tickets' => $eem_ticket, |
|
563 | - ]; |
|
564 | - // Get the IDs of event datetimes. |
|
565 | - $datetimeIds = $eem_datetime->get_col([[ |
|
566 | - 'EVT_ID' => $eventId, |
|
567 | - 'DTT_deleted' => ['IN', [true, false]], |
|
568 | - ]]); |
|
569 | - foreach ($datetimeIds as $datetimeId) { |
|
570 | - $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
571 | - foreach ($related_models as $key => $model) { |
|
572 | - // Get the IDs of related entities for the datetime ID. |
|
573 | - $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
574 | - $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
575 | - } |
|
576 | - } |
|
577 | - |
|
578 | - // PROCESS TICKETS |
|
579 | - $related_models = [ |
|
580 | - 'datetimes' => $eem_datetime, |
|
581 | - 'prices' => $eem_price, |
|
582 | - ]; |
|
583 | - // Get the IDs of all datetime tickets. |
|
584 | - $ticketIds = $eem_ticket->get_col([[ |
|
585 | - 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
586 | - 'TKT_deleted' => ['IN', [true, false]], |
|
587 | - ]]); |
|
588 | - foreach ($ticketIds as $ticketId) { |
|
589 | - $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
590 | - |
|
591 | - foreach ($related_models as $key => $model) { |
|
592 | - // Get the IDs of related entities for the ticket ID. |
|
593 | - $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
594 | - $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
595 | - } |
|
596 | - } |
|
597 | - |
|
598 | - // PROCESS PRICES |
|
599 | - $related_models = [ |
|
600 | - 'tickets' => $eem_ticket, |
|
601 | - 'priceTypes' => $eem_price_type, |
|
602 | - ]; |
|
603 | - // Get the IDs of all ticket prices. |
|
604 | - $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
605 | - foreach ($priceIds as $priceId) { |
|
606 | - $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
607 | - |
|
608 | - foreach ($related_models as $key => $model) { |
|
609 | - // Get the IDs of related entities for the price ID. |
|
610 | - $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
611 | - $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
612 | - } |
|
613 | - } |
|
614 | - |
|
615 | - return $data; |
|
616 | - } |
|
617 | - |
|
618 | - /** |
|
619 | - * Convert the DB ID into GID |
|
620 | - * |
|
621 | - * @param string $type |
|
622 | - * @param int|int[] $ID |
|
623 | - * @return mixed |
|
624 | - */ |
|
625 | - public static function convertToGlobalId($type, $ID) |
|
626 | - { |
|
627 | - if (is_array($ID)) { |
|
628 | - return array_map(function ($id) use ($type) { |
|
629 | - return self::convertToGlobalId($type, $id); |
|
630 | - }, $ID); |
|
631 | - } |
|
632 | - return Relay::toGlobalId($type, $ID); |
|
633 | - } |
|
634 | - |
|
635 | - |
|
636 | - /** |
|
637 | - * Returns Jed-formatted localization data. |
|
638 | - * |
|
639 | - * @param string $domain Translation domain. |
|
640 | - * @return array |
|
641 | - */ |
|
642 | - public static function getJedLocaleData($domain) |
|
643 | - { |
|
644 | - $translations = get_translations_for_domain($domain); |
|
645 | - |
|
646 | - $locale = array( |
|
647 | - '' => array( |
|
648 | - 'domain' => $domain, |
|
649 | - 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
650 | - ), |
|
651 | - ); |
|
652 | - |
|
653 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
654 | - $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
655 | - } |
|
656 | - |
|
657 | - foreach ($translations->entries as $msgid => $entry) { |
|
658 | - $locale[ $msgid ] = $entry->translations; |
|
659 | - } |
|
660 | - |
|
661 | - return $locale; |
|
662 | - } |
|
501 | + $data = [ |
|
502 | + 'operation_name' => 'GET_CURRENT_USER', |
|
503 | + 'query' => $query, |
|
504 | + ]; |
|
505 | + |
|
506 | + $responseData = $this->makeGraphQLRequest($data); |
|
507 | + return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
508 | + } |
|
509 | + |
|
510 | + |
|
511 | + /** |
|
512 | + * @param array $data |
|
513 | + * @return array |
|
514 | + * @since $VID:$ |
|
515 | + */ |
|
516 | + protected function makeGraphQLRequest($data) |
|
517 | + { |
|
518 | + try { |
|
519 | + $response = graphql($data); |
|
520 | + if (!empty($response['data'])) { |
|
521 | + return $response['data']; |
|
522 | + } |
|
523 | + return null; |
|
524 | + } catch (\Exception $e) { |
|
525 | + // do something with the errors thrown |
|
526 | + return null; |
|
527 | + } |
|
528 | + } |
|
529 | + |
|
530 | + |
|
531 | + /** |
|
532 | + * @param mixed $source The source that's passed down the GraphQL queries |
|
533 | + * @param array $args The inputArgs on the field |
|
534 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
535 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
536 | + * @return string |
|
537 | + * @throws EE_Error |
|
538 | + * @throws Exception |
|
539 | + * @throws InvalidArgumentException |
|
540 | + * @throws InvalidDataTypeException |
|
541 | + * @throws InvalidInterfaceException |
|
542 | + * @throws ReflectionException |
|
543 | + * @throws UserError |
|
544 | + * @throws UnexpectedEntityException |
|
545 | + * @since $VID:$ |
|
546 | + */ |
|
547 | + public static function getRelationalData($eventId) |
|
548 | + { |
|
549 | + $data = [ |
|
550 | + 'datetimes' => [], |
|
551 | + 'tickets' => [], |
|
552 | + 'prices' => [], |
|
553 | + ]; |
|
554 | + |
|
555 | + $eem_datetime = EEM_Datetime::instance(); |
|
556 | + $eem_ticket = EEM_Ticket::instance(); |
|
557 | + $eem_price = EEM_Price::instance(); |
|
558 | + $eem_price_type = EEM_Price_Type::instance(); |
|
559 | + |
|
560 | + // PROCESS DATETIMES |
|
561 | + $related_models = [ |
|
562 | + 'tickets' => $eem_ticket, |
|
563 | + ]; |
|
564 | + // Get the IDs of event datetimes. |
|
565 | + $datetimeIds = $eem_datetime->get_col([[ |
|
566 | + 'EVT_ID' => $eventId, |
|
567 | + 'DTT_deleted' => ['IN', [true, false]], |
|
568 | + ]]); |
|
569 | + foreach ($datetimeIds as $datetimeId) { |
|
570 | + $GID = self::convertToGlobalId($eem_datetime->item_name(), $datetimeId); |
|
571 | + foreach ($related_models as $key => $model) { |
|
572 | + // Get the IDs of related entities for the datetime ID. |
|
573 | + $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
|
574 | + $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
575 | + } |
|
576 | + } |
|
577 | + |
|
578 | + // PROCESS TICKETS |
|
579 | + $related_models = [ |
|
580 | + 'datetimes' => $eem_datetime, |
|
581 | + 'prices' => $eem_price, |
|
582 | + ]; |
|
583 | + // Get the IDs of all datetime tickets. |
|
584 | + $ticketIds = $eem_ticket->get_col([[ |
|
585 | + 'Datetime.DTT_ID' => ['in', $datetimeIds], |
|
586 | + 'TKT_deleted' => ['IN', [true, false]], |
|
587 | + ]]); |
|
588 | + foreach ($ticketIds as $ticketId) { |
|
589 | + $GID = self::convertToGlobalId($eem_ticket->item_name(), $ticketId); |
|
590 | + |
|
591 | + foreach ($related_models as $key => $model) { |
|
592 | + // Get the IDs of related entities for the ticket ID. |
|
593 | + $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
|
594 | + $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
595 | + } |
|
596 | + } |
|
597 | + |
|
598 | + // PROCESS PRICES |
|
599 | + $related_models = [ |
|
600 | + 'tickets' => $eem_ticket, |
|
601 | + 'priceTypes' => $eem_price_type, |
|
602 | + ]; |
|
603 | + // Get the IDs of all ticket prices. |
|
604 | + $priceIds = $eem_price->get_col([['Ticket.TKT_ID' => ['in', $ticketIds]]]); |
|
605 | + foreach ($priceIds as $priceId) { |
|
606 | + $GID = self::convertToGlobalId($eem_price->item_name(), $priceId); |
|
607 | + |
|
608 | + foreach ($related_models as $key => $model) { |
|
609 | + // Get the IDs of related entities for the price ID. |
|
610 | + $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
|
611 | + $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
612 | + } |
|
613 | + } |
|
614 | + |
|
615 | + return $data; |
|
616 | + } |
|
617 | + |
|
618 | + /** |
|
619 | + * Convert the DB ID into GID |
|
620 | + * |
|
621 | + * @param string $type |
|
622 | + * @param int|int[] $ID |
|
623 | + * @return mixed |
|
624 | + */ |
|
625 | + public static function convertToGlobalId($type, $ID) |
|
626 | + { |
|
627 | + if (is_array($ID)) { |
|
628 | + return array_map(function ($id) use ($type) { |
|
629 | + return self::convertToGlobalId($type, $id); |
|
630 | + }, $ID); |
|
631 | + } |
|
632 | + return Relay::toGlobalId($type, $ID); |
|
633 | + } |
|
634 | + |
|
635 | + |
|
636 | + /** |
|
637 | + * Returns Jed-formatted localization data. |
|
638 | + * |
|
639 | + * @param string $domain Translation domain. |
|
640 | + * @return array |
|
641 | + */ |
|
642 | + public static function getJedLocaleData($domain) |
|
643 | + { |
|
644 | + $translations = get_translations_for_domain($domain); |
|
645 | + |
|
646 | + $locale = array( |
|
647 | + '' => array( |
|
648 | + 'domain' => $domain, |
|
649 | + 'lang' => is_admin() ? EEH_DTT_Helper::get_user_locale() : get_locale() |
|
650 | + ), |
|
651 | + ); |
|
652 | + |
|
653 | + if (! empty($translations->headers['Plural-Forms'])) { |
|
654 | + $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
|
655 | + } |
|
656 | + |
|
657 | + foreach ($translations->entries as $msgid => $entry) { |
|
658 | + $locale[ $msgid ] = $entry->translations; |
|
659 | + } |
|
660 | + |
|
661 | + return $locale; |
|
662 | + } |
|
663 | 663 | } |
@@ -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 | - $assetsUrl = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
172 | + $assetsUrl = EE_PLUGIN_DIR_URL.'assets/dist/'; |
|
173 | 173 | |
174 | 174 | return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assetsUrl'); |
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) { |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | ]; |
295 | 295 | |
296 | 296 | $responseData = $this->makeGraphQLRequest($data); |
297 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
297 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | protected function getGraphQLTickets(array $datetimeIn) |
307 | 307 | { |
308 | - $field_key = lcfirst($this->namespace) . 'Tickets'; |
|
308 | + $field_key = lcfirst($this->namespace).'Tickets'; |
|
309 | 309 | $query = <<<QUERY |
310 | 310 | query GET_TICKETS(\$where: {$this->namespace}RootQueryTicketsConnectionWhereArgs, \$first: Int, \$last: Int ) { |
311 | 311 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | ]; |
354 | 354 | |
355 | 355 | $responseData = $this->makeGraphQLRequest($data); |
356 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
356 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
357 | 357 | } |
358 | 358 | |
359 | 359 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | protected function getGraphQLPrices(array $ticketIn) |
366 | 366 | { |
367 | - $field_key = lcfirst($this->namespace) . 'Prices'; |
|
367 | + $field_key = lcfirst($this->namespace).'Prices'; |
|
368 | 368 | $query = <<<QUERY |
369 | 369 | query GET_PRICES(\$where: {$this->namespace}RootQueryPricesConnectionWhereArgs, \$first: Int, \$last: Int ) { |
370 | 370 | {$field_key}(where: \$where, first: \$first, last: \$last) { |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | ]; |
402 | 402 | |
403 | 403 | $responseData = $this->makeGraphQLRequest($data); |
404 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
404 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | */ |
412 | 412 | protected function getGraphQLPriceTypes() |
413 | 413 | { |
414 | - $field_key = lcfirst($this->namespace) . 'PriceTypes'; |
|
414 | + $field_key = lcfirst($this->namespace).'PriceTypes'; |
|
415 | 415 | $query = <<<QUERY |
416 | 416 | query GET_PRICE_TYPES(\$first: Int, \$last: Int ) { |
417 | 417 | {$field_key}(first: \$first, last: \$last) { |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | ]; |
443 | 443 | |
444 | 444 | $responseData = $this->makeGraphQLRequest($data); |
445 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
445 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | ]; |
478 | 478 | |
479 | 479 | $responseData = $this->makeGraphQLRequest($data); |
480 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
480 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | |
@@ -504,7 +504,7 @@ discard block |
||
504 | 504 | ]; |
505 | 505 | |
506 | 506 | $responseData = $this->makeGraphQLRequest($data); |
507 | - return !empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
507 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | { |
518 | 518 | try { |
519 | 519 | $response = graphql($data); |
520 | - if (!empty($response['data'])) { |
|
520 | + if ( ! empty($response['data'])) { |
|
521 | 521 | return $response['data']; |
522 | 522 | } |
523 | 523 | return null; |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | foreach ($related_models as $key => $model) { |
572 | 572 | // Get the IDs of related entities for the datetime ID. |
573 | 573 | $Ids = $model->get_col([['Datetime.DTT_ID' => $datetimeId]]); |
574 | - $data['datetimes'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
574 | + $data['datetimes'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
575 | 575 | } |
576 | 576 | } |
577 | 577 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | foreach ($related_models as $key => $model) { |
592 | 592 | // Get the IDs of related entities for the ticket ID. |
593 | 593 | $Ids = $model->get_col([['Ticket.TKT_ID' => $ticketId]]); |
594 | - $data['tickets'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
594 | + $data['tickets'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
595 | 595 | } |
596 | 596 | } |
597 | 597 | |
@@ -608,7 +608,7 @@ discard block |
||
608 | 608 | foreach ($related_models as $key => $model) { |
609 | 609 | // Get the IDs of related entities for the price ID. |
610 | 610 | $Ids = $model->get_col([['Price.PRC_ID' => $priceId]]); |
611 | - $data['prices'][ $GID ][ $key ] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
611 | + $data['prices'][$GID][$key] = empty($Ids) ? [] : self::convertToGlobalId($model->item_name(), $Ids); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | public static function convertToGlobalId($type, $ID) |
626 | 626 | { |
627 | 627 | if (is_array($ID)) { |
628 | - return array_map(function ($id) use ($type) { |
|
628 | + return array_map(function($id) use ($type) { |
|
629 | 629 | return self::convertToGlobalId($type, $id); |
630 | 630 | }, $ID); |
631 | 631 | } |
@@ -650,12 +650,12 @@ discard block |
||
650 | 650 | ), |
651 | 651 | ); |
652 | 652 | |
653 | - if (! empty($translations->headers['Plural-Forms'])) { |
|
653 | + if ( ! empty($translations->headers['Plural-Forms'])) { |
|
654 | 654 | $locale['']['plural_forms'] = $translations->headers['Plural-Forms']; |
655 | 655 | } |
656 | 656 | |
657 | 657 | foreach ($translations->entries as $msgid => $entry) { |
658 | - $locale[ $msgid ] = $entry->translations; |
|
658 | + $locale[$msgid] = $entry->translations; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | return $locale; |