@@ -15,65 +15,65 @@ |
||
15 | 15 | */ |
16 | 16 | abstract class AbstractLoader extends AbstractDataLoader |
17 | 17 | { |
18 | - protected $primaryKey; |
|
18 | + protected $primaryKey; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @return EEM_Base |
|
22 | - * @throws EE_Error |
|
23 | - * @throws InvalidArgumentException |
|
24 | - * @throws InvalidDataTypeException |
|
25 | - * @throws InvalidInterfaceException |
|
26 | - */ |
|
27 | - abstract protected function getQuery(): EEM_Base; |
|
20 | + /** |
|
21 | + * @return EEM_Base |
|
22 | + * @throws EE_Error |
|
23 | + * @throws InvalidArgumentException |
|
24 | + * @throws InvalidDataTypeException |
|
25 | + * @throws InvalidInterfaceException |
|
26 | + */ |
|
27 | + abstract protected function getQuery(): EEM_Base; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param array $keys |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - abstract protected function getWhereParams(array $keys): array; |
|
29 | + /** |
|
30 | + * @param array $keys |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + abstract protected function getWhereParams(array $keys): array; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Given array of keys, loads and returns a map consisting of keys from `keys` array and loaded |
|
37 | - * values |
|
38 | - * |
|
39 | - * Note that order of returned values must match exactly the order of keys. |
|
40 | - * If some entry is not available for given key - it must include null for the missing key. |
|
41 | - * |
|
42 | - * For example: |
|
43 | - * loadKeys(['a', 'b', 'c']) -> ['a' => 'value1, 'b' => null, 'c' => 'value3'] |
|
44 | - * |
|
45 | - * @param array $keys |
|
46 | - * |
|
47 | - * @return array |
|
48 | - * @throws Exception |
|
49 | - */ |
|
50 | - public function loadKeys(array $keys): array |
|
51 | - { |
|
52 | - if (empty($keys)) { |
|
53 | - return $keys; |
|
54 | - } |
|
35 | + /** |
|
36 | + * Given array of keys, loads and returns a map consisting of keys from `keys` array and loaded |
|
37 | + * values |
|
38 | + * |
|
39 | + * Note that order of returned values must match exactly the order of keys. |
|
40 | + * If some entry is not available for given key - it must include null for the missing key. |
|
41 | + * |
|
42 | + * For example: |
|
43 | + * loadKeys(['a', 'b', 'c']) -> ['a' => 'value1, 'b' => null, 'c' => 'value3'] |
|
44 | + * |
|
45 | + * @param array $keys |
|
46 | + * |
|
47 | + * @return array |
|
48 | + * @throws Exception |
|
49 | + */ |
|
50 | + public function loadKeys(array $keys): array |
|
51 | + { |
|
52 | + if (empty($keys)) { |
|
53 | + return $keys; |
|
54 | + } |
|
55 | 55 | |
56 | - $args = [ |
|
57 | - $this->getWhereParams($keys), |
|
58 | - ]; |
|
56 | + $args = [ |
|
57 | + $this->getWhereParams($keys), |
|
58 | + ]; |
|
59 | 59 | |
60 | - $query = $this->getQuery(); |
|
61 | - $result = $query->get_all($args); |
|
60 | + $query = $this->getQuery(); |
|
61 | + $result = $query->get_all($args); |
|
62 | 62 | |
63 | - $loadedItems = []; |
|
63 | + $loadedItems = []; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Loop over the items and return an array of loaded items, |
|
67 | - * where the key is the ID and the value is the Object passed through |
|
68 | - * the model layer. |
|
69 | - */ |
|
70 | - foreach ($keys as $key) { |
|
71 | - if (isset($result[ $key ])) { |
|
72 | - $loadedItems[ $key ] = $result[ $key ]; |
|
73 | - } else { |
|
74 | - $loadedItems[ $key ] = null; |
|
75 | - } |
|
76 | - } |
|
77 | - return $loadedItems; |
|
78 | - } |
|
65 | + /** |
|
66 | + * Loop over the items and return an array of loaded items, |
|
67 | + * where the key is the ID and the value is the Object passed through |
|
68 | + * the model layer. |
|
69 | + */ |
|
70 | + foreach ($keys as $key) { |
|
71 | + if (isset($result[ $key ])) { |
|
72 | + $loadedItems[ $key ] = $result[ $key ]; |
|
73 | + } else { |
|
74 | + $loadedItems[ $key ] = null; |
|
75 | + } |
|
76 | + } |
|
77 | + return $loadedItems; |
|
78 | + } |
|
79 | 79 | } |
@@ -15,27 +15,27 @@ |
||
15 | 15 | */ |
16 | 16 | class PriceLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_Price::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_Price::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $keys |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getWhereParams(array $keys): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'PRC_ID' => ['IN', $keys], |
|
39 | - ]; |
|
40 | - } |
|
31 | + /** |
|
32 | + * @param array $keys |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getWhereParams(array $keys): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'PRC_ID' => ['IN', $keys], |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | } |
@@ -15,27 +15,27 @@ |
||
15 | 15 | */ |
16 | 16 | class VenueLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_Venue::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_Venue::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $keys |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getWhereParams(array $keys): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'VNU_ID' => ['IN', $keys], |
|
39 | - ]; |
|
40 | - } |
|
31 | + /** |
|
32 | + * @param array $keys |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getWhereParams(array $keys): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'VNU_ID' => ['IN', $keys], |
|
39 | + ]; |
|
40 | + } |
|
41 | 41 | } |
@@ -15,28 +15,28 @@ |
||
15 | 15 | */ |
16 | 16 | class DatetimeLoader extends AbstractLoader |
17 | 17 | { |
18 | - /** |
|
19 | - * @return EEM_Base |
|
20 | - * @throws EE_Error |
|
21 | - * @throws InvalidArgumentException |
|
22 | - * @throws InvalidDataTypeException |
|
23 | - * @throws InvalidInterfaceException |
|
24 | - * @throws ReflectionException |
|
25 | - */ |
|
26 | - protected function getQuery(): EEM_Base |
|
27 | - { |
|
28 | - return EEM_Datetime::instance(); |
|
29 | - } |
|
18 | + /** |
|
19 | + * @return EEM_Base |
|
20 | + * @throws EE_Error |
|
21 | + * @throws InvalidArgumentException |
|
22 | + * @throws InvalidDataTypeException |
|
23 | + * @throws InvalidInterfaceException |
|
24 | + * @throws ReflectionException |
|
25 | + */ |
|
26 | + protected function getQuery(): EEM_Base |
|
27 | + { |
|
28 | + return EEM_Datetime::instance(); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $keys |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - protected function getWhereParams(array $keys): array |
|
36 | - { |
|
37 | - return [ |
|
38 | - 'DTT_ID' => ['IN', $keys], |
|
39 | - 'DTT_deleted' => ['IN', [true, false]] |
|
40 | - ]; |
|
41 | - } |
|
31 | + /** |
|
32 | + * @param array $keys |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + protected function getWhereParams(array $keys): array |
|
36 | + { |
|
37 | + return [ |
|
38 | + 'DTT_ID' => ['IN', $keys], |
|
39 | + 'DTT_deleted' => ['IN', [true, false]] |
|
40 | + ]; |
|
41 | + } |
|
42 | 42 | } |
@@ -23,195 +23,195 @@ |
||
23 | 23 | class TicketMutation |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * Maps the GraphQL input to a format that the model functions can use |
|
28 | - * |
|
29 | - * @param array $input Data coming from the GraphQL mutation query input |
|
30 | - * @return array |
|
31 | - * @throws Exception |
|
32 | - */ |
|
33 | - public static function prepareFields(array $input): array |
|
34 | - { |
|
35 | - $args = []; |
|
36 | - |
|
37 | - if (! empty($input['datetimes'])) { |
|
38 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
39 | - } |
|
40 | - |
|
41 | - if (isset($input['description'])) { |
|
42 | - $args['TKT_description'] = wp_kses_post($input['description']); |
|
43 | - } |
|
44 | - |
|
45 | - if (! empty($input['endDate'])) { |
|
46 | - $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
47 | - } |
|
48 | - |
|
49 | - if (array_key_exists('isDefault', $input)) { |
|
50 | - $args['TKT_is_default'] = (bool) $input['isDefault']; |
|
51 | - } |
|
52 | - |
|
53 | - if (array_key_exists('isRequired', $input)) { |
|
54 | - $args['TKT_required'] = (bool) $input['isRequired']; |
|
55 | - } |
|
56 | - |
|
57 | - if (array_key_exists('isTaxable', $input)) { |
|
58 | - $args['TKT_taxable'] = (bool) $input['isTaxable']; |
|
59 | - } |
|
60 | - |
|
61 | - if (array_key_exists('isTrashed', $input)) { |
|
62 | - $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
63 | - } |
|
64 | - |
|
65 | - if (array_key_exists('max', $input)) { |
|
66 | - $args['TKT_max'] = (int) $input['max']; |
|
67 | - } |
|
68 | - |
|
69 | - if (array_key_exists('min', $input)) { |
|
70 | - $args['TKT_min'] = (int) $input['min']; |
|
71 | - } |
|
72 | - |
|
73 | - if (isset($input['name'])) { |
|
74 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
75 | - } |
|
76 | - |
|
77 | - if (array_key_exists('order', $input)) { |
|
78 | - $args['TKT_order'] = (int) $input['order']; |
|
79 | - } |
|
80 | - |
|
81 | - if (! empty($input['parent'])) { |
|
82 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
83 | - $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
84 | - } |
|
85 | - |
|
86 | - // price can be 0 |
|
87 | - if (array_key_exists('price', $input)) { |
|
88 | - $args['TKT_price'] = (float) $input['price']; |
|
89 | - } |
|
90 | - |
|
91 | - // prices can be an empty array when all prices are deleted |
|
92 | - if (array_key_exists('prices', $input) && is_array($input['prices'])) { |
|
93 | - $args['prices'] = array_map('sanitize_text_field', $input['prices']); |
|
94 | - } |
|
95 | - |
|
96 | - if (array_key_exists('quantity', $input)) { |
|
97 | - $args['TKT_qty'] = (int) $input['quantity']; |
|
98 | - } |
|
99 | - |
|
100 | - if (array_key_exists('reserved', $input)) { |
|
101 | - $args['TKT_reserved'] = (int) $input['reserved']; |
|
102 | - } |
|
103 | - |
|
104 | - if (array_key_exists('reverseCalculate', $input)) { |
|
105 | - $args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate']; |
|
106 | - } |
|
107 | - |
|
108 | - if (array_key_exists('row', $input)) { |
|
109 | - $args['TKT_row'] = (int) $input['row']; |
|
110 | - } |
|
111 | - |
|
112 | - if (array_key_exists('sold', $input)) { |
|
113 | - $args['TKT_sold'] = (int) $input['sold']; |
|
114 | - } |
|
115 | - |
|
116 | - if (! empty($input['startDate'])) { |
|
117 | - $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
118 | - } |
|
119 | - |
|
120 | - if (array_key_exists('uses', $input)) { |
|
121 | - $args['TKT_uses'] = (int) $input['uses']; |
|
122 | - } |
|
123 | - |
|
124 | - if (! empty($input['wpUser'])) { |
|
125 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
126 | - $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
127 | - } |
|
128 | - |
|
129 | - if (array_key_exists('visibility', $input)) { |
|
130 | - $args['TKT_visibility'] = (int) $input['visibility']; |
|
131 | - } |
|
132 | - |
|
133 | - return apply_filters( |
|
134 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args', |
|
135 | - $args, |
|
136 | - $input |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - |
|
141 | - /** |
|
142 | - * Sets the related datetimes for the given ticket. |
|
143 | - * |
|
144 | - * @param EE_Ticket $entity The Ticket instance. |
|
145 | - * @param array $datetimes Array of datetime IDs to relate. |
|
146 | - * @throws EE_Error |
|
147 | - * @throws InvalidArgumentException |
|
148 | - * @throws InvalidDataTypeException |
|
149 | - * @throws InvalidInterfaceException |
|
150 | - * @throws ReflectionException |
|
151 | - */ |
|
152 | - public static function setRelatedDatetimes(EE_Ticket $entity, array $datetimes) |
|
153 | - { |
|
154 | - $relationName = 'Datetime'; |
|
155 | - // Remove all the existing related datetimes |
|
156 | - |
|
157 | - $entity->_remove_relations($relationName); |
|
158 | - // @todo replace loop with single query |
|
159 | - foreach ($datetimes as $ID) { |
|
160 | - $parts = Relay::fromGlobalId($ID); |
|
161 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
162 | - $entity->_add_relation_to( |
|
163 | - $parts['id'], |
|
164 | - $relationName |
|
165 | - ); |
|
166 | - } |
|
167 | - } |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * Sets the related prices for the given ticket. |
|
173 | - * |
|
174 | - * @param EE_Ticket $entity The Ticket instance. |
|
175 | - * @param array $prices Array of entity IDs to relate. |
|
176 | - * @throws EE_Error |
|
177 | - * @throws InvalidArgumentException |
|
178 | - * @throws InvalidDataTypeException |
|
179 | - * @throws InvalidInterfaceException |
|
180 | - * @throws ReflectionException |
|
181 | - */ |
|
182 | - public static function setRelatedPrices(EE_Ticket $entity, array $prices) |
|
183 | - { |
|
184 | - $relationName = 'Price'; |
|
185 | - // Remove all the existing related entities |
|
186 | - $entity->_remove_relations($relationName); |
|
187 | - |
|
188 | - // @todo replace loop with single query |
|
189 | - foreach ($prices as $ID) { |
|
190 | - $parts = Relay::fromGlobalId($ID); |
|
191 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
192 | - $entity->_add_relation_to( |
|
193 | - $parts['id'], |
|
194 | - $relationName |
|
195 | - ); |
|
196 | - } |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - |
|
201 | - /** |
|
202 | - * @param EE_Ticket $ticket_entity |
|
203 | - * @throws EE_Error |
|
204 | - * @throws InvalidArgumentException |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidInterfaceException |
|
207 | - * @throws ReflectionException |
|
208 | - */ |
|
209 | - public static function addDefaultPrices(EE_Ticket $ticket_entity) |
|
210 | - { |
|
211 | - /** @var DefaultPrices $default_prices */ |
|
212 | - $default_prices = LoaderFactory::getLoader()->getShared( |
|
213 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' |
|
214 | - ); |
|
215 | - $default_prices->create($ticket_entity); |
|
216 | - } |
|
26 | + /** |
|
27 | + * Maps the GraphQL input to a format that the model functions can use |
|
28 | + * |
|
29 | + * @param array $input Data coming from the GraphQL mutation query input |
|
30 | + * @return array |
|
31 | + * @throws Exception |
|
32 | + */ |
|
33 | + public static function prepareFields(array $input): array |
|
34 | + { |
|
35 | + $args = []; |
|
36 | + |
|
37 | + if (! empty($input['datetimes'])) { |
|
38 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
39 | + } |
|
40 | + |
|
41 | + if (isset($input['description'])) { |
|
42 | + $args['TKT_description'] = wp_kses_post($input['description']); |
|
43 | + } |
|
44 | + |
|
45 | + if (! empty($input['endDate'])) { |
|
46 | + $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
47 | + } |
|
48 | + |
|
49 | + if (array_key_exists('isDefault', $input)) { |
|
50 | + $args['TKT_is_default'] = (bool) $input['isDefault']; |
|
51 | + } |
|
52 | + |
|
53 | + if (array_key_exists('isRequired', $input)) { |
|
54 | + $args['TKT_required'] = (bool) $input['isRequired']; |
|
55 | + } |
|
56 | + |
|
57 | + if (array_key_exists('isTaxable', $input)) { |
|
58 | + $args['TKT_taxable'] = (bool) $input['isTaxable']; |
|
59 | + } |
|
60 | + |
|
61 | + if (array_key_exists('isTrashed', $input)) { |
|
62 | + $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
63 | + } |
|
64 | + |
|
65 | + if (array_key_exists('max', $input)) { |
|
66 | + $args['TKT_max'] = (int) $input['max']; |
|
67 | + } |
|
68 | + |
|
69 | + if (array_key_exists('min', $input)) { |
|
70 | + $args['TKT_min'] = (int) $input['min']; |
|
71 | + } |
|
72 | + |
|
73 | + if (isset($input['name'])) { |
|
74 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
75 | + } |
|
76 | + |
|
77 | + if (array_key_exists('order', $input)) { |
|
78 | + $args['TKT_order'] = (int) $input['order']; |
|
79 | + } |
|
80 | + |
|
81 | + if (! empty($input['parent'])) { |
|
82 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
83 | + $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
84 | + } |
|
85 | + |
|
86 | + // price can be 0 |
|
87 | + if (array_key_exists('price', $input)) { |
|
88 | + $args['TKT_price'] = (float) $input['price']; |
|
89 | + } |
|
90 | + |
|
91 | + // prices can be an empty array when all prices are deleted |
|
92 | + if (array_key_exists('prices', $input) && is_array($input['prices'])) { |
|
93 | + $args['prices'] = array_map('sanitize_text_field', $input['prices']); |
|
94 | + } |
|
95 | + |
|
96 | + if (array_key_exists('quantity', $input)) { |
|
97 | + $args['TKT_qty'] = (int) $input['quantity']; |
|
98 | + } |
|
99 | + |
|
100 | + if (array_key_exists('reserved', $input)) { |
|
101 | + $args['TKT_reserved'] = (int) $input['reserved']; |
|
102 | + } |
|
103 | + |
|
104 | + if (array_key_exists('reverseCalculate', $input)) { |
|
105 | + $args['TKT_reverse_calculate'] = (bool) $input['reverseCalculate']; |
|
106 | + } |
|
107 | + |
|
108 | + if (array_key_exists('row', $input)) { |
|
109 | + $args['TKT_row'] = (int) $input['row']; |
|
110 | + } |
|
111 | + |
|
112 | + if (array_key_exists('sold', $input)) { |
|
113 | + $args['TKT_sold'] = (int) $input['sold']; |
|
114 | + } |
|
115 | + |
|
116 | + if (! empty($input['startDate'])) { |
|
117 | + $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
|
118 | + } |
|
119 | + |
|
120 | + if (array_key_exists('uses', $input)) { |
|
121 | + $args['TKT_uses'] = (int) $input['uses']; |
|
122 | + } |
|
123 | + |
|
124 | + if (! empty($input['wpUser'])) { |
|
125 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
|
126 | + $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
127 | + } |
|
128 | + |
|
129 | + if (array_key_exists('visibility', $input)) { |
|
130 | + $args['TKT_visibility'] = (int) $input['visibility']; |
|
131 | + } |
|
132 | + |
|
133 | + return apply_filters( |
|
134 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__ticket_args', |
|
135 | + $args, |
|
136 | + $input |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + |
|
141 | + /** |
|
142 | + * Sets the related datetimes for the given ticket. |
|
143 | + * |
|
144 | + * @param EE_Ticket $entity The Ticket instance. |
|
145 | + * @param array $datetimes Array of datetime IDs to relate. |
|
146 | + * @throws EE_Error |
|
147 | + * @throws InvalidArgumentException |
|
148 | + * @throws InvalidDataTypeException |
|
149 | + * @throws InvalidInterfaceException |
|
150 | + * @throws ReflectionException |
|
151 | + */ |
|
152 | + public static function setRelatedDatetimes(EE_Ticket $entity, array $datetimes) |
|
153 | + { |
|
154 | + $relationName = 'Datetime'; |
|
155 | + // Remove all the existing related datetimes |
|
156 | + |
|
157 | + $entity->_remove_relations($relationName); |
|
158 | + // @todo replace loop with single query |
|
159 | + foreach ($datetimes as $ID) { |
|
160 | + $parts = Relay::fromGlobalId($ID); |
|
161 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
162 | + $entity->_add_relation_to( |
|
163 | + $parts['id'], |
|
164 | + $relationName |
|
165 | + ); |
|
166 | + } |
|
167 | + } |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Sets the related prices for the given ticket. |
|
173 | + * |
|
174 | + * @param EE_Ticket $entity The Ticket instance. |
|
175 | + * @param array $prices Array of entity IDs to relate. |
|
176 | + * @throws EE_Error |
|
177 | + * @throws InvalidArgumentException |
|
178 | + * @throws InvalidDataTypeException |
|
179 | + * @throws InvalidInterfaceException |
|
180 | + * @throws ReflectionException |
|
181 | + */ |
|
182 | + public static function setRelatedPrices(EE_Ticket $entity, array $prices) |
|
183 | + { |
|
184 | + $relationName = 'Price'; |
|
185 | + // Remove all the existing related entities |
|
186 | + $entity->_remove_relations($relationName); |
|
187 | + |
|
188 | + // @todo replace loop with single query |
|
189 | + foreach ($prices as $ID) { |
|
190 | + $parts = Relay::fromGlobalId($ID); |
|
191 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
192 | + $entity->_add_relation_to( |
|
193 | + $parts['id'], |
|
194 | + $relationName |
|
195 | + ); |
|
196 | + } |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + |
|
201 | + /** |
|
202 | + * @param EE_Ticket $ticket_entity |
|
203 | + * @throws EE_Error |
|
204 | + * @throws InvalidArgumentException |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidInterfaceException |
|
207 | + * @throws ReflectionException |
|
208 | + */ |
|
209 | + public static function addDefaultPrices(EE_Ticket $ticket_entity) |
|
210 | + { |
|
211 | + /** @var DefaultPrices $default_prices */ |
|
212 | + $default_prices = LoaderFactory::getLoader()->getShared( |
|
213 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' |
|
214 | + ); |
|
215 | + $default_prices->create($ticket_entity); |
|
216 | + } |
|
217 | 217 | } |
@@ -14,101 +14,101 @@ |
||
14 | 14 | class VenueMutation |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * Maps the GraphQL input to a format that the model functions can use |
|
19 | - * |
|
20 | - * @param array $input Data coming from the GraphQL mutation query input |
|
21 | - * @return array |
|
22 | - * @throws Exception |
|
23 | - */ |
|
24 | - public static function prepareFields(array $input): array |
|
25 | - { |
|
26 | - $args = []; |
|
27 | - |
|
28 | - if (! empty($input['name'])) { |
|
29 | - $args['VNU_name'] = sanitize_text_field($input['name']); |
|
30 | - } |
|
31 | - |
|
32 | - if (! empty($input['description'])) { |
|
33 | - $args['VNU_desc'] = wp_kses_post($input['description']); |
|
34 | - } |
|
35 | - |
|
36 | - if (! empty($input['shortDescription'])) { |
|
37 | - $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
|
38 | - } |
|
39 | - |
|
40 | - if (! empty($input['identifier'])) { |
|
41 | - $args['VNU_identifier'] = sanitize_title($input['identifier']); |
|
42 | - } |
|
43 | - |
|
44 | - if (! empty($input['created'])) { |
|
45 | - $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
|
46 | - } |
|
47 | - |
|
48 | - if (! empty($input['order'])) { |
|
49 | - $args['VNU_order'] = absint($input['order']); |
|
50 | - } |
|
51 | - |
|
52 | - if (! empty($input['wpUser'])) { |
|
53 | - $args['VNU_wp_user'] = absint($input['wpUser']); |
|
54 | - } |
|
55 | - |
|
56 | - if (! empty($input['address'])) { |
|
57 | - $args['VNU_address'] = sanitize_text_field($input['address']); |
|
58 | - } |
|
59 | - |
|
60 | - if (! empty($input['address2'])) { |
|
61 | - $args['VNU_address2'] = sanitize_text_field($input['address2']); |
|
62 | - } |
|
63 | - |
|
64 | - if (! empty($input['city'])) { |
|
65 | - $args['VNU_city'] = sanitize_text_field($input['city']); |
|
66 | - } |
|
67 | - |
|
68 | - if (! empty($input['state'])) { |
|
69 | - $args['STA_ID'] = absint($input['state']); |
|
70 | - } |
|
71 | - |
|
72 | - if (! empty($input['country'])) { |
|
73 | - $args['CNT_ISO'] = sanitize_text_field($input['country']); |
|
74 | - } |
|
75 | - |
|
76 | - if (! empty($input['zip'])) { |
|
77 | - $args['VNU_zip'] = sanitize_text_field($input['zip']); |
|
78 | - } |
|
79 | - |
|
80 | - if (! empty($input['capacity'])) { |
|
81 | - $args['VNU_capacity'] = absint($input['capacity']); |
|
82 | - } |
|
83 | - |
|
84 | - if (! empty($input['phone'])) { |
|
85 | - $args['VNU_phone'] = sanitize_text_field($input['phone']); |
|
86 | - } |
|
87 | - |
|
88 | - if (! empty($input['virtualPhone'])) { |
|
89 | - $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
|
90 | - } |
|
91 | - |
|
92 | - if (! empty($input['url'])) { |
|
93 | - $args['VNU_url'] = sanitize_text_field($input['url']); |
|
94 | - } |
|
95 | - |
|
96 | - if (! empty($input['virtualUrl'])) { |
|
97 | - $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
|
98 | - } |
|
99 | - |
|
100 | - if (! empty($input['googleMapLink'])) { |
|
101 | - $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
|
102 | - } |
|
103 | - |
|
104 | - if (! empty($input['enableForGmap'])) { |
|
105 | - $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
|
106 | - } |
|
107 | - |
|
108 | - return apply_filters( |
|
109 | - 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
110 | - $args, |
|
111 | - $input |
|
112 | - ); |
|
113 | - } |
|
17 | + /** |
|
18 | + * Maps the GraphQL input to a format that the model functions can use |
|
19 | + * |
|
20 | + * @param array $input Data coming from the GraphQL mutation query input |
|
21 | + * @return array |
|
22 | + * @throws Exception |
|
23 | + */ |
|
24 | + public static function prepareFields(array $input): array |
|
25 | + { |
|
26 | + $args = []; |
|
27 | + |
|
28 | + if (! empty($input['name'])) { |
|
29 | + $args['VNU_name'] = sanitize_text_field($input['name']); |
|
30 | + } |
|
31 | + |
|
32 | + if (! empty($input['description'])) { |
|
33 | + $args['VNU_desc'] = wp_kses_post($input['description']); |
|
34 | + } |
|
35 | + |
|
36 | + if (! empty($input['shortDescription'])) { |
|
37 | + $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
|
38 | + } |
|
39 | + |
|
40 | + if (! empty($input['identifier'])) { |
|
41 | + $args['VNU_identifier'] = sanitize_title($input['identifier']); |
|
42 | + } |
|
43 | + |
|
44 | + if (! empty($input['created'])) { |
|
45 | + $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
|
46 | + } |
|
47 | + |
|
48 | + if (! empty($input['order'])) { |
|
49 | + $args['VNU_order'] = absint($input['order']); |
|
50 | + } |
|
51 | + |
|
52 | + if (! empty($input['wpUser'])) { |
|
53 | + $args['VNU_wp_user'] = absint($input['wpUser']); |
|
54 | + } |
|
55 | + |
|
56 | + if (! empty($input['address'])) { |
|
57 | + $args['VNU_address'] = sanitize_text_field($input['address']); |
|
58 | + } |
|
59 | + |
|
60 | + if (! empty($input['address2'])) { |
|
61 | + $args['VNU_address2'] = sanitize_text_field($input['address2']); |
|
62 | + } |
|
63 | + |
|
64 | + if (! empty($input['city'])) { |
|
65 | + $args['VNU_city'] = sanitize_text_field($input['city']); |
|
66 | + } |
|
67 | + |
|
68 | + if (! empty($input['state'])) { |
|
69 | + $args['STA_ID'] = absint($input['state']); |
|
70 | + } |
|
71 | + |
|
72 | + if (! empty($input['country'])) { |
|
73 | + $args['CNT_ISO'] = sanitize_text_field($input['country']); |
|
74 | + } |
|
75 | + |
|
76 | + if (! empty($input['zip'])) { |
|
77 | + $args['VNU_zip'] = sanitize_text_field($input['zip']); |
|
78 | + } |
|
79 | + |
|
80 | + if (! empty($input['capacity'])) { |
|
81 | + $args['VNU_capacity'] = absint($input['capacity']); |
|
82 | + } |
|
83 | + |
|
84 | + if (! empty($input['phone'])) { |
|
85 | + $args['VNU_phone'] = sanitize_text_field($input['phone']); |
|
86 | + } |
|
87 | + |
|
88 | + if (! empty($input['virtualPhone'])) { |
|
89 | + $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
|
90 | + } |
|
91 | + |
|
92 | + if (! empty($input['url'])) { |
|
93 | + $args['VNU_url'] = sanitize_text_field($input['url']); |
|
94 | + } |
|
95 | + |
|
96 | + if (! empty($input['virtualUrl'])) { |
|
97 | + $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
|
98 | + } |
|
99 | + |
|
100 | + if (! empty($input['googleMapLink'])) { |
|
101 | + $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
|
102 | + } |
|
103 | + |
|
104 | + if (! empty($input['enableForGmap'])) { |
|
105 | + $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
|
106 | + } |
|
107 | + |
|
108 | + return apply_filters( |
|
109 | + 'FHEE__EventEspresso_core_domain_services_graphql_data_mutations__venue_args', |
|
110 | + $args, |
|
111 | + $input |
|
112 | + ); |
|
113 | + } |
|
114 | 114 | } |
@@ -25,83 +25,83 @@ |
||
25 | 25 | { |
26 | 26 | $args = []; |
27 | 27 | |
28 | - if (! empty($input['name'])) { |
|
28 | + if ( ! empty($input['name'])) { |
|
29 | 29 | $args['VNU_name'] = sanitize_text_field($input['name']); |
30 | 30 | } |
31 | 31 | |
32 | - if (! empty($input['description'])) { |
|
32 | + if ( ! empty($input['description'])) { |
|
33 | 33 | $args['VNU_desc'] = wp_kses_post($input['description']); |
34 | 34 | } |
35 | 35 | |
36 | - if (! empty($input['shortDescription'])) { |
|
36 | + if ( ! empty($input['shortDescription'])) { |
|
37 | 37 | $args['VNU_short_desc'] = sanitize_text_field($input['shortDescription']); |
38 | 38 | } |
39 | 39 | |
40 | - if (! empty($input['identifier'])) { |
|
40 | + if ( ! empty($input['identifier'])) { |
|
41 | 41 | $args['VNU_identifier'] = sanitize_title($input['identifier']); |
42 | 42 | } |
43 | 43 | |
44 | - if (! empty($input['created'])) { |
|
44 | + if ( ! empty($input['created'])) { |
|
45 | 45 | $args['VNU_created'] = new DateTime(sanitize_text_field($input['created'])); |
46 | 46 | } |
47 | 47 | |
48 | - if (! empty($input['order'])) { |
|
48 | + if ( ! empty($input['order'])) { |
|
49 | 49 | $args['VNU_order'] = absint($input['order']); |
50 | 50 | } |
51 | 51 | |
52 | - if (! empty($input['wpUser'])) { |
|
52 | + if ( ! empty($input['wpUser'])) { |
|
53 | 53 | $args['VNU_wp_user'] = absint($input['wpUser']); |
54 | 54 | } |
55 | 55 | |
56 | - if (! empty($input['address'])) { |
|
56 | + if ( ! empty($input['address'])) { |
|
57 | 57 | $args['VNU_address'] = sanitize_text_field($input['address']); |
58 | 58 | } |
59 | 59 | |
60 | - if (! empty($input['address2'])) { |
|
60 | + if ( ! empty($input['address2'])) { |
|
61 | 61 | $args['VNU_address2'] = sanitize_text_field($input['address2']); |
62 | 62 | } |
63 | 63 | |
64 | - if (! empty($input['city'])) { |
|
64 | + if ( ! empty($input['city'])) { |
|
65 | 65 | $args['VNU_city'] = sanitize_text_field($input['city']); |
66 | 66 | } |
67 | 67 | |
68 | - if (! empty($input['state'])) { |
|
68 | + if ( ! empty($input['state'])) { |
|
69 | 69 | $args['STA_ID'] = absint($input['state']); |
70 | 70 | } |
71 | 71 | |
72 | - if (! empty($input['country'])) { |
|
72 | + if ( ! empty($input['country'])) { |
|
73 | 73 | $args['CNT_ISO'] = sanitize_text_field($input['country']); |
74 | 74 | } |
75 | 75 | |
76 | - if (! empty($input['zip'])) { |
|
76 | + if ( ! empty($input['zip'])) { |
|
77 | 77 | $args['VNU_zip'] = sanitize_text_field($input['zip']); |
78 | 78 | } |
79 | 79 | |
80 | - if (! empty($input['capacity'])) { |
|
80 | + if ( ! empty($input['capacity'])) { |
|
81 | 81 | $args['VNU_capacity'] = absint($input['capacity']); |
82 | 82 | } |
83 | 83 | |
84 | - if (! empty($input['phone'])) { |
|
84 | + if ( ! empty($input['phone'])) { |
|
85 | 85 | $args['VNU_phone'] = sanitize_text_field($input['phone']); |
86 | 86 | } |
87 | 87 | |
88 | - if (! empty($input['virtualPhone'])) { |
|
88 | + if ( ! empty($input['virtualPhone'])) { |
|
89 | 89 | $args['VNU_virtual_phone'] = sanitize_text_field($input['virtualPhone']); |
90 | 90 | } |
91 | 91 | |
92 | - if (! empty($input['url'])) { |
|
92 | + if ( ! empty($input['url'])) { |
|
93 | 93 | $args['VNU_url'] = sanitize_text_field($input['url']); |
94 | 94 | } |
95 | 95 | |
96 | - if (! empty($input['virtualUrl'])) { |
|
96 | + if ( ! empty($input['virtualUrl'])) { |
|
97 | 97 | $args['VNU_virtual_url'] = sanitize_text_field($input['virtualUrl']); |
98 | 98 | } |
99 | 99 | |
100 | - if (! empty($input['googleMapLink'])) { |
|
100 | + if ( ! empty($input['googleMapLink'])) { |
|
101 | 101 | $args['VNU_google_map_link'] = sanitize_text_field($input['googleMapLink']); |
102 | 102 | } |
103 | 103 | |
104 | - if (! empty($input['enableForGmap'])) { |
|
104 | + if ( ! empty($input['enableForGmap'])) { |
|
105 | 105 | $args['VNU_enable_for_gmap'] = (bool) $input['enableForGmap']; |
106 | 106 | } |
107 | 107 |
@@ -20,82 +20,82 @@ |
||
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->setName($this->namespace . 'State'); |
|
31 | - $this->setDescription(__('A state', 'event_espresso')); |
|
32 | - $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->setName($this->namespace . 'State'); |
|
31 | + $this->setDescription(__('A state', 'event_espresso')); |
|
32 | + $this->setIsCustomPostType(false); |
|
33 | 33 | |
34 | - parent::__construct($state_model); |
|
35 | - } |
|
34 | + parent::__construct($state_model); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * @return GraphQLFieldInterface[] |
|
40 | - */ |
|
41 | - public function getFields(): array |
|
42 | - { |
|
43 | - $fields = [ |
|
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 | - 'dbId', |
|
52 | - ['non_null' => 'Int'], |
|
53 | - 'ID', |
|
54 | - esc_html__('State ID', 'event_espresso') |
|
55 | - ), |
|
56 | - new GraphQLField( |
|
57 | - 'abbreviation', |
|
58 | - 'String', |
|
59 | - 'abbrev', |
|
60 | - esc_html__('State Abbreviation', 'event_espresso') |
|
61 | - ), |
|
62 | - new GraphQLOutputField( |
|
63 | - 'cacheId', |
|
64 | - ['non_null' => 'String'], |
|
65 | - null, |
|
66 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
67 | - ), |
|
68 | - new GraphQLField( |
|
69 | - 'name', |
|
70 | - 'String', |
|
71 | - 'name', |
|
72 | - esc_html__('State Name', 'event_espresso') |
|
73 | - ), |
|
74 | - new GraphQLField( |
|
75 | - 'isActive', |
|
76 | - 'Boolean', |
|
77 | - 'active', |
|
78 | - esc_html__('State Active Flag', 'event_espresso') |
|
79 | - ), |
|
80 | - new GraphQLOutputField( |
|
81 | - 'country', |
|
82 | - $this->namespace . 'Country', |
|
83 | - null, |
|
84 | - esc_html__('Country for the state', 'event_espresso') |
|
85 | - ), |
|
86 | - new GraphQLInputField( |
|
87 | - 'country', |
|
88 | - 'String', |
|
89 | - null, |
|
90 | - esc_html__('Country ISO Code', 'event_espresso') |
|
91 | - ), |
|
92 | - ]; |
|
38 | + /** |
|
39 | + * @return GraphQLFieldInterface[] |
|
40 | + */ |
|
41 | + public function getFields(): array |
|
42 | + { |
|
43 | + $fields = [ |
|
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 | + 'dbId', |
|
52 | + ['non_null' => 'Int'], |
|
53 | + 'ID', |
|
54 | + esc_html__('State ID', 'event_espresso') |
|
55 | + ), |
|
56 | + new GraphQLField( |
|
57 | + 'abbreviation', |
|
58 | + 'String', |
|
59 | + 'abbrev', |
|
60 | + esc_html__('State Abbreviation', 'event_espresso') |
|
61 | + ), |
|
62 | + new GraphQLOutputField( |
|
63 | + 'cacheId', |
|
64 | + ['non_null' => 'String'], |
|
65 | + null, |
|
66 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
67 | + ), |
|
68 | + new GraphQLField( |
|
69 | + 'name', |
|
70 | + 'String', |
|
71 | + 'name', |
|
72 | + esc_html__('State Name', 'event_espresso') |
|
73 | + ), |
|
74 | + new GraphQLField( |
|
75 | + 'isActive', |
|
76 | + 'Boolean', |
|
77 | + 'active', |
|
78 | + esc_html__('State Active Flag', 'event_espresso') |
|
79 | + ), |
|
80 | + new GraphQLOutputField( |
|
81 | + 'country', |
|
82 | + $this->namespace . 'Country', |
|
83 | + null, |
|
84 | + esc_html__('Country for the state', 'event_espresso') |
|
85 | + ), |
|
86 | + new GraphQLInputField( |
|
87 | + 'country', |
|
88 | + 'String', |
|
89 | + null, |
|
90 | + esc_html__('Country ISO Code', 'event_espresso') |
|
91 | + ), |
|
92 | + ]; |
|
93 | 93 | |
94 | - return apply_filters( |
|
95 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__state_fields', |
|
96 | - $fields, |
|
97 | - $this->name, |
|
98 | - $this->model |
|
99 | - ); |
|
100 | - } |
|
94 | + return apply_filters( |
|
95 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__state_fields', |
|
96 | + $fields, |
|
97 | + $this->name, |
|
98 | + $this->model |
|
99 | + ); |
|
100 | + } |
|
101 | 101 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function __construct(EEM_State $state_model) |
29 | 29 | { |
30 | - $this->setName($this->namespace . 'State'); |
|
30 | + $this->setName($this->namespace.'State'); |
|
31 | 31 | $this->setDescription(__('A state', 'event_espresso')); |
32 | 32 | $this->setIsCustomPostType(false); |
33 | 33 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | ), |
80 | 80 | new GraphQLOutputField( |
81 | 81 | 'country', |
82 | - $this->namespace . 'Country', |
|
82 | + $this->namespace.'Country', |
|
83 | 83 | null, |
84 | 84 | esc_html__('Country for the state', 'event_espresso') |
85 | 85 | ), |
@@ -34,390 +34,390 @@ |
||
34 | 34 | class Ticket extends TypeBase |
35 | 35 | { |
36 | 36 | |
37 | - /** |
|
38 | - * Ticket constructor. |
|
39 | - * |
|
40 | - * @param EEM_Ticket $ticket_model |
|
41 | - */ |
|
42 | - public function __construct(EEM_Ticket $ticket_model) |
|
43 | - { |
|
44 | - $this->setName($this->namespace . 'Ticket'); |
|
45 | - $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
46 | - $this->setIsCustomPostType(false); |
|
47 | - parent::__construct($ticket_model); |
|
48 | - } |
|
37 | + /** |
|
38 | + * Ticket constructor. |
|
39 | + * |
|
40 | + * @param EEM_Ticket $ticket_model |
|
41 | + */ |
|
42 | + public function __construct(EEM_Ticket $ticket_model) |
|
43 | + { |
|
44 | + $this->setName($this->namespace . 'Ticket'); |
|
45 | + $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
|
46 | + $this->setIsCustomPostType(false); |
|
47 | + parent::__construct($ticket_model); |
|
48 | + } |
|
49 | 49 | |
50 | 50 | |
51 | - /** |
|
52 | - * @return GraphQLFieldInterface[] |
|
53 | - */ |
|
54 | - public function getFields(): array |
|
55 | - { |
|
56 | - $fields = [ |
|
57 | - new GraphQLField( |
|
58 | - 'id', |
|
59 | - ['non_null' => 'ID'], |
|
60 | - null, |
|
61 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLOutputField( |
|
64 | - 'dbId', |
|
65 | - ['non_null' => 'Int'], |
|
66 | - 'ID', |
|
67 | - esc_html__('Ticket ID', 'event_espresso') |
|
68 | - ), |
|
69 | - new GraphQLOutputField( |
|
70 | - 'cacheId', |
|
71 | - ['non_null' => 'String'], |
|
72 | - null, |
|
73 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
74 | - ), |
|
75 | - new GraphQLInputField( |
|
76 | - 'datetimes', |
|
77 | - ['list_of' => 'ID'], |
|
78 | - null, |
|
79 | - sprintf( |
|
80 | - '%1$s %2$s', |
|
81 | - esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
82 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
83 | - ) |
|
84 | - ), |
|
85 | - new GraphQLField( |
|
86 | - 'description', |
|
87 | - 'String', |
|
88 | - 'description', |
|
89 | - esc_html__('Description of Ticket', 'event_espresso') |
|
90 | - ), |
|
91 | - new GraphQLField( |
|
92 | - 'endDate', |
|
93 | - 'String', |
|
94 | - 'end_date', |
|
95 | - esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
96 | - [$this, 'formatDatetime'] |
|
97 | - ), |
|
98 | - new GraphQLOutputField( |
|
99 | - 'event', |
|
100 | - $this->namespace . 'Event', |
|
101 | - null, |
|
102 | - esc_html__('Event of the ticket.', 'event_espresso') |
|
103 | - ), |
|
104 | - new GraphQLField( |
|
105 | - 'isDefault', |
|
106 | - 'Boolean', |
|
107 | - 'is_default', |
|
108 | - esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
109 | - ), |
|
110 | - new GraphQLOutputField( |
|
111 | - 'isExpired', |
|
112 | - 'Boolean', |
|
113 | - 'is_expired', |
|
114 | - esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
115 | - ), |
|
116 | - new GraphQLOutputField( |
|
117 | - 'isFree', |
|
118 | - 'Boolean', |
|
119 | - 'is_free', |
|
120 | - esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
121 | - ), |
|
122 | - new GraphQLOutputField( |
|
123 | - 'isOnSale', |
|
124 | - 'Boolean', |
|
125 | - 'is_on_sale', |
|
126 | - esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
127 | - ), |
|
128 | - new GraphQLOutputField( |
|
129 | - 'isPending', |
|
130 | - 'Boolean', |
|
131 | - 'is_pending', |
|
132 | - esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
133 | - ), |
|
134 | - new GraphQLField( |
|
135 | - 'isRequired', |
|
136 | - 'Boolean', |
|
137 | - 'required', |
|
138 | - esc_html__( |
|
139 | - 'Flag indicating whether this ticket must be purchased with a transaction', |
|
140 | - 'event_espresso' |
|
141 | - ) |
|
142 | - ), |
|
143 | - new GraphQLOutputField( |
|
144 | - 'isSoldOut', |
|
145 | - 'Boolean', |
|
146 | - null, |
|
147 | - esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
148 | - null, |
|
149 | - [$this, 'getIsSoldOut'] |
|
150 | - ), |
|
151 | - new GraphQLField( |
|
152 | - 'isTaxable', |
|
153 | - 'Boolean', |
|
154 | - 'taxable', |
|
155 | - esc_html__( |
|
156 | - 'Flag indicating whether there is tax applied on this ticket', |
|
157 | - 'event_espresso' |
|
158 | - ) |
|
159 | - ), |
|
160 | - new GraphQLField( |
|
161 | - 'isTrashed', |
|
162 | - 'Boolean', |
|
163 | - 'deleted', |
|
164 | - esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
165 | - ), |
|
166 | - new GraphQLField( |
|
167 | - 'max', |
|
168 | - 'Int', |
|
169 | - 'max', |
|
170 | - esc_html__( |
|
171 | - 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
172 | - 'event_espresso' |
|
173 | - ), |
|
174 | - [$this, 'parseInfiniteValue'] |
|
175 | - ), |
|
176 | - new GraphQLField( |
|
177 | - 'min', |
|
178 | - 'Int', |
|
179 | - 'min', |
|
180 | - esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
181 | - ), |
|
182 | - new GraphQLField( |
|
183 | - 'name', |
|
184 | - 'String', |
|
185 | - 'name', |
|
186 | - esc_html__('Ticket Name', 'event_espresso') |
|
187 | - ), |
|
188 | - new GraphQLField( |
|
189 | - 'order', |
|
190 | - 'Int', |
|
191 | - 'order', |
|
192 | - esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
193 | - ), |
|
194 | - new GraphQLOutputField( |
|
195 | - 'parent', |
|
196 | - $this->name(), |
|
197 | - null, |
|
198 | - esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
199 | - ), |
|
200 | - new GraphQLInputField( |
|
201 | - 'parent', |
|
202 | - 'ID', |
|
203 | - null, |
|
204 | - esc_html__('The parent ticket ID', 'event_espresso') |
|
205 | - ), |
|
206 | - new GraphQLField( |
|
207 | - 'price', |
|
208 | - 'Float', |
|
209 | - 'price', |
|
210 | - esc_html__('Final calculated price for ticket', 'event_espresso') |
|
211 | - ), |
|
212 | - new GraphQLInputField( |
|
213 | - 'prices', |
|
214 | - ['list_of' => 'ID'], |
|
215 | - null, |
|
216 | - sprintf( |
|
217 | - '%1$s %2$s', |
|
218 | - esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
219 | - esc_html__('Ignored if empty.', 'event_espresso') |
|
220 | - ) |
|
221 | - ), |
|
222 | - new GraphQLField( |
|
223 | - 'quantity', |
|
224 | - 'Int', |
|
225 | - 'qty', |
|
226 | - esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
227 | - [$this, 'parseInfiniteValue'] |
|
228 | - ), |
|
229 | - new GraphQLOutputField( |
|
230 | - 'registrationCount', |
|
231 | - 'Int', |
|
232 | - 'count_registrations', |
|
233 | - esc_html__('Number of registrations for the ticket', 'event_espresso') |
|
234 | - ), |
|
235 | - new GraphQLField( |
|
236 | - 'reserved', |
|
237 | - 'Int', |
|
238 | - 'reserved', |
|
239 | - esc_html__( |
|
240 | - 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
241 | - 'event_espresso' |
|
242 | - ) |
|
243 | - ), |
|
244 | - new GraphQLField( |
|
245 | - 'reverseCalculate', |
|
246 | - 'Boolean', |
|
247 | - 'reverse_calculate', |
|
248 | - esc_html__( |
|
249 | - 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
250 | - 'event_espresso' |
|
251 | - ) |
|
252 | - ), |
|
253 | - new GraphQLField( |
|
254 | - 'row', |
|
255 | - 'Int', |
|
256 | - 'row', |
|
257 | - esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
258 | - ), |
|
259 | - new GraphQLField( |
|
260 | - 'sold', |
|
261 | - 'Int', |
|
262 | - 'sold', |
|
263 | - esc_html__('Number of this ticket sold', 'event_espresso') |
|
264 | - ), |
|
265 | - new GraphQLOutputField( |
|
266 | - 'status', |
|
267 | - $this->namespace . 'TicketStatusEnum', |
|
268 | - 'ticket_status', |
|
269 | - esc_html__('Ticket status', 'event_espresso') |
|
270 | - ), |
|
271 | - new GraphQLField( |
|
272 | - 'startDate', |
|
273 | - 'String', |
|
274 | - 'start_date', |
|
275 | - esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
276 | - [$this, 'formatDatetime'] |
|
277 | - ), |
|
278 | - new GraphQLField( |
|
279 | - 'uses', |
|
280 | - 'Int', |
|
281 | - 'uses', |
|
282 | - esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
283 | - [$this, 'parseInfiniteValue'] |
|
284 | - ), |
|
285 | - new GraphQLField( |
|
286 | - 'visibility', |
|
287 | - $this->namespace . 'TicketVisibilityEnum', |
|
288 | - 'visibility', |
|
289 | - esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
290 | - ), |
|
291 | - new GraphQLOutputField( |
|
292 | - 'wpUser', |
|
293 | - 'User', |
|
294 | - null, |
|
295 | - esc_html__('Ticket Creator', 'event_espresso') |
|
296 | - ), |
|
297 | - new GraphQLOutputField( |
|
298 | - 'userId', |
|
299 | - 'ID', |
|
300 | - null, |
|
301 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
302 | - ), |
|
303 | - new GraphQLInputField( |
|
304 | - 'wpUser', |
|
305 | - 'Int', |
|
306 | - null, |
|
307 | - esc_html__('Ticket Creator ID', 'event_espresso') |
|
308 | - ), |
|
309 | - ]; |
|
51 | + /** |
|
52 | + * @return GraphQLFieldInterface[] |
|
53 | + */ |
|
54 | + public function getFields(): array |
|
55 | + { |
|
56 | + $fields = [ |
|
57 | + new GraphQLField( |
|
58 | + 'id', |
|
59 | + ['non_null' => 'ID'], |
|
60 | + null, |
|
61 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLOutputField( |
|
64 | + 'dbId', |
|
65 | + ['non_null' => 'Int'], |
|
66 | + 'ID', |
|
67 | + esc_html__('Ticket ID', 'event_espresso') |
|
68 | + ), |
|
69 | + new GraphQLOutputField( |
|
70 | + 'cacheId', |
|
71 | + ['non_null' => 'String'], |
|
72 | + null, |
|
73 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
74 | + ), |
|
75 | + new GraphQLInputField( |
|
76 | + 'datetimes', |
|
77 | + ['list_of' => 'ID'], |
|
78 | + null, |
|
79 | + sprintf( |
|
80 | + '%1$s %2$s', |
|
81 | + esc_html__('Globally unique IDs of the datetimes related to the ticket.', 'event_espresso'), |
|
82 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
83 | + ) |
|
84 | + ), |
|
85 | + new GraphQLField( |
|
86 | + 'description', |
|
87 | + 'String', |
|
88 | + 'description', |
|
89 | + esc_html__('Description of Ticket', 'event_espresso') |
|
90 | + ), |
|
91 | + new GraphQLField( |
|
92 | + 'endDate', |
|
93 | + 'String', |
|
94 | + 'end_date', |
|
95 | + esc_html__('End date and time of the Ticket', 'event_espresso'), |
|
96 | + [$this, 'formatDatetime'] |
|
97 | + ), |
|
98 | + new GraphQLOutputField( |
|
99 | + 'event', |
|
100 | + $this->namespace . 'Event', |
|
101 | + null, |
|
102 | + esc_html__('Event of the ticket.', 'event_espresso') |
|
103 | + ), |
|
104 | + new GraphQLField( |
|
105 | + 'isDefault', |
|
106 | + 'Boolean', |
|
107 | + 'is_default', |
|
108 | + esc_html__('Flag indicating that this ticket is a default ticket', 'event_espresso') |
|
109 | + ), |
|
110 | + new GraphQLOutputField( |
|
111 | + 'isExpired', |
|
112 | + 'Boolean', |
|
113 | + 'is_expired', |
|
114 | + esc_html__('Flag indicating ticket is no longer available because its available dates have expired', 'event_espresso') |
|
115 | + ), |
|
116 | + new GraphQLOutputField( |
|
117 | + 'isFree', |
|
118 | + 'Boolean', |
|
119 | + 'is_free', |
|
120 | + esc_html__('Flag indicating whether the ticket is free.', 'event_espresso') |
|
121 | + ), |
|
122 | + new GraphQLOutputField( |
|
123 | + 'isOnSale', |
|
124 | + 'Boolean', |
|
125 | + 'is_on_sale', |
|
126 | + esc_html__('Flag indicating ticket ticket is on sale or not', 'event_espresso') |
|
127 | + ), |
|
128 | + new GraphQLOutputField( |
|
129 | + 'isPending', |
|
130 | + 'Boolean', |
|
131 | + 'is_pending', |
|
132 | + esc_html__('Flag indicating ticket is yet to go on sale or not', 'event_espresso') |
|
133 | + ), |
|
134 | + new GraphQLField( |
|
135 | + 'isRequired', |
|
136 | + 'Boolean', |
|
137 | + 'required', |
|
138 | + esc_html__( |
|
139 | + 'Flag indicating whether this ticket must be purchased with a transaction', |
|
140 | + 'event_espresso' |
|
141 | + ) |
|
142 | + ), |
|
143 | + new GraphQLOutputField( |
|
144 | + 'isSoldOut', |
|
145 | + 'Boolean', |
|
146 | + null, |
|
147 | + esc_html__('Flag indicating whether the ticket is sold out', 'event_espresso'), |
|
148 | + null, |
|
149 | + [$this, 'getIsSoldOut'] |
|
150 | + ), |
|
151 | + new GraphQLField( |
|
152 | + 'isTaxable', |
|
153 | + 'Boolean', |
|
154 | + 'taxable', |
|
155 | + esc_html__( |
|
156 | + 'Flag indicating whether there is tax applied on this ticket', |
|
157 | + 'event_espresso' |
|
158 | + ) |
|
159 | + ), |
|
160 | + new GraphQLField( |
|
161 | + 'isTrashed', |
|
162 | + 'Boolean', |
|
163 | + 'deleted', |
|
164 | + esc_html__('Flag indicating ticket has been trashed.', 'event_espresso') |
|
165 | + ), |
|
166 | + new GraphQLField( |
|
167 | + 'max', |
|
168 | + 'Int', |
|
169 | + 'max', |
|
170 | + esc_html__( |
|
171 | + 'Maximum quantity of this ticket that can be purchased in one transaction', |
|
172 | + 'event_espresso' |
|
173 | + ), |
|
174 | + [$this, 'parseInfiniteValue'] |
|
175 | + ), |
|
176 | + new GraphQLField( |
|
177 | + 'min', |
|
178 | + 'Int', |
|
179 | + 'min', |
|
180 | + esc_html__('Minimum quantity of this ticket that must be purchased', 'event_espresso') |
|
181 | + ), |
|
182 | + new GraphQLField( |
|
183 | + 'name', |
|
184 | + 'String', |
|
185 | + 'name', |
|
186 | + esc_html__('Ticket Name', 'event_espresso') |
|
187 | + ), |
|
188 | + new GraphQLField( |
|
189 | + 'order', |
|
190 | + 'Int', |
|
191 | + 'order', |
|
192 | + esc_html__('The order in which the Datetime is displayed', 'event_espresso') |
|
193 | + ), |
|
194 | + new GraphQLOutputField( |
|
195 | + 'parent', |
|
196 | + $this->name(), |
|
197 | + null, |
|
198 | + esc_html__('The parent ticket of the current ticket', 'event_espresso') |
|
199 | + ), |
|
200 | + new GraphQLInputField( |
|
201 | + 'parent', |
|
202 | + 'ID', |
|
203 | + null, |
|
204 | + esc_html__('The parent ticket ID', 'event_espresso') |
|
205 | + ), |
|
206 | + new GraphQLField( |
|
207 | + 'price', |
|
208 | + 'Float', |
|
209 | + 'price', |
|
210 | + esc_html__('Final calculated price for ticket', 'event_espresso') |
|
211 | + ), |
|
212 | + new GraphQLInputField( |
|
213 | + 'prices', |
|
214 | + ['list_of' => 'ID'], |
|
215 | + null, |
|
216 | + sprintf( |
|
217 | + '%1$s %2$s', |
|
218 | + esc_html__('Globally unique IDs of the prices related to the ticket.', 'event_espresso'), |
|
219 | + esc_html__('Ignored if empty.', 'event_espresso') |
|
220 | + ) |
|
221 | + ), |
|
222 | + new GraphQLField( |
|
223 | + 'quantity', |
|
224 | + 'Int', |
|
225 | + 'qty', |
|
226 | + esc_html__('Quantity of this ticket that is available', 'event_espresso'), |
|
227 | + [$this, 'parseInfiniteValue'] |
|
228 | + ), |
|
229 | + new GraphQLOutputField( |
|
230 | + 'registrationCount', |
|
231 | + 'Int', |
|
232 | + 'count_registrations', |
|
233 | + esc_html__('Number of registrations for the ticket', 'event_espresso') |
|
234 | + ), |
|
235 | + new GraphQLField( |
|
236 | + 'reserved', |
|
237 | + 'Int', |
|
238 | + 'reserved', |
|
239 | + esc_html__( |
|
240 | + 'Quantity of this ticket that is reserved, but not yet fully purchased', |
|
241 | + 'event_espresso' |
|
242 | + ) |
|
243 | + ), |
|
244 | + new GraphQLField( |
|
245 | + 'reverseCalculate', |
|
246 | + 'Boolean', |
|
247 | + 'reverse_calculate', |
|
248 | + esc_html__( |
|
249 | + 'Flag indicating whether ticket calculations should run in reverse and calculate the base ticket price from the provided ticket total.', |
|
250 | + 'event_espresso' |
|
251 | + ) |
|
252 | + ), |
|
253 | + new GraphQLField( |
|
254 | + 'row', |
|
255 | + 'Int', |
|
256 | + 'row', |
|
257 | + esc_html__('How tickets are displayed in the ui', 'event_espresso') |
|
258 | + ), |
|
259 | + new GraphQLField( |
|
260 | + 'sold', |
|
261 | + 'Int', |
|
262 | + 'sold', |
|
263 | + esc_html__('Number of this ticket sold', 'event_espresso') |
|
264 | + ), |
|
265 | + new GraphQLOutputField( |
|
266 | + 'status', |
|
267 | + $this->namespace . 'TicketStatusEnum', |
|
268 | + 'ticket_status', |
|
269 | + esc_html__('Ticket status', 'event_espresso') |
|
270 | + ), |
|
271 | + new GraphQLField( |
|
272 | + 'startDate', |
|
273 | + 'String', |
|
274 | + 'start_date', |
|
275 | + esc_html__('Start date and time of the Ticket', 'event_espresso'), |
|
276 | + [$this, 'formatDatetime'] |
|
277 | + ), |
|
278 | + new GraphQLField( |
|
279 | + 'uses', |
|
280 | + 'Int', |
|
281 | + 'uses', |
|
282 | + esc_html__('Number of datetimes this ticket can be used at', 'event_espresso'), |
|
283 | + [$this, 'parseInfiniteValue'] |
|
284 | + ), |
|
285 | + new GraphQLField( |
|
286 | + 'visibility', |
|
287 | + $this->namespace . 'TicketVisibilityEnum', |
|
288 | + 'visibility', |
|
289 | + esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
|
290 | + ), |
|
291 | + new GraphQLOutputField( |
|
292 | + 'wpUser', |
|
293 | + 'User', |
|
294 | + null, |
|
295 | + esc_html__('Ticket Creator', 'event_espresso') |
|
296 | + ), |
|
297 | + new GraphQLOutputField( |
|
298 | + 'userId', |
|
299 | + 'ID', |
|
300 | + null, |
|
301 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
302 | + ), |
|
303 | + new GraphQLInputField( |
|
304 | + 'wpUser', |
|
305 | + 'Int', |
|
306 | + null, |
|
307 | + esc_html__('Ticket Creator ID', 'event_espresso') |
|
308 | + ), |
|
309 | + ]; |
|
310 | 310 | |
311 | - return apply_filters( |
|
312 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
313 | - $fields, |
|
314 | - $this->name, |
|
315 | - $this->model |
|
316 | - ); |
|
317 | - } |
|
311 | + return apply_filters( |
|
312 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__ticket_fields', |
|
313 | + $fields, |
|
314 | + $this->name, |
|
315 | + $this->model |
|
316 | + ); |
|
317 | + } |
|
318 | 318 | |
319 | 319 | |
320 | - /** |
|
321 | - * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
322 | - * @param array $args The inputArgs on the field |
|
323 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
324 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
325 | - * @return bool |
|
326 | - * @throws Exception |
|
327 | - * @throws InvalidArgumentException |
|
328 | - * @throws InvalidDataTypeException |
|
329 | - * @throws InvalidInterfaceException |
|
330 | - * @throws ReflectionException |
|
331 | - * @throws UserError |
|
332 | - * @throws UnexpectedEntityException |
|
333 | - * @since $VID:$ |
|
334 | - */ |
|
335 | - public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
336 | - { |
|
337 | - return $source->ticket_status() === EE_Ticket::sold_out; |
|
338 | - } |
|
320 | + /** |
|
321 | + * @param EE_Ticket $source The source that's passed down the GraphQL queries |
|
322 | + * @param array $args The inputArgs on the field |
|
323 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
324 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
325 | + * @return bool |
|
326 | + * @throws Exception |
|
327 | + * @throws InvalidArgumentException |
|
328 | + * @throws InvalidDataTypeException |
|
329 | + * @throws InvalidInterfaceException |
|
330 | + * @throws ReflectionException |
|
331 | + * @throws UserError |
|
332 | + * @throws UnexpectedEntityException |
|
333 | + * @since $VID:$ |
|
334 | + */ |
|
335 | + public function getIsSoldOut(EE_Ticket $source, array $args, AppContext $context, ResolveInfo $info): bool |
|
336 | + { |
|
337 | + return $source->ticket_status() === EE_Ticket::sold_out; |
|
338 | + } |
|
339 | 339 | |
340 | 340 | |
341 | - /** |
|
342 | - * @param array $inputFields The mutation input fields. |
|
343 | - * @throws InvalidArgumentException |
|
344 | - * @throws ReflectionException |
|
345 | - * @throws Exception |
|
346 | - */ |
|
347 | - public function registerMutations(array $inputFields) |
|
348 | - { |
|
349 | - register_graphql_input_type( |
|
350 | - 'Update' . $this->name() . 'BaseInput', |
|
351 | - [ |
|
352 | - 'fields' => $inputFields, |
|
353 | - ] |
|
354 | - ); |
|
355 | - // Register mutation to update an entity. |
|
356 | - register_graphql_mutation( |
|
357 | - 'update' . $this->name(), |
|
358 | - [ |
|
359 | - 'inputFields' => $inputFields, |
|
360 | - 'outputFields' => [ |
|
361 | - lcfirst($this->name()) => [ |
|
362 | - 'type' => $this->name(), |
|
363 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
364 | - ], |
|
365 | - ], |
|
366 | - 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
367 | - ] |
|
368 | - ); |
|
369 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
370 | - // Register mutation to update an entity. |
|
371 | - register_graphql_mutation( |
|
372 | - 'bulkUpdate' . $this->name(), |
|
373 | - array_merge( |
|
374 | - Datetime::bulkUpdateBaseConfig($base_input), |
|
375 | - [ |
|
376 | - 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
377 | - ] |
|
378 | - ) |
|
379 | - ); |
|
380 | - // Register mutation to delete an entity. |
|
381 | - register_graphql_mutation( |
|
382 | - 'delete' . $this->name(), |
|
383 | - [ |
|
384 | - 'inputFields' => [ |
|
385 | - 'id' => $inputFields['id'], |
|
386 | - 'deletePermanently' => [ |
|
387 | - 'type' => 'Boolean', |
|
388 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
389 | - ], |
|
390 | - ], |
|
391 | - 'outputFields' => [ |
|
392 | - lcfirst($this->name()) => [ |
|
393 | - 'type' => $this->name(), |
|
394 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
395 | - 'resolve' => static function ($payload) { |
|
396 | - $deleted = (object) $payload['deleted']; |
|
341 | + /** |
|
342 | + * @param array $inputFields The mutation input fields. |
|
343 | + * @throws InvalidArgumentException |
|
344 | + * @throws ReflectionException |
|
345 | + * @throws Exception |
|
346 | + */ |
|
347 | + public function registerMutations(array $inputFields) |
|
348 | + { |
|
349 | + register_graphql_input_type( |
|
350 | + 'Update' . $this->name() . 'BaseInput', |
|
351 | + [ |
|
352 | + 'fields' => $inputFields, |
|
353 | + ] |
|
354 | + ); |
|
355 | + // Register mutation to update an entity. |
|
356 | + register_graphql_mutation( |
|
357 | + 'update' . $this->name(), |
|
358 | + [ |
|
359 | + 'inputFields' => $inputFields, |
|
360 | + 'outputFields' => [ |
|
361 | + lcfirst($this->name()) => [ |
|
362 | + 'type' => $this->name(), |
|
363 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
364 | + ], |
|
365 | + ], |
|
366 | + 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
|
367 | + ] |
|
368 | + ); |
|
369 | + $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
370 | + // Register mutation to update an entity. |
|
371 | + register_graphql_mutation( |
|
372 | + 'bulkUpdate' . $this->name(), |
|
373 | + array_merge( |
|
374 | + Datetime::bulkUpdateBaseConfig($base_input), |
|
375 | + [ |
|
376 | + 'mutateAndGetPayload' => TicketBulkUpdate::mutateAndGetPayload($this->model, $this), |
|
377 | + ] |
|
378 | + ) |
|
379 | + ); |
|
380 | + // Register mutation to delete an entity. |
|
381 | + register_graphql_mutation( |
|
382 | + 'delete' . $this->name(), |
|
383 | + [ |
|
384 | + 'inputFields' => [ |
|
385 | + 'id' => $inputFields['id'], |
|
386 | + 'deletePermanently' => [ |
|
387 | + 'type' => 'Boolean', |
|
388 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
389 | + ], |
|
390 | + ], |
|
391 | + 'outputFields' => [ |
|
392 | + lcfirst($this->name()) => [ |
|
393 | + 'type' => $this->name(), |
|
394 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
395 | + 'resolve' => static function ($payload) { |
|
396 | + $deleted = (object) $payload['deleted']; |
|
397 | 397 | |
398 | - return ! empty($deleted) ? $deleted : null; |
|
399 | - }, |
|
400 | - ], |
|
401 | - ], |
|
402 | - 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
403 | - ] |
|
404 | - ); |
|
398 | + return ! empty($deleted) ? $deleted : null; |
|
399 | + }, |
|
400 | + ], |
|
401 | + ], |
|
402 | + 'mutateAndGetPayload' => TicketDelete::mutateAndGetPayload($this->model, $this), |
|
403 | + ] |
|
404 | + ); |
|
405 | 405 | |
406 | - // remove primary key from input. |
|
407 | - unset($inputFields['id']); |
|
408 | - // Register mutation to update an entity. |
|
409 | - register_graphql_mutation( |
|
410 | - 'create' . $this->name(), |
|
411 | - [ |
|
412 | - 'inputFields' => $inputFields, |
|
413 | - 'outputFields' => [ |
|
414 | - lcfirst($this->name()) => [ |
|
415 | - 'type' => $this->name(), |
|
416 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
417 | - ], |
|
418 | - ], |
|
419 | - 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
420 | - ] |
|
421 | - ); |
|
422 | - } |
|
406 | + // remove primary key from input. |
|
407 | + unset($inputFields['id']); |
|
408 | + // Register mutation to update an entity. |
|
409 | + register_graphql_mutation( |
|
410 | + 'create' . $this->name(), |
|
411 | + [ |
|
412 | + 'inputFields' => $inputFields, |
|
413 | + 'outputFields' => [ |
|
414 | + lcfirst($this->name()) => [ |
|
415 | + 'type' => $this->name(), |
|
416 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
417 | + ], |
|
418 | + ], |
|
419 | + 'mutateAndGetPayload' => TicketCreate::mutateAndGetPayload($this->model, $this), |
|
420 | + ] |
|
421 | + ); |
|
422 | + } |
|
423 | 423 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function __construct(EEM_Ticket $ticket_model) |
43 | 43 | { |
44 | - $this->setName($this->namespace . 'Ticket'); |
|
44 | + $this->setName($this->namespace.'Ticket'); |
|
45 | 45 | $this->setDescription(__('A ticket for an event date', 'event_espresso')); |
46 | 46 | $this->setIsCustomPostType(false); |
47 | 47 | parent::__construct($ticket_model); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | ), |
98 | 98 | new GraphQLOutputField( |
99 | 99 | 'event', |
100 | - $this->namespace . 'Event', |
|
100 | + $this->namespace.'Event', |
|
101 | 101 | null, |
102 | 102 | esc_html__('Event of the ticket.', 'event_espresso') |
103 | 103 | ), |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ), |
265 | 265 | new GraphQLOutputField( |
266 | 266 | 'status', |
267 | - $this->namespace . 'TicketStatusEnum', |
|
267 | + $this->namespace.'TicketStatusEnum', |
|
268 | 268 | 'ticket_status', |
269 | 269 | esc_html__('Ticket status', 'event_espresso') |
270 | 270 | ), |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | ), |
285 | 285 | new GraphQLField( |
286 | 286 | 'visibility', |
287 | - $this->namespace . 'TicketVisibilityEnum', |
|
287 | + $this->namespace.'TicketVisibilityEnum', |
|
288 | 288 | 'visibility', |
289 | 289 | esc_html__('Where the ticket can be viewed throughout the UI', 'event_espresso') |
290 | 290 | ), |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function registerMutations(array $inputFields) |
348 | 348 | { |
349 | 349 | register_graphql_input_type( |
350 | - 'Update' . $this->name() . 'BaseInput', |
|
350 | + 'Update'.$this->name().'BaseInput', |
|
351 | 351 | [ |
352 | 352 | 'fields' => $inputFields, |
353 | 353 | ] |
354 | 354 | ); |
355 | 355 | // Register mutation to update an entity. |
356 | 356 | register_graphql_mutation( |
357 | - 'update' . $this->name(), |
|
357 | + 'update'.$this->name(), |
|
358 | 358 | [ |
359 | 359 | 'inputFields' => $inputFields, |
360 | 360 | 'outputFields' => [ |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | 'mutateAndGetPayload' => TicketUpdate::mutateAndGetPayload($this->model, $this), |
367 | 367 | ] |
368 | 368 | ); |
369 | - $base_input = 'Update' . $this->name() . 'BaseInput'; |
|
369 | + $base_input = 'Update'.$this->name().'BaseInput'; |
|
370 | 370 | // Register mutation to update an entity. |
371 | 371 | register_graphql_mutation( |
372 | - 'bulkUpdate' . $this->name(), |
|
372 | + 'bulkUpdate'.$this->name(), |
|
373 | 373 | array_merge( |
374 | 374 | Datetime::bulkUpdateBaseConfig($base_input), |
375 | 375 | [ |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | ); |
380 | 380 | // Register mutation to delete an entity. |
381 | 381 | register_graphql_mutation( |
382 | - 'delete' . $this->name(), |
|
382 | + 'delete'.$this->name(), |
|
383 | 383 | [ |
384 | 384 | 'inputFields' => [ |
385 | 385 | 'id' => $inputFields['id'], |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | lcfirst($this->name()) => [ |
393 | 393 | 'type' => $this->name(), |
394 | 394 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
395 | - 'resolve' => static function ($payload) { |
|
395 | + 'resolve' => static function($payload) { |
|
396 | 396 | $deleted = (object) $payload['deleted']; |
397 | 397 | |
398 | 398 | return ! empty($deleted) ? $deleted : null; |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | unset($inputFields['id']); |
408 | 408 | // Register mutation to update an entity. |
409 | 409 | register_graphql_mutation( |
410 | - 'create' . $this->name(), |
|
410 | + 'create'.$this->name(), |
|
411 | 411 | [ |
412 | 412 | 'inputFields' => $inputFields, |
413 | 413 | 'outputFields' => [ |
@@ -26,228 +26,228 @@ |
||
26 | 26 | class Price extends TypeBase |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * Price constructor. |
|
31 | - * |
|
32 | - * @param EEM_Price $price_model |
|
33 | - */ |
|
34 | - public function __construct(EEM_Price $price_model) |
|
35 | - { |
|
36 | - $this->setName($this->namespace . 'Price'); |
|
37 | - $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | - $this->setIsCustomPostType(false); |
|
39 | - parent::__construct($price_model); |
|
40 | - } |
|
29 | + /** |
|
30 | + * Price constructor. |
|
31 | + * |
|
32 | + * @param EEM_Price $price_model |
|
33 | + */ |
|
34 | + public function __construct(EEM_Price $price_model) |
|
35 | + { |
|
36 | + $this->setName($this->namespace . 'Price'); |
|
37 | + $this->setDescription(__('A price.', 'event_espresso')); |
|
38 | + $this->setIsCustomPostType(false); |
|
39 | + parent::__construct($price_model); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @return GraphQLFieldInterface[] |
|
45 | - * @since $VID:$ |
|
46 | - */ |
|
47 | - public function getFields(): array |
|
48 | - { |
|
49 | - $fields = [ |
|
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 | - 'description', |
|
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 GraphQLOutputField( |
|
165 | - 'userId', |
|
166 | - 'ID', |
|
167 | - null, |
|
168 | - esc_html__('Price Creator ID', 'event_espresso') |
|
169 | - ), |
|
170 | - new GraphQLInputField( |
|
171 | - 'wpUser', |
|
172 | - 'Int', |
|
173 | - null, |
|
174 | - esc_html__('Price Creator ID', 'event_espresso') |
|
175 | - ), |
|
176 | - ]; |
|
43 | + /** |
|
44 | + * @return GraphQLFieldInterface[] |
|
45 | + * @since $VID:$ |
|
46 | + */ |
|
47 | + public function getFields(): array |
|
48 | + { |
|
49 | + $fields = [ |
|
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 | + 'description', |
|
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 GraphQLOutputField( |
|
165 | + 'userId', |
|
166 | + 'ID', |
|
167 | + null, |
|
168 | + esc_html__('Price Creator ID', 'event_espresso') |
|
169 | + ), |
|
170 | + new GraphQLInputField( |
|
171 | + 'wpUser', |
|
172 | + 'Int', |
|
173 | + null, |
|
174 | + esc_html__('Price Creator ID', 'event_espresso') |
|
175 | + ), |
|
176 | + ]; |
|
177 | 177 | |
178 | - return apply_filters( |
|
179 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__price_fields', |
|
180 | - $fields, |
|
181 | - $this->name, |
|
182 | - $this->model |
|
183 | - ); |
|
184 | - } |
|
178 | + return apply_filters( |
|
179 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__price_fields', |
|
180 | + $fields, |
|
181 | + $this->name, |
|
182 | + $this->model |
|
183 | + ); |
|
184 | + } |
|
185 | 185 | |
186 | 186 | |
187 | - /** |
|
188 | - * @param array $inputFields The mutation input fields. |
|
189 | - * @throws InvalidArgumentException |
|
190 | - * @throws ReflectionException |
|
191 | - * @throws Exception |
|
192 | - * @since $VID:$ |
|
193 | - */ |
|
194 | - public function registerMutations(array $inputFields) |
|
195 | - { |
|
196 | - // Register mutation to update an entity. |
|
197 | - register_graphql_mutation( |
|
198 | - 'update' . $this->name(), |
|
199 | - [ |
|
200 | - 'inputFields' => $inputFields, |
|
201 | - 'outputFields' => [ |
|
202 | - lcfirst($this->name()) => [ |
|
203 | - 'type' => $this->name(), |
|
204 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
205 | - ], |
|
206 | - ], |
|
207 | - 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
208 | - ] |
|
209 | - ); |
|
210 | - // Register mutation to delete an entity. |
|
211 | - register_graphql_mutation( |
|
212 | - 'delete' . $this->name(), |
|
213 | - [ |
|
214 | - 'inputFields' => [ |
|
215 | - 'id' => $inputFields['id'], |
|
216 | - 'deletePermanently' => [ |
|
217 | - 'type' => 'Boolean', |
|
218 | - 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
219 | - ], |
|
220 | - ], |
|
221 | - 'outputFields' => [ |
|
222 | - lcfirst($this->name()) => [ |
|
223 | - 'type' => $this->name(), |
|
224 | - 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
225 | - 'resolve' => static function ($payload) { |
|
226 | - $deleted = (object) $payload['deleted']; |
|
187 | + /** |
|
188 | + * @param array $inputFields The mutation input fields. |
|
189 | + * @throws InvalidArgumentException |
|
190 | + * @throws ReflectionException |
|
191 | + * @throws Exception |
|
192 | + * @since $VID:$ |
|
193 | + */ |
|
194 | + public function registerMutations(array $inputFields) |
|
195 | + { |
|
196 | + // Register mutation to update an entity. |
|
197 | + register_graphql_mutation( |
|
198 | + 'update' . $this->name(), |
|
199 | + [ |
|
200 | + 'inputFields' => $inputFields, |
|
201 | + 'outputFields' => [ |
|
202 | + lcfirst($this->name()) => [ |
|
203 | + 'type' => $this->name(), |
|
204 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
205 | + ], |
|
206 | + ], |
|
207 | + 'mutateAndGetPayload' => PriceUpdate::mutateAndGetPayload($this->model, $this), |
|
208 | + ] |
|
209 | + ); |
|
210 | + // Register mutation to delete an entity. |
|
211 | + register_graphql_mutation( |
|
212 | + 'delete' . $this->name(), |
|
213 | + [ |
|
214 | + 'inputFields' => [ |
|
215 | + 'id' => $inputFields['id'], |
|
216 | + 'deletePermanently' => [ |
|
217 | + 'type' => 'Boolean', |
|
218 | + 'description' => esc_html__('Whether to delete the entity permanently.', 'event_espresso'), |
|
219 | + ], |
|
220 | + ], |
|
221 | + 'outputFields' => [ |
|
222 | + lcfirst($this->name()) => [ |
|
223 | + 'type' => $this->name(), |
|
224 | + 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
|
225 | + 'resolve' => static function ($payload) { |
|
226 | + $deleted = (object) $payload['deleted']; |
|
227 | 227 | |
228 | - return ! empty($deleted) ? $deleted : null; |
|
229 | - }, |
|
230 | - ], |
|
231 | - ], |
|
232 | - 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
233 | - ] |
|
234 | - ); |
|
228 | + return ! empty($deleted) ? $deleted : null; |
|
229 | + }, |
|
230 | + ], |
|
231 | + ], |
|
232 | + 'mutateAndGetPayload' => PriceDelete::mutateAndGetPayload($this->model, $this), |
|
233 | + ] |
|
234 | + ); |
|
235 | 235 | |
236 | - // remove primary key from input. |
|
237 | - unset($inputFields['id']); |
|
238 | - // Register mutation to update an entity. |
|
239 | - register_graphql_mutation( |
|
240 | - 'create' . $this->name(), |
|
241 | - [ |
|
242 | - 'inputFields' => $inputFields, |
|
243 | - 'outputFields' => [ |
|
244 | - lcfirst($this->name()) => [ |
|
245 | - 'type' => $this->name(), |
|
246 | - 'resolve' => [$this, 'resolveFromPayload'], |
|
247 | - ], |
|
248 | - ], |
|
249 | - 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
250 | - ] |
|
251 | - ); |
|
252 | - } |
|
236 | + // remove primary key from input. |
|
237 | + unset($inputFields['id']); |
|
238 | + // Register mutation to update an entity. |
|
239 | + register_graphql_mutation( |
|
240 | + 'create' . $this->name(), |
|
241 | + [ |
|
242 | + 'inputFields' => $inputFields, |
|
243 | + 'outputFields' => [ |
|
244 | + lcfirst($this->name()) => [ |
|
245 | + 'type' => $this->name(), |
|
246 | + 'resolve' => [$this, 'resolveFromPayload'], |
|
247 | + ], |
|
248 | + ], |
|
249 | + 'mutateAndGetPayload' => PriceCreate::mutateAndGetPayload($this->model, $this), |
|
250 | + ] |
|
251 | + ); |
|
252 | + } |
|
253 | 253 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public function __construct(EEM_Price $price_model) |
35 | 35 | { |
36 | - $this->setName($this->namespace . 'Price'); |
|
36 | + $this->setName($this->namespace.'Price'); |
|
37 | 37 | $this->setDescription(__('A price.', 'event_espresso')); |
38 | 38 | $this->setIsCustomPostType(false); |
39 | 39 | parent::__construct($price_model); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | ), |
146 | 146 | new GraphQLOutputField( |
147 | 147 | 'priceType', |
148 | - $this->namespace . 'PriceType', |
|
148 | + $this->namespace.'PriceType', |
|
149 | 149 | 'type_obj', |
150 | 150 | esc_html__('The related price type object.', 'event_espresso') |
151 | 151 | ), |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | { |
196 | 196 | // Register mutation to update an entity. |
197 | 197 | register_graphql_mutation( |
198 | - 'update' . $this->name(), |
|
198 | + 'update'.$this->name(), |
|
199 | 199 | [ |
200 | 200 | 'inputFields' => $inputFields, |
201 | 201 | 'outputFields' => [ |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | ); |
210 | 210 | // Register mutation to delete an entity. |
211 | 211 | register_graphql_mutation( |
212 | - 'delete' . $this->name(), |
|
212 | + 'delete'.$this->name(), |
|
213 | 213 | [ |
214 | 214 | 'inputFields' => [ |
215 | 215 | 'id' => $inputFields['id'], |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | lcfirst($this->name()) => [ |
223 | 223 | 'type' => $this->name(), |
224 | 224 | 'description' => esc_html__('The object before it was deleted', 'event_espresso'), |
225 | - 'resolve' => static function ($payload) { |
|
225 | + 'resolve' => static function($payload) { |
|
226 | 226 | $deleted = (object) $payload['deleted']; |
227 | 227 | |
228 | 228 | return ! empty($deleted) ? $deleted : null; |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | unset($inputFields['id']); |
238 | 238 | // Register mutation to update an entity. |
239 | 239 | register_graphql_mutation( |
240 | - 'create' . $this->name(), |
|
240 | + 'create'.$this->name(), |
|
241 | 241 | [ |
242 | 242 | 'inputFields' => $inputFields, |
243 | 243 | 'outputFields' => [ |