@@ -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 | } |
@@ -22,106 +22,106 @@ |
||
22 | 22 | class PriceType extends TypeBase |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * PriceType constructor. |
|
27 | - * |
|
28 | - * @param EEM_Price_Type $price_type_model |
|
29 | - */ |
|
30 | - public function __construct(EEM_Price_Type $price_type_model) |
|
31 | - { |
|
32 | - $this->model = $price_type_model; |
|
33 | - $this->setName($this->namespace. 'PriceType'); |
|
34 | - $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | - $this->setIsCustomPostType(false); |
|
36 | - parent::__construct(); |
|
37 | - } |
|
25 | + /** |
|
26 | + * PriceType constructor. |
|
27 | + * |
|
28 | + * @param EEM_Price_Type $price_type_model |
|
29 | + */ |
|
30 | + public function __construct(EEM_Price_Type $price_type_model) |
|
31 | + { |
|
32 | + $this->model = $price_type_model; |
|
33 | + $this->setName($this->namespace. 'PriceType'); |
|
34 | + $this->setDescription(__('A price type.', 'event_espresso')); |
|
35 | + $this->setIsCustomPostType(false); |
|
36 | + parent::__construct(); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * @return GraphQLFieldInterface[] |
|
42 | - * @since $VID:$ |
|
43 | - */ |
|
44 | - public function getFields() |
|
45 | - { |
|
46 | - return [ |
|
47 | - new GraphQLField( |
|
48 | - 'id', |
|
49 | - ['non_null' => 'ID'], |
|
50 | - null, |
|
51 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | - ), |
|
53 | - new GraphQLOutputField( |
|
54 | - 'dbId', |
|
55 | - ['non_null' => 'Int'], |
|
56 | - 'ID', |
|
57 | - esc_html__('Price type ID', 'event_espresso') |
|
58 | - ), |
|
59 | - new GraphQLField( |
|
60 | - 'baseType', |
|
61 | - $this->namespace . 'PriceBaseTypeEnum', |
|
62 | - 'base_type', |
|
63 | - esc_html__('Price Base type', 'event_espresso') |
|
64 | - ), |
|
65 | - new GraphQLOutputField( |
|
66 | - 'cacheId', |
|
67 | - ['non_null' => 'String'], |
|
68 | - null, |
|
69 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
70 | - ), |
|
71 | - new GraphQLField( |
|
72 | - 'isBasePrice', |
|
73 | - 'Boolean', |
|
74 | - 'is_base_price', |
|
75 | - esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
76 | - ), |
|
77 | - new GraphQLField( |
|
78 | - 'isTrashed', |
|
79 | - 'Boolean', |
|
80 | - 'deleted', |
|
81 | - esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
82 | - ), |
|
83 | - new GraphQLOutputField( |
|
84 | - 'isDiscount', |
|
85 | - 'Boolean', |
|
86 | - 'is_discount', |
|
87 | - esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
88 | - ), |
|
89 | - new GraphQLField( |
|
90 | - 'isPercent', |
|
91 | - 'Boolean', |
|
92 | - 'is_percent', |
|
93 | - esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
94 | - ), |
|
95 | - new GraphQLOutputField( |
|
96 | - 'isTax', |
|
97 | - 'Boolean', |
|
98 | - 'is_tax', |
|
99 | - esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
100 | - ), |
|
101 | - new GraphQLField( |
|
102 | - 'name', |
|
103 | - 'String', |
|
104 | - 'name', |
|
105 | - esc_html__('Price type Name', 'event_espresso') |
|
106 | - ), |
|
107 | - new GraphQLField( |
|
108 | - 'order', |
|
109 | - 'Int', |
|
110 | - 'order', |
|
111 | - esc_html__('Order in which price should be applied.', 'event_espresso') |
|
112 | - ), |
|
113 | - new GraphQLOutputField( |
|
114 | - 'wpUser', |
|
115 | - 'User', |
|
116 | - null, |
|
117 | - esc_html__('Price Type Creator', 'event_espresso') |
|
118 | - ), |
|
119 | - new GraphQLInputField( |
|
120 | - 'wpUser', |
|
121 | - 'Int', |
|
122 | - null, |
|
123 | - esc_html__('Price Type Creator ID', 'event_espresso') |
|
124 | - ), |
|
125 | - ]; |
|
126 | - } |
|
40 | + /** |
|
41 | + * @return GraphQLFieldInterface[] |
|
42 | + * @since $VID:$ |
|
43 | + */ |
|
44 | + public function getFields() |
|
45 | + { |
|
46 | + return [ |
|
47 | + new GraphQLField( |
|
48 | + 'id', |
|
49 | + ['non_null' => 'ID'], |
|
50 | + null, |
|
51 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
52 | + ), |
|
53 | + new GraphQLOutputField( |
|
54 | + 'dbId', |
|
55 | + ['non_null' => 'Int'], |
|
56 | + 'ID', |
|
57 | + esc_html__('Price type ID', 'event_espresso') |
|
58 | + ), |
|
59 | + new GraphQLField( |
|
60 | + 'baseType', |
|
61 | + $this->namespace . 'PriceBaseTypeEnum', |
|
62 | + 'base_type', |
|
63 | + esc_html__('Price Base type', 'event_espresso') |
|
64 | + ), |
|
65 | + new GraphQLOutputField( |
|
66 | + 'cacheId', |
|
67 | + ['non_null' => 'String'], |
|
68 | + null, |
|
69 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
70 | + ), |
|
71 | + new GraphQLField( |
|
72 | + 'isBasePrice', |
|
73 | + 'Boolean', |
|
74 | + 'is_base_price', |
|
75 | + esc_html__('Flag indicating price type is a base price.', 'event_espresso') |
|
76 | + ), |
|
77 | + new GraphQLField( |
|
78 | + 'isTrashed', |
|
79 | + 'Boolean', |
|
80 | + 'deleted', |
|
81 | + esc_html__('Flag indicating price type has been trashed.', 'event_espresso') |
|
82 | + ), |
|
83 | + new GraphQLOutputField( |
|
84 | + 'isDiscount', |
|
85 | + 'Boolean', |
|
86 | + 'is_discount', |
|
87 | + esc_html__('Flag indicating price type is a discount.', 'event_espresso') |
|
88 | + ), |
|
89 | + new GraphQLField( |
|
90 | + 'isPercent', |
|
91 | + 'Boolean', |
|
92 | + 'is_percent', |
|
93 | + esc_html__('Flag indicating price type is a percentage.', 'event_espresso') |
|
94 | + ), |
|
95 | + new GraphQLOutputField( |
|
96 | + 'isTax', |
|
97 | + 'Boolean', |
|
98 | + 'is_tax', |
|
99 | + esc_html__('Flag indicating price is a tax.', 'event_espresso') |
|
100 | + ), |
|
101 | + new GraphQLField( |
|
102 | + 'name', |
|
103 | + 'String', |
|
104 | + 'name', |
|
105 | + esc_html__('Price type Name', 'event_espresso') |
|
106 | + ), |
|
107 | + new GraphQLField( |
|
108 | + 'order', |
|
109 | + 'Int', |
|
110 | + 'order', |
|
111 | + esc_html__('Order in which price should be applied.', 'event_espresso') |
|
112 | + ), |
|
113 | + new GraphQLOutputField( |
|
114 | + 'wpUser', |
|
115 | + 'User', |
|
116 | + null, |
|
117 | + esc_html__('Price Type Creator', 'event_espresso') |
|
118 | + ), |
|
119 | + new GraphQLInputField( |
|
120 | + 'wpUser', |
|
121 | + 'Int', |
|
122 | + null, |
|
123 | + esc_html__('Price Type Creator ID', 'event_espresso') |
|
124 | + ), |
|
125 | + ]; |
|
126 | + } |
|
127 | 127 | } |