@@ -13,68 +13,68 @@ |
||
13 | 13 | class TicketCreate extends EntityMutator |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Defines the mutation data modification closure. |
|
18 | - * |
|
19 | - * @param EEM_Ticket $model |
|
20 | - * @param Ticket $type |
|
21 | - * @return callable |
|
22 | - */ |
|
23 | - public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | - { |
|
25 | - /** |
|
26 | - * Creates an entity. |
|
27 | - * |
|
28 | - * @param array $input The input for the mutation |
|
29 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
34 | - try { |
|
35 | - EntityMutator::checkPermissions($model); |
|
16 | + /** |
|
17 | + * Defines the mutation data modification closure. |
|
18 | + * |
|
19 | + * @param EEM_Ticket $model |
|
20 | + * @param Ticket $type |
|
21 | + * @return callable |
|
22 | + */ |
|
23 | + public static function mutateAndGetPayload(EEM_Ticket $model, Ticket $type) |
|
24 | + { |
|
25 | + /** |
|
26 | + * Creates an entity. |
|
27 | + * |
|
28 | + * @param array $input The input for the mutation |
|
29 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
30 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
34 | + try { |
|
35 | + EntityMutator::checkPermissions($model); |
|
36 | 36 | |
37 | - $datetimes = []; |
|
38 | - $prices = []; |
|
37 | + $datetimes = []; |
|
38 | + $prices = []; |
|
39 | 39 | |
40 | - $args = TicketMutation::prepareFields($input); |
|
40 | + $args = TicketMutation::prepareFields($input); |
|
41 | 41 | |
42 | - if (isset($args['datetimes'])) { |
|
43 | - $datetimes = $args['datetimes']; |
|
44 | - unset($args['datetimes']); |
|
45 | - } |
|
46 | - if (isset($args['prices'])) { |
|
47 | - $prices = $args['prices']; |
|
48 | - unset($args['prices']); |
|
49 | - } |
|
42 | + if (isset($args['datetimes'])) { |
|
43 | + $datetimes = $args['datetimes']; |
|
44 | + unset($args['datetimes']); |
|
45 | + } |
|
46 | + if (isset($args['prices'])) { |
|
47 | + $prices = $args['prices']; |
|
48 | + unset($args['prices']); |
|
49 | + } |
|
50 | 50 | |
51 | - $entity = EE_Ticket::new_instance($args); |
|
52 | - $id = $entity->save(); |
|
53 | - EntityMutator::validateResults($id); |
|
51 | + $entity = EE_Ticket::new_instance($args); |
|
52 | + $id = $entity->save(); |
|
53 | + EntityMutator::validateResults($id); |
|
54 | 54 | |
55 | - if (! empty($datetimes)) { |
|
56 | - TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
57 | - } |
|
58 | - // if prices are passed. |
|
59 | - if (! empty($prices)) { |
|
60 | - TicketMutation::setRelatedPrices($entity, $prices); |
|
61 | - } else { |
|
62 | - // we do this client-side |
|
63 | - // TicketMutation::addDefaultPrices($entity, $model); |
|
64 | - } |
|
65 | - } catch (Exception $exception) { |
|
66 | - EntityMutator::handleExceptions( |
|
67 | - $exception, |
|
68 | - esc_html__( |
|
69 | - 'The ticket could not be created because of the following error(s)', |
|
70 | - 'event_espresso' |
|
71 | - ) |
|
72 | - ); |
|
73 | - } |
|
55 | + if (! empty($datetimes)) { |
|
56 | + TicketMutation::setRelatedDatetimes($entity, $datetimes); |
|
57 | + } |
|
58 | + // if prices are passed. |
|
59 | + if (! empty($prices)) { |
|
60 | + TicketMutation::setRelatedPrices($entity, $prices); |
|
61 | + } else { |
|
62 | + // we do this client-side |
|
63 | + // TicketMutation::addDefaultPrices($entity, $model); |
|
64 | + } |
|
65 | + } catch (Exception $exception) { |
|
66 | + EntityMutator::handleExceptions( |
|
67 | + $exception, |
|
68 | + esc_html__( |
|
69 | + 'The ticket could not be created because of the following error(s)', |
|
70 | + 'event_espresso' |
|
71 | + ) |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | - return [ |
|
76 | - 'id' => $id, |
|
77 | - ]; |
|
78 | - }; |
|
79 | - } |
|
75 | + return [ |
|
76 | + 'id' => $id, |
|
77 | + ]; |
|
78 | + }; |
|
79 | + } |
|
80 | 80 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
33 | + return static function($input, AppContext $context, ResolveInfo $info) use ($model, $type) { |
|
34 | 34 | try { |
35 | 35 | EntityMutator::checkPermissions($model); |
36 | 36 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | $id = $entity->save(); |
53 | 53 | EntityMutator::validateResults($id); |
54 | 54 | |
55 | - if (! empty($datetimes)) { |
|
55 | + if ( ! empty($datetimes)) { |
|
56 | 56 | TicketMutation::setRelatedDatetimes($entity, $datetimes); |
57 | 57 | } |
58 | 58 | // if prices are passed. |
59 | - if (! empty($prices)) { |
|
59 | + if ( ! empty($prices)) { |
|
60 | 60 | TicketMutation::setRelatedPrices($entity, $prices); |
61 | 61 | } else { |
62 | 62 | // we do this client-side |
@@ -15,158 +15,158 @@ |
||
15 | 15 | */ |
16 | 16 | class PriceConnectionResolver extends AbstractConnectionResolver |
17 | 17 | { |
18 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
19 | - public function get_loader_name() |
|
20 | - { |
|
21 | - return 'espresso_price'; |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * @return EEM_Price |
|
26 | - * @throws EE_Error |
|
27 | - * @throws InvalidArgumentException |
|
28 | - * @throws InvalidDataTypeException |
|
29 | - * @throws InvalidInterfaceException |
|
30 | - */ |
|
31 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | - public function get_query() |
|
33 | - { |
|
34 | - return EEM_Price::instance(); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * Return an array of item IDs from the query |
|
40 | - * |
|
41 | - * @return array |
|
42 | - */ |
|
43 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
44 | - public function get_ids() |
|
45 | - { |
|
46 | - $results = $this->query->get_col($this->query_args); |
|
47 | - |
|
48 | - return ! empty($results) ? $results : []; |
|
49 | - } |
|
50 | - |
|
51 | - |
|
52 | - /** |
|
53 | - * Determine whether the Query should execute. If it's determined that the query should |
|
54 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
55 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
56 | - * Return false to prevent the query from executing. |
|
57 | - * |
|
58 | - * @return bool |
|
59 | - */ |
|
60 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
61 | - public function should_execute() |
|
62 | - { |
|
63 | - if ($this->should_execute === false) { |
|
64 | - return false; |
|
65 | - } |
|
66 | - |
|
67 | - return $this->should_execute; |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
73 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
74 | - * handle batch resolution of the posts. |
|
75 | - * |
|
76 | - * @return array |
|
77 | - * @throws EE_Error |
|
78 | - * @throws InvalidArgumentException |
|
79 | - * @throws ReflectionException |
|
80 | - * @throws InvalidDataTypeException |
|
81 | - * @throws InvalidInterfaceException |
|
82 | - */ |
|
83 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
84 | - public function get_query_args() |
|
85 | - { |
|
86 | - $where_params = []; |
|
87 | - $query_args = []; |
|
88 | - |
|
89 | - $query_args['limit'] = $this->getLimit(); |
|
90 | - |
|
91 | - // Avoid multiple entries by join. |
|
92 | - $query_args['group_by'] = 'PRC_ID'; |
|
93 | - |
|
94 | - $query_args['default_where_conditions'] = 'minimum'; |
|
95 | - |
|
96 | - /** |
|
97 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
98 | - */ |
|
99 | - $input_fields = []; |
|
100 | - if (! empty($this->args['where'])) { |
|
101 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
102 | - |
|
103 | - // Use the proper operator. |
|
104 | - if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
105 | - $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
106 | - } |
|
107 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
108 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
109 | - } |
|
110 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
111 | - $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
112 | - } |
|
113 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
114 | - $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
120 | - */ |
|
121 | - if ($this->source instanceof EE_Ticket) { |
|
122 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Merge the input_fields with the default query_args |
|
127 | - */ |
|
128 | - if (! empty($input_fields)) { |
|
129 | - $where_params = array_merge($where_params, $input_fields); |
|
130 | - } |
|
131 | - |
|
132 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
133 | - |
|
134 | - $query_args[] = $where_params; |
|
135 | - |
|
136 | - /** |
|
137 | - * Return the $query_args |
|
138 | - */ |
|
139 | - return $query_args; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
145 | - * friendly keys. |
|
146 | - * |
|
147 | - * @param array $where_args |
|
148 | - * @return array |
|
149 | - */ |
|
150 | - public function sanitizeInputFields(array $where_args) |
|
151 | - { |
|
152 | - $arg_mapping = [ |
|
153 | - 'in' => 'PRC_ID', |
|
154 | - 'idIn' => 'PRC_ID', |
|
155 | - 'ticket' => 'Ticket.TKT_ID', |
|
156 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
157 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
158 | - 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
159 | - 'priceType' => 'Price_Type.PRT_ID', |
|
160 | - 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
161 | - 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
162 | - 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
163 | - 'priceBaseType' => 'Price_Type.PBT_ID', |
|
164 | - 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
165 | - ]; |
|
166 | - return $this->sanitizeWhereArgsForInputFields( |
|
167 | - $where_args, |
|
168 | - $arg_mapping, |
|
169 | - ['in', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
170 | - ); |
|
171 | - } |
|
18 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
19 | + public function get_loader_name() |
|
20 | + { |
|
21 | + return 'espresso_price'; |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * @return EEM_Price |
|
26 | + * @throws EE_Error |
|
27 | + * @throws InvalidArgumentException |
|
28 | + * @throws InvalidDataTypeException |
|
29 | + * @throws InvalidInterfaceException |
|
30 | + */ |
|
31 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | + public function get_query() |
|
33 | + { |
|
34 | + return EEM_Price::instance(); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * Return an array of item IDs from the query |
|
40 | + * |
|
41 | + * @return array |
|
42 | + */ |
|
43 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
44 | + public function get_ids() |
|
45 | + { |
|
46 | + $results = $this->query->get_col($this->query_args); |
|
47 | + |
|
48 | + return ! empty($results) ? $results : []; |
|
49 | + } |
|
50 | + |
|
51 | + |
|
52 | + /** |
|
53 | + * Determine whether the Query should execute. If it's determined that the query should |
|
54 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
55 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
56 | + * Return false to prevent the query from executing. |
|
57 | + * |
|
58 | + * @return bool |
|
59 | + */ |
|
60 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
61 | + public function should_execute() |
|
62 | + { |
|
63 | + if ($this->should_execute === false) { |
|
64 | + return false; |
|
65 | + } |
|
66 | + |
|
67 | + return $this->should_execute; |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
73 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
74 | + * handle batch resolution of the posts. |
|
75 | + * |
|
76 | + * @return array |
|
77 | + * @throws EE_Error |
|
78 | + * @throws InvalidArgumentException |
|
79 | + * @throws ReflectionException |
|
80 | + * @throws InvalidDataTypeException |
|
81 | + * @throws InvalidInterfaceException |
|
82 | + */ |
|
83 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
84 | + public function get_query_args() |
|
85 | + { |
|
86 | + $where_params = []; |
|
87 | + $query_args = []; |
|
88 | + |
|
89 | + $query_args['limit'] = $this->getLimit(); |
|
90 | + |
|
91 | + // Avoid multiple entries by join. |
|
92 | + $query_args['group_by'] = 'PRC_ID'; |
|
93 | + |
|
94 | + $query_args['default_where_conditions'] = 'minimum'; |
|
95 | + |
|
96 | + /** |
|
97 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
98 | + */ |
|
99 | + $input_fields = []; |
|
100 | + if (! empty($this->args['where'])) { |
|
101 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
102 | + |
|
103 | + // Use the proper operator. |
|
104 | + if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
105 | + $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
106 | + } |
|
107 | + if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
108 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
109 | + } |
|
110 | + if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
111 | + $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
112 | + } |
|
113 | + if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
114 | + $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
120 | + */ |
|
121 | + if ($this->source instanceof EE_Ticket) { |
|
122 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Merge the input_fields with the default query_args |
|
127 | + */ |
|
128 | + if (! empty($input_fields)) { |
|
129 | + $where_params = array_merge($where_params, $input_fields); |
|
130 | + } |
|
131 | + |
|
132 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
133 | + |
|
134 | + $query_args[] = $where_params; |
|
135 | + |
|
136 | + /** |
|
137 | + * Return the $query_args |
|
138 | + */ |
|
139 | + return $query_args; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
145 | + * friendly keys. |
|
146 | + * |
|
147 | + * @param array $where_args |
|
148 | + * @return array |
|
149 | + */ |
|
150 | + public function sanitizeInputFields(array $where_args) |
|
151 | + { |
|
152 | + $arg_mapping = [ |
|
153 | + 'in' => 'PRC_ID', |
|
154 | + 'idIn' => 'PRC_ID', |
|
155 | + 'ticket' => 'Ticket.TKT_ID', |
|
156 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
157 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
158 | + 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
159 | + 'priceType' => 'Price_Type.PRT_ID', |
|
160 | + 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
161 | + 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
162 | + 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
163 | + 'priceBaseType' => 'Price_Type.PBT_ID', |
|
164 | + 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
165 | + ]; |
|
166 | + return $this->sanitizeWhereArgsForInputFields( |
|
167 | + $where_args, |
|
168 | + $arg_mapping, |
|
169 | + ['in', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
170 | + ); |
|
171 | + } |
|
172 | 172 | } |
@@ -97,20 +97,20 @@ discard block |
||
97 | 97 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
98 | 98 | */ |
99 | 99 | $input_fields = []; |
100 | - if (! empty($this->args['where'])) { |
|
100 | + if ( ! empty($this->args['where'])) { |
|
101 | 101 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
102 | 102 | |
103 | 103 | // Use the proper operator. |
104 | - if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
104 | + if ( ! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
105 | 105 | $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
106 | 106 | } |
107 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
107 | + if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
108 | 108 | $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
109 | 109 | } |
110 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
110 | + if ( ! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
111 | 111 | $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
112 | 112 | } |
113 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
113 | + if ( ! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
114 | 114 | $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
115 | 115 | } |
116 | 116 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | /** |
126 | 126 | * Merge the input_fields with the default query_args |
127 | 127 | */ |
128 | - if (! empty($input_fields)) { |
|
128 | + if ( ! empty($input_fields)) { |
|
129 | 129 | $where_params = array_merge($where_params, $input_fields); |
130 | 130 | } |
131 | 131 |
@@ -24,188 +24,188 @@ |
||
24 | 24 | class TicketMutation |
25 | 25 | { |
26 | 26 | |
27 | - /** |
|
28 | - * Maps the GraphQL input to a format that the model functions can use |
|
29 | - * |
|
30 | - * @param array $input Data coming from the GraphQL mutation query input |
|
31 | - * @return array |
|
32 | - * @throws Exception |
|
33 | - */ |
|
34 | - public static function prepareFields(array $input) |
|
35 | - { |
|
36 | - $args = []; |
|
37 | - |
|
38 | - if (! empty($input['datetimes'])) { |
|
39 | - $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
40 | - } |
|
41 | - |
|
42 | - if (! empty($input['description'])) { |
|
43 | - $args['TKT_description'] = sanitize_text_field($input['description']); |
|
44 | - } |
|
45 | - |
|
46 | - if (! empty($input['endDate'])) { |
|
47 | - $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
48 | - } |
|
49 | - |
|
50 | - if (array_key_exists('isDefault', $input)) { |
|
51 | - $args['TKT_is_default'] = (bool) $input['isDefault']; |
|
52 | - } |
|
53 | - |
|
54 | - if (array_key_exists('isRequired', $input)) { |
|
55 | - $args['TKT_required'] = (bool) $input['isRequired']; |
|
56 | - } |
|
57 | - |
|
58 | - if (array_key_exists('isTaxable', $input)) { |
|
59 | - $args['TKT_taxable'] = (bool) $input['isTaxable']; |
|
60 | - } |
|
61 | - |
|
62 | - if (array_key_exists('isTrashed', $input)) { |
|
63 | - $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
64 | - } |
|
65 | - |
|
66 | - if (array_key_exists('max', $input)) { |
|
67 | - $args['TKT_max'] = (int) $input['max']; |
|
68 | - } |
|
69 | - |
|
70 | - if (array_key_exists('min', $input)) { |
|
71 | - $args['TKT_min'] = (int) $input['min']; |
|
72 | - } |
|
73 | - |
|
74 | - if (! empty($input['name'])) { |
|
75 | - $args['TKT_name'] = sanitize_text_field($input['name']); |
|
76 | - } |
|
77 | - |
|
78 | - if (array_key_exists('order', $input)) { |
|
79 | - $args['TKT_order'] = (int) $input['order']; |
|
80 | - } |
|
81 | - |
|
82 | - if (! empty($input['parent'])) { |
|
83 | - $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
84 | - $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
85 | - } |
|
86 | - |
|
87 | - // price can be 0 |
|
88 | - if (array_key_exists('price', $input)) { |
|
89 | - $args['TKT_price'] = (float) $input['price']; |
|
90 | - } |
|
91 | - |
|
92 | - if (! empty($input['prices'])) { |
|
93 | - $args['prices'] = array_map('sanitize_text_field', (array) $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 | - return $args; |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * Sets the related datetimes for the given ticket. |
|
135 | - * |
|
136 | - * @param EE_Ticket $entity The Ticket instance. |
|
137 | - * @param array $datetimes Array of datetime IDs to relate. |
|
138 | - * @throws EE_Error |
|
139 | - * @throws InvalidArgumentException |
|
140 | - * @throws InvalidDataTypeException |
|
141 | - * @throws InvalidInterfaceException |
|
142 | - * @throws ReflectionException |
|
143 | - */ |
|
144 | - public static function setRelatedDatetimes($entity, array $datetimes) |
|
145 | - { |
|
146 | - $relationName = 'Datetime'; |
|
147 | - // Remove all the existing related datetimes |
|
148 | - |
|
149 | - $entity->_remove_relations($relationName); |
|
150 | - // @todo replace loop with single query |
|
151 | - foreach ($datetimes as $ID) { |
|
152 | - $parts = Relay::fromGlobalId($ID); |
|
153 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
154 | - $entity->_add_relation_to( |
|
155 | - $parts['id'], |
|
156 | - $relationName |
|
157 | - ); |
|
158 | - } |
|
159 | - } |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * Sets the related prices for the given ticket. |
|
165 | - * |
|
166 | - * @param EE_Ticket $entity The Ticket instance. |
|
167 | - * @param array $prices Array of entity IDs to relate. |
|
168 | - * @throws EE_Error |
|
169 | - * @throws InvalidArgumentException |
|
170 | - * @throws InvalidDataTypeException |
|
171 | - * @throws InvalidInterfaceException |
|
172 | - * @throws ReflectionException |
|
173 | - */ |
|
174 | - public static function setRelatedPrices($entity, array $prices) |
|
175 | - { |
|
176 | - $relationName = 'Price'; |
|
177 | - // Remove all the existing related entities |
|
178 | - $entity->_remove_relations($relationName); |
|
179 | - |
|
180 | - // @todo replace loop with single query |
|
181 | - foreach ($prices as $ID) { |
|
182 | - $parts = Relay::fromGlobalId($ID); |
|
183 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
184 | - $entity->_add_relation_to( |
|
185 | - $parts['id'], |
|
186 | - $relationName |
|
187 | - ); |
|
188 | - } |
|
189 | - } |
|
190 | - } |
|
191 | - |
|
192 | - |
|
193 | - /** |
|
194 | - * @param EE_Ticket $ticket_entity |
|
195 | - * @param EEM_Ticket $ticket_model |
|
196 | - * @throws EE_Error |
|
197 | - * @throws InvalidArgumentException |
|
198 | - * @throws InvalidDataTypeException |
|
199 | - * @throws InvalidInterfaceException |
|
200 | - * @throws ReflectionException |
|
201 | - * @since $VID:$ |
|
202 | - */ |
|
203 | - public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
204 | - { |
|
205 | - /** @var DefaultPrices $default_prices */ |
|
206 | - $default_prices = LoaderFactory::getLoader()->getShared( |
|
207 | - 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' |
|
208 | - ); |
|
209 | - $default_prices->create($ticket_entity); |
|
210 | - } |
|
27 | + /** |
|
28 | + * Maps the GraphQL input to a format that the model functions can use |
|
29 | + * |
|
30 | + * @param array $input Data coming from the GraphQL mutation query input |
|
31 | + * @return array |
|
32 | + * @throws Exception |
|
33 | + */ |
|
34 | + public static function prepareFields(array $input) |
|
35 | + { |
|
36 | + $args = []; |
|
37 | + |
|
38 | + if (! empty($input['datetimes'])) { |
|
39 | + $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
|
40 | + } |
|
41 | + |
|
42 | + if (! empty($input['description'])) { |
|
43 | + $args['TKT_description'] = sanitize_text_field($input['description']); |
|
44 | + } |
|
45 | + |
|
46 | + if (! empty($input['endDate'])) { |
|
47 | + $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
|
48 | + } |
|
49 | + |
|
50 | + if (array_key_exists('isDefault', $input)) { |
|
51 | + $args['TKT_is_default'] = (bool) $input['isDefault']; |
|
52 | + } |
|
53 | + |
|
54 | + if (array_key_exists('isRequired', $input)) { |
|
55 | + $args['TKT_required'] = (bool) $input['isRequired']; |
|
56 | + } |
|
57 | + |
|
58 | + if (array_key_exists('isTaxable', $input)) { |
|
59 | + $args['TKT_taxable'] = (bool) $input['isTaxable']; |
|
60 | + } |
|
61 | + |
|
62 | + if (array_key_exists('isTrashed', $input)) { |
|
63 | + $args['TKT_deleted'] = (bool) $input['isTrashed']; |
|
64 | + } |
|
65 | + |
|
66 | + if (array_key_exists('max', $input)) { |
|
67 | + $args['TKT_max'] = (int) $input['max']; |
|
68 | + } |
|
69 | + |
|
70 | + if (array_key_exists('min', $input)) { |
|
71 | + $args['TKT_min'] = (int) $input['min']; |
|
72 | + } |
|
73 | + |
|
74 | + if (! empty($input['name'])) { |
|
75 | + $args['TKT_name'] = sanitize_text_field($input['name']); |
|
76 | + } |
|
77 | + |
|
78 | + if (array_key_exists('order', $input)) { |
|
79 | + $args['TKT_order'] = (int) $input['order']; |
|
80 | + } |
|
81 | + |
|
82 | + if (! empty($input['parent'])) { |
|
83 | + $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
|
84 | + $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
85 | + } |
|
86 | + |
|
87 | + // price can be 0 |
|
88 | + if (array_key_exists('price', $input)) { |
|
89 | + $args['TKT_price'] = (float) $input['price']; |
|
90 | + } |
|
91 | + |
|
92 | + if (! empty($input['prices'])) { |
|
93 | + $args['prices'] = array_map('sanitize_text_field', (array) $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 | + return $args; |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * Sets the related datetimes for the given ticket. |
|
135 | + * |
|
136 | + * @param EE_Ticket $entity The Ticket instance. |
|
137 | + * @param array $datetimes Array of datetime IDs to relate. |
|
138 | + * @throws EE_Error |
|
139 | + * @throws InvalidArgumentException |
|
140 | + * @throws InvalidDataTypeException |
|
141 | + * @throws InvalidInterfaceException |
|
142 | + * @throws ReflectionException |
|
143 | + */ |
|
144 | + public static function setRelatedDatetimes($entity, array $datetimes) |
|
145 | + { |
|
146 | + $relationName = 'Datetime'; |
|
147 | + // Remove all the existing related datetimes |
|
148 | + |
|
149 | + $entity->_remove_relations($relationName); |
|
150 | + // @todo replace loop with single query |
|
151 | + foreach ($datetimes as $ID) { |
|
152 | + $parts = Relay::fromGlobalId($ID); |
|
153 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
154 | + $entity->_add_relation_to( |
|
155 | + $parts['id'], |
|
156 | + $relationName |
|
157 | + ); |
|
158 | + } |
|
159 | + } |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * Sets the related prices for the given ticket. |
|
165 | + * |
|
166 | + * @param EE_Ticket $entity The Ticket instance. |
|
167 | + * @param array $prices Array of entity IDs to relate. |
|
168 | + * @throws EE_Error |
|
169 | + * @throws InvalidArgumentException |
|
170 | + * @throws InvalidDataTypeException |
|
171 | + * @throws InvalidInterfaceException |
|
172 | + * @throws ReflectionException |
|
173 | + */ |
|
174 | + public static function setRelatedPrices($entity, array $prices) |
|
175 | + { |
|
176 | + $relationName = 'Price'; |
|
177 | + // Remove all the existing related entities |
|
178 | + $entity->_remove_relations($relationName); |
|
179 | + |
|
180 | + // @todo replace loop with single query |
|
181 | + foreach ($prices as $ID) { |
|
182 | + $parts = Relay::fromGlobalId($ID); |
|
183 | + if (! empty($parts['id']) && absint($parts['id'])) { |
|
184 | + $entity->_add_relation_to( |
|
185 | + $parts['id'], |
|
186 | + $relationName |
|
187 | + ); |
|
188 | + } |
|
189 | + } |
|
190 | + } |
|
191 | + |
|
192 | + |
|
193 | + /** |
|
194 | + * @param EE_Ticket $ticket_entity |
|
195 | + * @param EEM_Ticket $ticket_model |
|
196 | + * @throws EE_Error |
|
197 | + * @throws InvalidArgumentException |
|
198 | + * @throws InvalidDataTypeException |
|
199 | + * @throws InvalidInterfaceException |
|
200 | + * @throws ReflectionException |
|
201 | + * @since $VID:$ |
|
202 | + */ |
|
203 | + public static function addDefaultPrices(EE_Ticket $ticket_entity, EEM_Ticket $ticket_model) |
|
204 | + { |
|
205 | + /** @var DefaultPrices $default_prices */ |
|
206 | + $default_prices = LoaderFactory::getLoader()->getShared( |
|
207 | + 'EventEspresso\core\domain\services\admin\entities\DefaultPrices' |
|
208 | + ); |
|
209 | + $default_prices->create($ticket_entity); |
|
210 | + } |
|
211 | 211 | } |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | { |
36 | 36 | $args = []; |
37 | 37 | |
38 | - if (! empty($input['datetimes'])) { |
|
38 | + if ( ! empty($input['datetimes'])) { |
|
39 | 39 | $args['datetimes'] = array_map('sanitize_text_field', (array) $input['datetimes']); |
40 | 40 | } |
41 | 41 | |
42 | - if (! empty($input['description'])) { |
|
42 | + if ( ! empty($input['description'])) { |
|
43 | 43 | $args['TKT_description'] = sanitize_text_field($input['description']); |
44 | 44 | } |
45 | 45 | |
46 | - if (! empty($input['endDate'])) { |
|
46 | + if ( ! empty($input['endDate'])) { |
|
47 | 47 | $args['TKT_end_date'] = new DateTime(sanitize_text_field($input['endDate'])); |
48 | 48 | } |
49 | 49 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $args['TKT_min'] = (int) $input['min']; |
72 | 72 | } |
73 | 73 | |
74 | - if (! empty($input['name'])) { |
|
74 | + if ( ! empty($input['name'])) { |
|
75 | 75 | $args['TKT_name'] = sanitize_text_field($input['name']); |
76 | 76 | } |
77 | 77 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $args['TKT_order'] = (int) $input['order']; |
80 | 80 | } |
81 | 81 | |
82 | - if (! empty($input['parent'])) { |
|
82 | + if ( ! empty($input['parent'])) { |
|
83 | 83 | $parts = Relay::fromGlobalId(sanitize_text_field($input['parent'])); |
84 | - $args['TKT_parent'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
84 | + $args['TKT_parent'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // price can be 0 |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $args['TKT_price'] = (float) $input['price']; |
90 | 90 | } |
91 | 91 | |
92 | - if (! empty($input['prices'])) { |
|
92 | + if ( ! empty($input['prices'])) { |
|
93 | 93 | $args['prices'] = array_map('sanitize_text_field', (array) $input['prices']); |
94 | 94 | } |
95 | 95 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $args['TKT_sold'] = (int) $input['sold']; |
114 | 114 | } |
115 | 115 | |
116 | - if (! empty($input['startDate'])) { |
|
116 | + if ( ! empty($input['startDate'])) { |
|
117 | 117 | $args['TKT_start_date'] = new DateTime(sanitize_text_field($input['startDate'])); |
118 | 118 | } |
119 | 119 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | $args['TKT_uses'] = (int) $input['uses']; |
122 | 122 | } |
123 | 123 | |
124 | - if (! empty($input['wpUser'])) { |
|
124 | + if ( ! empty($input['wpUser'])) { |
|
125 | 125 | $parts = Relay::fromGlobalId(sanitize_text_field($input['wpUser'])); |
126 | - $args['TKT_wp_user'] = (! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
126 | + $args['TKT_wp_user'] = ( ! empty($parts['id']) && is_int($parts['id'])) ? $parts['id'] : null; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | return $args; |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | // @todo replace loop with single query |
151 | 151 | foreach ($datetimes as $ID) { |
152 | 152 | $parts = Relay::fromGlobalId($ID); |
153 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
153 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
154 | 154 | $entity->_add_relation_to( |
155 | 155 | $parts['id'], |
156 | 156 | $relationName |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | // @todo replace loop with single query |
181 | 181 | foreach ($prices as $ID) { |
182 | 182 | $parts = Relay::fromGlobalId($ID); |
183 | - if (! empty($parts['id']) && absint($parts['id'])) { |
|
183 | + if ( ! empty($parts['id']) && absint($parts['id'])) { |
|
184 | 184 | $entity->_add_relation_to( |
185 | 185 | $parts['id'], |
186 | 186 | $relationName |
@@ -16,163 +16,163 @@ |
||
16 | 16 | class EventEntityRelations extends EventEditorData |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @param array $data |
|
21 | - */ |
|
22 | - private $data; |
|
23 | - |
|
24 | - /** |
|
25 | - * @param int $eventId |
|
26 | - * @return array |
|
27 | - * @throws EE_Error |
|
28 | - * @since $VID:$ |
|
29 | - */ |
|
30 | - public function getData($eventId) |
|
31 | - { |
|
32 | - $this->data = [ |
|
33 | - 'datetimes' => [], |
|
34 | - 'tickets' => [], |
|
35 | - 'prices' => [], |
|
36 | - ]; |
|
37 | - |
|
38 | - $datetimeIds = $this->processDatetimes($eventId); |
|
39 | - $ticketIds = $this->processTickets($datetimeIds); |
|
40 | - $this->processPrices($ticketIds); |
|
41 | - |
|
42 | - return $this->data; |
|
43 | - } |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @param int $eventId |
|
48 | - * @return array |
|
49 | - * @throws EE_Error |
|
50 | - * @since $VID:$ |
|
51 | - */ |
|
52 | - private function processDatetimes($eventId) |
|
53 | - { |
|
54 | - $related_models = [ |
|
55 | - 'tickets' => $this->ticket_model, |
|
56 | - ]; |
|
57 | - // Get the IDs of event datetimes. |
|
58 | - $datetimeIds = $this->datetime_model->get_col([ |
|
59 | - [ 'EVT_ID' => $eventId ], |
|
60 | - 'default_where_conditions' => 'minimum', |
|
61 | - ]); |
|
62 | - foreach ($datetimeIds as $datetimeId) { |
|
63 | - $GID = $this->convertToGlobalId($this->datetime_model->item_name(), $datetimeId); |
|
64 | - foreach ($related_models as $key => $model) { |
|
65 | - // Get the IDs of related entities for the datetime ID. |
|
66 | - $Ids = $model->get_col([ |
|
67 | - [ 'Datetime.DTT_ID' => $datetimeId ], |
|
68 | - 'default_where_conditions' => 'minimum', |
|
69 | - ]); |
|
70 | - $this->data['datetimes'][ $GID ][ $key ] = ! empty($Ids) |
|
71 | - ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
72 | - : []; |
|
73 | - } |
|
74 | - } |
|
75 | - return $datetimeIds; |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - /** |
|
80 | - * @param array $datetimeIds |
|
81 | - * @return array |
|
82 | - * @throws EE_Error |
|
83 | - * @since $VID:$ |
|
84 | - */ |
|
85 | - private function processTickets(array $datetimeIds) |
|
86 | - { |
|
87 | - $related_models = [ |
|
88 | - 'datetimes' => $this->datetime_model, |
|
89 | - 'prices' => $this->price_model, |
|
90 | - ]; |
|
91 | - // Get the IDs of all datetime tickets. |
|
92 | - $ticketIds = $this->ticket_model->get_col([ |
|
93 | - [ 'Datetime.DTT_ID' => ['IN', $datetimeIds] ], |
|
94 | - 'default_where_conditions' => 'minimum', |
|
95 | - ]); |
|
96 | - foreach ($ticketIds as $ticketId) { |
|
97 | - $GID = $this->convertToGlobalId($this->ticket_model->item_name(), $ticketId); |
|
98 | - |
|
99 | - foreach ($related_models as $key => $model) { |
|
100 | - // Get the IDs of related entities for the ticket ID. |
|
101 | - $Ids = $model->get_col([ |
|
102 | - [ 'Ticket.TKT_ID' => $ticketId ], |
|
103 | - 'default_where_conditions' => 'minimum', |
|
104 | - ]); |
|
105 | - $this->data['tickets'][ $GID ][ $key ] = ! empty($Ids) |
|
106 | - ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
107 | - : []; |
|
108 | - } |
|
109 | - } |
|
110 | - return $ticketIds; |
|
111 | - } |
|
112 | - |
|
113 | - |
|
114 | - /** |
|
115 | - * @param array $ticketIds |
|
116 | - * @throws EE_Error |
|
117 | - * @since $VID:$ |
|
118 | - */ |
|
119 | - private function processPrices(array $ticketIds) |
|
120 | - { |
|
121 | - $related_models = [ |
|
122 | - 'tickets' => $this->ticket_model, |
|
123 | - 'priceTypes' => $this->price_type_model, |
|
124 | - ]; |
|
125 | - // Get the IDs of all ticket prices and default prices |
|
126 | - $priceIds = $this->price_model->get_col([ |
|
127 | - [ |
|
128 | - 'OR' => [ |
|
129 | - // either the price is related to any of these tickets |
|
130 | - 'Ticket.TKT_ID' => ['IN', $ticketIds], |
|
131 | - // or it's a default price and not trashed |
|
132 | - 'AND' => [ |
|
133 | - 'PRC_deleted' => 0, |
|
134 | - 'PRC_is_default' => 1, |
|
135 | - ], |
|
136 | - ], |
|
137 | - ], |
|
138 | - 'group_by' => 'PRC_ID', |
|
139 | - 'default_where_conditions' => 'minimum', |
|
140 | - ]); |
|
141 | - foreach ($priceIds as $priceId) { |
|
142 | - $GID = $this->convertToGlobalId($this->price_model->item_name(), $priceId); |
|
143 | - |
|
144 | - foreach ($related_models as $key => $model) { |
|
145 | - // Get the IDs of related entities for the price ID. |
|
146 | - $Ids = $model->get_col([ |
|
147 | - [ 'Price.PRC_ID' => $priceId ], |
|
148 | - 'default_where_conditions' => 'minimum', |
|
149 | - ]); |
|
150 | - $this->data['prices'][ $GID ][ $key ] = ! empty($Ids) |
|
151 | - ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
152 | - : []; |
|
153 | - } |
|
154 | - } |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * Convert the DB ID into GID |
|
160 | - * |
|
161 | - * @param string $type |
|
162 | - * @param int|int[] $ID |
|
163 | - * @return mixed |
|
164 | - */ |
|
165 | - public function convertToGlobalId($type, $ID) |
|
166 | - { |
|
167 | - $convertToGlobalId = [$this, 'convertToGlobalId']; |
|
168 | - if (is_array($ID)) { |
|
169 | - return array_map( |
|
170 | - static function ($id) use ($convertToGlobalId, $type) { |
|
171 | - return $convertToGlobalId($type, $id); |
|
172 | - }, |
|
173 | - $ID |
|
174 | - ); |
|
175 | - } |
|
176 | - return Relay::toGlobalId($type, $ID); |
|
177 | - } |
|
19 | + /** |
|
20 | + * @param array $data |
|
21 | + */ |
|
22 | + private $data; |
|
23 | + |
|
24 | + /** |
|
25 | + * @param int $eventId |
|
26 | + * @return array |
|
27 | + * @throws EE_Error |
|
28 | + * @since $VID:$ |
|
29 | + */ |
|
30 | + public function getData($eventId) |
|
31 | + { |
|
32 | + $this->data = [ |
|
33 | + 'datetimes' => [], |
|
34 | + 'tickets' => [], |
|
35 | + 'prices' => [], |
|
36 | + ]; |
|
37 | + |
|
38 | + $datetimeIds = $this->processDatetimes($eventId); |
|
39 | + $ticketIds = $this->processTickets($datetimeIds); |
|
40 | + $this->processPrices($ticketIds); |
|
41 | + |
|
42 | + return $this->data; |
|
43 | + } |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @param int $eventId |
|
48 | + * @return array |
|
49 | + * @throws EE_Error |
|
50 | + * @since $VID:$ |
|
51 | + */ |
|
52 | + private function processDatetimes($eventId) |
|
53 | + { |
|
54 | + $related_models = [ |
|
55 | + 'tickets' => $this->ticket_model, |
|
56 | + ]; |
|
57 | + // Get the IDs of event datetimes. |
|
58 | + $datetimeIds = $this->datetime_model->get_col([ |
|
59 | + [ 'EVT_ID' => $eventId ], |
|
60 | + 'default_where_conditions' => 'minimum', |
|
61 | + ]); |
|
62 | + foreach ($datetimeIds as $datetimeId) { |
|
63 | + $GID = $this->convertToGlobalId($this->datetime_model->item_name(), $datetimeId); |
|
64 | + foreach ($related_models as $key => $model) { |
|
65 | + // Get the IDs of related entities for the datetime ID. |
|
66 | + $Ids = $model->get_col([ |
|
67 | + [ 'Datetime.DTT_ID' => $datetimeId ], |
|
68 | + 'default_where_conditions' => 'minimum', |
|
69 | + ]); |
|
70 | + $this->data['datetimes'][ $GID ][ $key ] = ! empty($Ids) |
|
71 | + ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
72 | + : []; |
|
73 | + } |
|
74 | + } |
|
75 | + return $datetimeIds; |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + /** |
|
80 | + * @param array $datetimeIds |
|
81 | + * @return array |
|
82 | + * @throws EE_Error |
|
83 | + * @since $VID:$ |
|
84 | + */ |
|
85 | + private function processTickets(array $datetimeIds) |
|
86 | + { |
|
87 | + $related_models = [ |
|
88 | + 'datetimes' => $this->datetime_model, |
|
89 | + 'prices' => $this->price_model, |
|
90 | + ]; |
|
91 | + // Get the IDs of all datetime tickets. |
|
92 | + $ticketIds = $this->ticket_model->get_col([ |
|
93 | + [ 'Datetime.DTT_ID' => ['IN', $datetimeIds] ], |
|
94 | + 'default_where_conditions' => 'minimum', |
|
95 | + ]); |
|
96 | + foreach ($ticketIds as $ticketId) { |
|
97 | + $GID = $this->convertToGlobalId($this->ticket_model->item_name(), $ticketId); |
|
98 | + |
|
99 | + foreach ($related_models as $key => $model) { |
|
100 | + // Get the IDs of related entities for the ticket ID. |
|
101 | + $Ids = $model->get_col([ |
|
102 | + [ 'Ticket.TKT_ID' => $ticketId ], |
|
103 | + 'default_where_conditions' => 'minimum', |
|
104 | + ]); |
|
105 | + $this->data['tickets'][ $GID ][ $key ] = ! empty($Ids) |
|
106 | + ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
107 | + : []; |
|
108 | + } |
|
109 | + } |
|
110 | + return $ticketIds; |
|
111 | + } |
|
112 | + |
|
113 | + |
|
114 | + /** |
|
115 | + * @param array $ticketIds |
|
116 | + * @throws EE_Error |
|
117 | + * @since $VID:$ |
|
118 | + */ |
|
119 | + private function processPrices(array $ticketIds) |
|
120 | + { |
|
121 | + $related_models = [ |
|
122 | + 'tickets' => $this->ticket_model, |
|
123 | + 'priceTypes' => $this->price_type_model, |
|
124 | + ]; |
|
125 | + // Get the IDs of all ticket prices and default prices |
|
126 | + $priceIds = $this->price_model->get_col([ |
|
127 | + [ |
|
128 | + 'OR' => [ |
|
129 | + // either the price is related to any of these tickets |
|
130 | + 'Ticket.TKT_ID' => ['IN', $ticketIds], |
|
131 | + // or it's a default price and not trashed |
|
132 | + 'AND' => [ |
|
133 | + 'PRC_deleted' => 0, |
|
134 | + 'PRC_is_default' => 1, |
|
135 | + ], |
|
136 | + ], |
|
137 | + ], |
|
138 | + 'group_by' => 'PRC_ID', |
|
139 | + 'default_where_conditions' => 'minimum', |
|
140 | + ]); |
|
141 | + foreach ($priceIds as $priceId) { |
|
142 | + $GID = $this->convertToGlobalId($this->price_model->item_name(), $priceId); |
|
143 | + |
|
144 | + foreach ($related_models as $key => $model) { |
|
145 | + // Get the IDs of related entities for the price ID. |
|
146 | + $Ids = $model->get_col([ |
|
147 | + [ 'Price.PRC_ID' => $priceId ], |
|
148 | + 'default_where_conditions' => 'minimum', |
|
149 | + ]); |
|
150 | + $this->data['prices'][ $GID ][ $key ] = ! empty($Ids) |
|
151 | + ? $this->convertToGlobalId($model->item_name(), $Ids) |
|
152 | + : []; |
|
153 | + } |
|
154 | + } |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * Convert the DB ID into GID |
|
160 | + * |
|
161 | + * @param string $type |
|
162 | + * @param int|int[] $ID |
|
163 | + * @return mixed |
|
164 | + */ |
|
165 | + public function convertToGlobalId($type, $ID) |
|
166 | + { |
|
167 | + $convertToGlobalId = [$this, 'convertToGlobalId']; |
|
168 | + if (is_array($ID)) { |
|
169 | + return array_map( |
|
170 | + static function ($id) use ($convertToGlobalId, $type) { |
|
171 | + return $convertToGlobalId($type, $id); |
|
172 | + }, |
|
173 | + $ID |
|
174 | + ); |
|
175 | + } |
|
176 | + return Relay::toGlobalId($type, $ID); |
|
177 | + } |
|
178 | 178 | } |
@@ -21,131 +21,131 @@ |
||
21 | 21 | class EventEditorGraphQLData |
22 | 22 | { |
23 | 23 | |
24 | - /** |
|
25 | - * @var Datetimes $datetimes |
|
26 | - */ |
|
27 | - protected $datetimes; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var Prices $prices |
|
31 | - */ |
|
32 | - protected $prices; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var PriceTypes $price_types |
|
36 | - */ |
|
37 | - protected $price_types; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var Tickets $tickets |
|
41 | - */ |
|
42 | - protected $tickets; |
|
43 | - |
|
44 | - /** |
|
45 | - * @var EventEntityRelations $relations |
|
46 | - */ |
|
47 | - protected $relations; |
|
48 | - |
|
49 | - /** |
|
50 | - * @var NewEventDefaultEntities $default_entities |
|
51 | - */ |
|
52 | - protected $default_entities; |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * EventEditorGraphQLData constructor. |
|
57 | - * |
|
58 | - * @param Datetimes $datetimes |
|
59 | - * @param Prices $prices |
|
60 | - * @param PriceTypes $price_types |
|
61 | - * @param Tickets $tickets |
|
62 | - * @param EventEntityRelations $relations |
|
63 | - * @param NewEventDefaultEntities $default_entities |
|
64 | - */ |
|
65 | - public function __construct( |
|
66 | - Datetimes $datetimes, |
|
67 | - Prices $prices, |
|
68 | - PriceTypes $price_types, |
|
69 | - Tickets $tickets, |
|
70 | - EventEntityRelations $relations, |
|
71 | - NewEventDefaultEntities $default_entities |
|
72 | - ) { |
|
73 | - $this->datetimes = $datetimes; |
|
74 | - $this->default_entities = $default_entities; |
|
75 | - $this->prices = $prices; |
|
76 | - $this->price_types = $price_types; |
|
77 | - $this->relations = $relations; |
|
78 | - $this->tickets = $tickets; |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * @param int $eventId |
|
84 | - * @return array |
|
85 | - * @throws EE_Error |
|
86 | - * @throws ReflectionException |
|
87 | - * @since $VID:$ |
|
88 | - */ |
|
89 | - public function getData($eventId) |
|
90 | - { |
|
91 | - $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
92 | - |
|
93 | - // Avoid undefined variable warning in PHP >= 7.3 |
|
94 | - $tickets = null; |
|
95 | - $prices = null; |
|
96 | - |
|
97 | - if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
98 | - $this->default_entities->getData($eventId); |
|
99 | - $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
100 | - } |
|
101 | - |
|
102 | - if (! empty($datetimes['nodes'])) { |
|
103 | - $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
104 | - |
|
105 | - if (! empty($datetimeIn)) { |
|
106 | - $tickets = $this->tickets->getData(['datetimeIn' => $datetimeIn]); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - if (! empty($tickets['nodes'])) { |
|
111 | - $ticketIds = wp_list_pluck($tickets['nodes'], 'dbId'); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * We need to get the prices that are related to the given tickets |
|
116 | - * Or are defalut prices. |
|
117 | - * We will first query for such prices and then limit our GQL query |
|
118 | - * to those price IDs. |
|
119 | - */ |
|
120 | - $where_params = [ |
|
121 | - 'AND' => [ |
|
122 | - 'PRC_deleted' => 0, |
|
123 | - 'PRC_is_default' => 1, |
|
124 | - ], |
|
125 | - ]; |
|
126 | - if (! empty($ticketIds)) { |
|
127 | - $where_params['Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
128 | - } |
|
129 | - $priceIds = EEM_Price::instance()->get_col([ |
|
130 | - [ |
|
131 | - // If the price is related to any of these tickets |
|
132 | - // OR |
|
133 | - // it's a default price and not trashed |
|
134 | - 'OR' => $where_params, |
|
135 | - ], |
|
136 | - 'group_by' => 'PRC_ID', |
|
137 | - 'default_where_conditions' => 'minimum', |
|
138 | - ]); |
|
139 | - |
|
140 | - if (! empty($priceIds)) { |
|
141 | - $prices = $this->prices->getData(['idIn' => $priceIds]); |
|
142 | - } |
|
143 | - |
|
144 | - $priceTypes = $this->price_types->getData(); |
|
145 | - |
|
146 | - $relations = $this->relations->getData($eventId); |
|
147 | - |
|
148 | - |
|
149 | - return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
150 | - } |
|
24 | + /** |
|
25 | + * @var Datetimes $datetimes |
|
26 | + */ |
|
27 | + protected $datetimes; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var Prices $prices |
|
31 | + */ |
|
32 | + protected $prices; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var PriceTypes $price_types |
|
36 | + */ |
|
37 | + protected $price_types; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var Tickets $tickets |
|
41 | + */ |
|
42 | + protected $tickets; |
|
43 | + |
|
44 | + /** |
|
45 | + * @var EventEntityRelations $relations |
|
46 | + */ |
|
47 | + protected $relations; |
|
48 | + |
|
49 | + /** |
|
50 | + * @var NewEventDefaultEntities $default_entities |
|
51 | + */ |
|
52 | + protected $default_entities; |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * EventEditorGraphQLData constructor. |
|
57 | + * |
|
58 | + * @param Datetimes $datetimes |
|
59 | + * @param Prices $prices |
|
60 | + * @param PriceTypes $price_types |
|
61 | + * @param Tickets $tickets |
|
62 | + * @param EventEntityRelations $relations |
|
63 | + * @param NewEventDefaultEntities $default_entities |
|
64 | + */ |
|
65 | + public function __construct( |
|
66 | + Datetimes $datetimes, |
|
67 | + Prices $prices, |
|
68 | + PriceTypes $price_types, |
|
69 | + Tickets $tickets, |
|
70 | + EventEntityRelations $relations, |
|
71 | + NewEventDefaultEntities $default_entities |
|
72 | + ) { |
|
73 | + $this->datetimes = $datetimes; |
|
74 | + $this->default_entities = $default_entities; |
|
75 | + $this->prices = $prices; |
|
76 | + $this->price_types = $price_types; |
|
77 | + $this->relations = $relations; |
|
78 | + $this->tickets = $tickets; |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * @param int $eventId |
|
84 | + * @return array |
|
85 | + * @throws EE_Error |
|
86 | + * @throws ReflectionException |
|
87 | + * @since $VID:$ |
|
88 | + */ |
|
89 | + public function getData($eventId) |
|
90 | + { |
|
91 | + $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
92 | + |
|
93 | + // Avoid undefined variable warning in PHP >= 7.3 |
|
94 | + $tickets = null; |
|
95 | + $prices = null; |
|
96 | + |
|
97 | + if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
|
98 | + $this->default_entities->getData($eventId); |
|
99 | + $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
|
100 | + } |
|
101 | + |
|
102 | + if (! empty($datetimes['nodes'])) { |
|
103 | + $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
|
104 | + |
|
105 | + if (! empty($datetimeIn)) { |
|
106 | + $tickets = $this->tickets->getData(['datetimeIn' => $datetimeIn]); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + if (! empty($tickets['nodes'])) { |
|
111 | + $ticketIds = wp_list_pluck($tickets['nodes'], 'dbId'); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * We need to get the prices that are related to the given tickets |
|
116 | + * Or are defalut prices. |
|
117 | + * We will first query for such prices and then limit our GQL query |
|
118 | + * to those price IDs. |
|
119 | + */ |
|
120 | + $where_params = [ |
|
121 | + 'AND' => [ |
|
122 | + 'PRC_deleted' => 0, |
|
123 | + 'PRC_is_default' => 1, |
|
124 | + ], |
|
125 | + ]; |
|
126 | + if (! empty($ticketIds)) { |
|
127 | + $where_params['Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
128 | + } |
|
129 | + $priceIds = EEM_Price::instance()->get_col([ |
|
130 | + [ |
|
131 | + // If the price is related to any of these tickets |
|
132 | + // OR |
|
133 | + // it's a default price and not trashed |
|
134 | + 'OR' => $where_params, |
|
135 | + ], |
|
136 | + 'group_by' => 'PRC_ID', |
|
137 | + 'default_where_conditions' => 'minimum', |
|
138 | + ]); |
|
139 | + |
|
140 | + if (! empty($priceIds)) { |
|
141 | + $prices = $this->prices->getData(['idIn' => $priceIds]); |
|
142 | + } |
|
143 | + |
|
144 | + $priceTypes = $this->price_types->getData(); |
|
145 | + |
|
146 | + $relations = $this->relations->getData($eventId); |
|
147 | + |
|
148 | + |
|
149 | + return compact('datetimes', 'tickets', 'prices', 'priceTypes', 'relations'); |
|
150 | + } |
|
151 | 151 | } |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | $datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
100 | 100 | } |
101 | 101 | |
102 | - if (! empty($datetimes['nodes'])) { |
|
102 | + if ( ! empty($datetimes['nodes'])) { |
|
103 | 103 | $datetimeIn = wp_list_pluck($datetimes['nodes'], 'id'); |
104 | 104 | |
105 | - if (! empty($datetimeIn)) { |
|
105 | + if ( ! empty($datetimeIn)) { |
|
106 | 106 | $tickets = $this->tickets->getData(['datetimeIn' => $datetimeIn]); |
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - if (! empty($tickets['nodes'])) { |
|
110 | + if ( ! empty($tickets['nodes'])) { |
|
111 | 111 | $ticketIds = wp_list_pluck($tickets['nodes'], 'dbId'); |
112 | 112 | } |
113 | 113 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | 'PRC_is_default' => 1, |
124 | 124 | ], |
125 | 125 | ]; |
126 | - if (! empty($ticketIds)) { |
|
126 | + if ( ! empty($ticketIds)) { |
|
127 | 127 | $where_params['Ticket.TKT_ID'] = ['IN', $ticketIds]; |
128 | 128 | } |
129 | 129 | $priceIds = EEM_Price::instance()->get_col([ |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | 'default_where_conditions' => 'minimum', |
138 | 138 | ]); |
139 | 139 | |
140 | - if (! empty($priceIds)) { |
|
140 | + if ( ! empty($priceIds)) { |
|
141 | 141 | $prices = $this->prices->getData(['idIn' => $priceIds]); |
142 | 142 | } |
143 | 143 |
@@ -19,112 +19,112 @@ |
||
19 | 19 | { |
20 | 20 | |
21 | 21 | |
22 | - /** |
|
23 | - * TicketConnection constructor. |
|
24 | - * |
|
25 | - * @param EEM_Price $model |
|
26 | - */ |
|
27 | - public function __construct(EEM_Price $model) |
|
28 | - { |
|
29 | - $this->model = $model; |
|
30 | - } |
|
22 | + /** |
|
23 | + * TicketConnection constructor. |
|
24 | + * |
|
25 | + * @param EEM_Price $model |
|
26 | + */ |
|
27 | + public function __construct(EEM_Price $model) |
|
28 | + { |
|
29 | + $this->model = $model; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @return array |
|
35 | - * @since $VID:$ |
|
36 | - */ |
|
37 | - public function config() |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'fromType' => $this->namespace . 'Ticket', |
|
41 | - 'toType' => $this->namespace . 'Price', |
|
42 | - 'fromFieldName' => 'prices', |
|
43 | - 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
|
44 | - 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | - 'resolve' => [$this, 'resolveConnection'], |
|
46 | - ]; |
|
47 | - } |
|
33 | + /** |
|
34 | + * @return array |
|
35 | + * @since $VID:$ |
|
36 | + */ |
|
37 | + public function config() |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'fromType' => $this->namespace . 'Ticket', |
|
41 | + 'toType' => $this->namespace . 'Price', |
|
42 | + 'fromFieldName' => 'prices', |
|
43 | + 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
|
44 | + 'connectionArgs' => TicketPricesConnection::get_connection_args(), |
|
45 | + 'resolve' => [$this, 'resolveConnection'], |
|
46 | + ]; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * @param $entity |
|
52 | - * @param $args |
|
53 | - * @param $context |
|
54 | - * @param $info |
|
55 | - * @return array |
|
56 | - * @throws Exception |
|
57 | - * @since $VID:$ |
|
58 | - */ |
|
59 | - public function resolveConnection($entity, $args, $context, $info) |
|
60 | - { |
|
61 | - $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
62 | - return $resolver->get_connection(); |
|
63 | - } |
|
50 | + /** |
|
51 | + * @param $entity |
|
52 | + * @param $args |
|
53 | + * @param $context |
|
54 | + * @param $info |
|
55 | + * @return array |
|
56 | + * @throws Exception |
|
57 | + * @since $VID:$ |
|
58 | + */ |
|
59 | + public function resolveConnection($entity, $args, $context, $info) |
|
60 | + { |
|
61 | + $resolver = new PriceConnectionResolver($entity, $args, $context, $info); |
|
62 | + return $resolver->get_connection(); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * Given an optional array of args, this returns the args to be used in the connection |
|
67 | - * |
|
68 | - * @access public |
|
69 | - * @param array $args The args to modify the defaults |
|
70 | - * |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
74 | - public static function get_connection_args($args = []) |
|
75 | - { |
|
76 | - return array_merge( |
|
77 | - [ |
|
78 | - 'in' => [ |
|
79 | - 'type' => ['list_of' => 'ID'], |
|
80 | - 'description' => esc_html__('Limit prices to the given globally unique IDs', 'event_espresso'), |
|
81 | - ], |
|
82 | - 'idIn' => [ |
|
83 | - 'type' => ['list_of' => 'ID'], |
|
84 | - 'description' => esc_html__('Limit prices to the given IDs', 'event_espresso'), |
|
85 | - ], |
|
86 | - 'ticket' => [ |
|
87 | - 'type' => 'ID', |
|
88 | - 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
89 | - ], |
|
90 | - 'ticketIn' => [ |
|
91 | - 'type' => ['list_of' => 'ID'], |
|
92 | - 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
93 | - ], |
|
94 | - 'ticketId' => [ |
|
95 | - 'type' => 'Int', |
|
96 | - 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
97 | - ], |
|
98 | - 'ticketIdIn' => [ |
|
99 | - 'type' => ['list_of' => 'Int'], |
|
100 | - 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
101 | - ], |
|
102 | - 'priceType' => [ |
|
103 | - 'type' => 'ID', |
|
104 | - 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
105 | - ], |
|
106 | - 'priceTypeIn' => [ |
|
107 | - 'type' => ['list_of' => 'ID'], |
|
108 | - 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
109 | - ], |
|
110 | - 'priceTypeId' => [ |
|
111 | - 'type' => 'Int', |
|
112 | - 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
113 | - ], |
|
114 | - 'priceTypeIdIn' => [ |
|
115 | - 'type' => ['list_of' => 'Int'], |
|
116 | - 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
117 | - ], |
|
118 | - 'priceBaseType' => [ |
|
119 | - 'type' => 'PriceBaseTypeEnum', |
|
120 | - 'description' => esc_html__('Price Base type.', 'event_espresso'), |
|
121 | - ], |
|
122 | - 'priceBaseTypeIn' => [ |
|
123 | - 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
124 | - 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
125 | - ], |
|
126 | - ], |
|
127 | - $args |
|
128 | - ); |
|
129 | - } |
|
65 | + /** |
|
66 | + * Given an optional array of args, this returns the args to be used in the connection |
|
67 | + * |
|
68 | + * @access public |
|
69 | + * @param array $args The args to modify the defaults |
|
70 | + * |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
74 | + public static function get_connection_args($args = []) |
|
75 | + { |
|
76 | + return array_merge( |
|
77 | + [ |
|
78 | + 'in' => [ |
|
79 | + 'type' => ['list_of' => 'ID'], |
|
80 | + 'description' => esc_html__('Limit prices to the given globally unique IDs', 'event_espresso'), |
|
81 | + ], |
|
82 | + 'idIn' => [ |
|
83 | + 'type' => ['list_of' => 'ID'], |
|
84 | + 'description' => esc_html__('Limit prices to the given IDs', 'event_espresso'), |
|
85 | + ], |
|
86 | + 'ticket' => [ |
|
87 | + 'type' => 'ID', |
|
88 | + 'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'), |
|
89 | + ], |
|
90 | + 'ticketIn' => [ |
|
91 | + 'type' => ['list_of' => 'ID'], |
|
92 | + 'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'), |
|
93 | + ], |
|
94 | + 'ticketId' => [ |
|
95 | + 'type' => 'Int', |
|
96 | + 'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'), |
|
97 | + ], |
|
98 | + 'ticketIdIn' => [ |
|
99 | + 'type' => ['list_of' => 'Int'], |
|
100 | + 'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'), |
|
101 | + ], |
|
102 | + 'priceType' => [ |
|
103 | + 'type' => 'ID', |
|
104 | + 'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'), |
|
105 | + ], |
|
106 | + 'priceTypeIn' => [ |
|
107 | + 'type' => ['list_of' => 'ID'], |
|
108 | + 'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'), |
|
109 | + ], |
|
110 | + 'priceTypeId' => [ |
|
111 | + 'type' => 'Int', |
|
112 | + 'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'), |
|
113 | + ], |
|
114 | + 'priceTypeIdIn' => [ |
|
115 | + 'type' => ['list_of' => 'Int'], |
|
116 | + 'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'), |
|
117 | + ], |
|
118 | + 'priceBaseType' => [ |
|
119 | + 'type' => 'PriceBaseTypeEnum', |
|
120 | + 'description' => esc_html__('Price Base type.', 'event_espresso'), |
|
121 | + ], |
|
122 | + 'priceBaseTypeIn' => [ |
|
123 | + 'type' => ['list_of' => 'PriceBaseTypeEnum'], |
|
124 | + 'description' => esc_html__('Price Base types.', 'event_espresso'), |
|
125 | + ], |
|
126 | + ], |
|
127 | + $args |
|
128 | + ); |
|
129 | + } |
|
130 | 130 | } |
@@ -37,8 +37,8 @@ |
||
37 | 37 | public function config() |
38 | 38 | { |
39 | 39 | return [ |
40 | - 'fromType' => $this->namespace . 'Ticket', |
|
41 | - 'toType' => $this->namespace . 'Price', |
|
40 | + 'fromType' => $this->namespace.'Ticket', |
|
41 | + 'toType' => $this->namespace.'Price', |
|
42 | 42 | 'fromFieldName' => 'prices', |
43 | 43 | 'connectionTypeName' => "{$this->namespace}TicketPricesConnection", |
44 | 44 | 'connectionArgs' => TicketPricesConnection::get_connection_args(), |