@@ -23,187 +23,187 @@ |
||
23 | 23 | class Attendee extends TypeBase |
24 | 24 | { |
25 | 25 | |
26 | - /** |
|
27 | - * Attendee constructor. |
|
28 | - * |
|
29 | - * @param EEM_Attendee $attendee_model |
|
30 | - */ |
|
31 | - public function __construct(EEM_Attendee $attendee_model) |
|
32 | - { |
|
33 | - $this->setName($this->namespace . 'Attendee'); |
|
34 | - $this->setIsCustomPostType(false); // Set to false to use our model queries |
|
35 | - parent::__construct($attendee_model); |
|
36 | - } |
|
26 | + /** |
|
27 | + * Attendee constructor. |
|
28 | + * |
|
29 | + * @param EEM_Attendee $attendee_model |
|
30 | + */ |
|
31 | + public function __construct(EEM_Attendee $attendee_model) |
|
32 | + { |
|
33 | + $this->setName($this->namespace . 'Attendee'); |
|
34 | + $this->setIsCustomPostType(false); // Set to false to use our model queries |
|
35 | + parent::__construct($attendee_model); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * @return GraphQLFieldInterface[] |
|
41 | - */ |
|
42 | - public function getFields(): array |
|
43 | - { |
|
44 | - $fields = [ |
|
45 | - new GraphQLField( |
|
46 | - 'id', |
|
47 | - ['non_null' => 'ID'], |
|
48 | - null, |
|
49 | - esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
50 | - ), |
|
51 | - new GraphQLOutputField( |
|
52 | - 'dbId', |
|
53 | - ['non_null' => 'Int'], |
|
54 | - 'ID', |
|
55 | - esc_html__('The attendee ID.', 'event_espresso') |
|
56 | - ), |
|
57 | - new GraphQLOutputField( |
|
58 | - 'cacheId', |
|
59 | - ['non_null' => 'String'], |
|
60 | - null, |
|
61 | - esc_html__('The cache ID of the object.', 'event_espresso') |
|
62 | - ), |
|
63 | - new GraphQLOutputField( |
|
64 | - 'address', |
|
65 | - 'String', |
|
66 | - 'address', |
|
67 | - esc_html__('Address Part 1', 'event_espresso'), |
|
68 | - null, |
|
69 | - null, |
|
70 | - ['ee_edit_contacts'] |
|
71 | - ), |
|
72 | - new GraphQLOutputField( |
|
73 | - 'address2', |
|
74 | - 'String', |
|
75 | - 'address2', |
|
76 | - esc_html__('Address Part 2', 'event_espresso'), |
|
77 | - null, |
|
78 | - null, |
|
79 | - ['ee_edit_contacts'] |
|
80 | - ), |
|
81 | - new GraphQLOutputField( |
|
82 | - 'avatar', |
|
83 | - 'String', |
|
84 | - null, |
|
85 | - esc_html__('User avatar URL', 'event_espresso'), |
|
86 | - null, |
|
87 | - [$this, 'getAvatar'], |
|
88 | - ['ee_edit_contacts'] |
|
89 | - ), |
|
90 | - new GraphQLOutputField( |
|
91 | - 'bio', |
|
92 | - 'String', |
|
93 | - 'bio', |
|
94 | - esc_html__('Attendee Biography', 'event_espresso'), |
|
95 | - null, |
|
96 | - null, |
|
97 | - ['ee_edit_contacts'] |
|
98 | - ), |
|
99 | - new GraphQLOutputField( |
|
100 | - 'city', |
|
101 | - 'String', |
|
102 | - 'city', |
|
103 | - esc_html__('City', 'event_espresso'), |
|
104 | - null, |
|
105 | - null, |
|
106 | - ['ee_edit_contacts'] |
|
107 | - ), |
|
108 | - new GraphQLOutputField( |
|
109 | - 'country', |
|
110 | - $this->namespace . 'Country', |
|
111 | - null, |
|
112 | - esc_html__('Country', 'event_espresso'), |
|
113 | - null, |
|
114 | - null, |
|
115 | - ['ee_edit_contacts'] |
|
116 | - ), |
|
117 | - new GraphQLOutputField( |
|
118 | - 'email', |
|
119 | - 'String', |
|
120 | - 'email', |
|
121 | - esc_html__('Email Address', 'event_espresso'), |
|
122 | - null, |
|
123 | - null, |
|
124 | - ['ee_edit_contacts'] |
|
125 | - ), |
|
126 | - new GraphQLOutputField( |
|
127 | - 'firstName', |
|
128 | - 'String', |
|
129 | - 'fname', |
|
130 | - esc_html__('Attendee First Name', 'event_espresso') |
|
131 | - ), |
|
132 | - new GraphQLOutputField( |
|
133 | - 'fullName', |
|
134 | - 'String', |
|
135 | - 'full_name', |
|
136 | - esc_html__('Attendee Name', 'event_espresso') |
|
137 | - ), |
|
138 | - new GraphQLOutputField( |
|
139 | - 'lastName', |
|
140 | - 'String', |
|
141 | - 'lname', |
|
142 | - esc_html__('Attendee Last Name', 'event_espresso') |
|
143 | - ), |
|
144 | - new GraphQLOutputField( |
|
145 | - 'phone', |
|
146 | - 'String', |
|
147 | - 'phone', |
|
148 | - esc_html__('Phone', 'event_espresso'), |
|
149 | - null, |
|
150 | - null, |
|
151 | - ['ee_edit_contacts'] |
|
152 | - ), |
|
153 | - new GraphQLOutputField( |
|
154 | - 'shortBio', |
|
155 | - 'String', |
|
156 | - 'short_bio', |
|
157 | - esc_html__('Attendee Short Biography', 'event_espresso'), |
|
158 | - null, |
|
159 | - null, |
|
160 | - ['ee_edit_contacts'] |
|
161 | - ), |
|
162 | - new GraphQLOutputField( |
|
163 | - 'state', |
|
164 | - $this->namespace . 'State', |
|
165 | - null, |
|
166 | - esc_html__('State', 'event_espresso'), |
|
167 | - null, |
|
168 | - null, |
|
169 | - ['ee_edit_contacts'] |
|
170 | - ), |
|
171 | - new GraphQLOutputField( |
|
172 | - 'zip', |
|
173 | - 'String', |
|
174 | - 'zip', |
|
175 | - esc_html__('ZIP/Postal Code', 'event_espresso'), |
|
176 | - null, |
|
177 | - null, |
|
178 | - ['ee_edit_contacts'] |
|
179 | - ), |
|
180 | - ]; |
|
39 | + /** |
|
40 | + * @return GraphQLFieldInterface[] |
|
41 | + */ |
|
42 | + public function getFields(): array |
|
43 | + { |
|
44 | + $fields = [ |
|
45 | + new GraphQLField( |
|
46 | + 'id', |
|
47 | + ['non_null' => 'ID'], |
|
48 | + null, |
|
49 | + esc_html__('The globally unique ID for the object.', 'event_espresso') |
|
50 | + ), |
|
51 | + new GraphQLOutputField( |
|
52 | + 'dbId', |
|
53 | + ['non_null' => 'Int'], |
|
54 | + 'ID', |
|
55 | + esc_html__('The attendee ID.', 'event_espresso') |
|
56 | + ), |
|
57 | + new GraphQLOutputField( |
|
58 | + 'cacheId', |
|
59 | + ['non_null' => 'String'], |
|
60 | + null, |
|
61 | + esc_html__('The cache ID of the object.', 'event_espresso') |
|
62 | + ), |
|
63 | + new GraphQLOutputField( |
|
64 | + 'address', |
|
65 | + 'String', |
|
66 | + 'address', |
|
67 | + esc_html__('Address Part 1', 'event_espresso'), |
|
68 | + null, |
|
69 | + null, |
|
70 | + ['ee_edit_contacts'] |
|
71 | + ), |
|
72 | + new GraphQLOutputField( |
|
73 | + 'address2', |
|
74 | + 'String', |
|
75 | + 'address2', |
|
76 | + esc_html__('Address Part 2', 'event_espresso'), |
|
77 | + null, |
|
78 | + null, |
|
79 | + ['ee_edit_contacts'] |
|
80 | + ), |
|
81 | + new GraphQLOutputField( |
|
82 | + 'avatar', |
|
83 | + 'String', |
|
84 | + null, |
|
85 | + esc_html__('User avatar URL', 'event_espresso'), |
|
86 | + null, |
|
87 | + [$this, 'getAvatar'], |
|
88 | + ['ee_edit_contacts'] |
|
89 | + ), |
|
90 | + new GraphQLOutputField( |
|
91 | + 'bio', |
|
92 | + 'String', |
|
93 | + 'bio', |
|
94 | + esc_html__('Attendee Biography', 'event_espresso'), |
|
95 | + null, |
|
96 | + null, |
|
97 | + ['ee_edit_contacts'] |
|
98 | + ), |
|
99 | + new GraphQLOutputField( |
|
100 | + 'city', |
|
101 | + 'String', |
|
102 | + 'city', |
|
103 | + esc_html__('City', 'event_espresso'), |
|
104 | + null, |
|
105 | + null, |
|
106 | + ['ee_edit_contacts'] |
|
107 | + ), |
|
108 | + new GraphQLOutputField( |
|
109 | + 'country', |
|
110 | + $this->namespace . 'Country', |
|
111 | + null, |
|
112 | + esc_html__('Country', 'event_espresso'), |
|
113 | + null, |
|
114 | + null, |
|
115 | + ['ee_edit_contacts'] |
|
116 | + ), |
|
117 | + new GraphQLOutputField( |
|
118 | + 'email', |
|
119 | + 'String', |
|
120 | + 'email', |
|
121 | + esc_html__('Email Address', 'event_espresso'), |
|
122 | + null, |
|
123 | + null, |
|
124 | + ['ee_edit_contacts'] |
|
125 | + ), |
|
126 | + new GraphQLOutputField( |
|
127 | + 'firstName', |
|
128 | + 'String', |
|
129 | + 'fname', |
|
130 | + esc_html__('Attendee First Name', 'event_espresso') |
|
131 | + ), |
|
132 | + new GraphQLOutputField( |
|
133 | + 'fullName', |
|
134 | + 'String', |
|
135 | + 'full_name', |
|
136 | + esc_html__('Attendee Name', 'event_espresso') |
|
137 | + ), |
|
138 | + new GraphQLOutputField( |
|
139 | + 'lastName', |
|
140 | + 'String', |
|
141 | + 'lname', |
|
142 | + esc_html__('Attendee Last Name', 'event_espresso') |
|
143 | + ), |
|
144 | + new GraphQLOutputField( |
|
145 | + 'phone', |
|
146 | + 'String', |
|
147 | + 'phone', |
|
148 | + esc_html__('Phone', 'event_espresso'), |
|
149 | + null, |
|
150 | + null, |
|
151 | + ['ee_edit_contacts'] |
|
152 | + ), |
|
153 | + new GraphQLOutputField( |
|
154 | + 'shortBio', |
|
155 | + 'String', |
|
156 | + 'short_bio', |
|
157 | + esc_html__('Attendee Short Biography', 'event_espresso'), |
|
158 | + null, |
|
159 | + null, |
|
160 | + ['ee_edit_contacts'] |
|
161 | + ), |
|
162 | + new GraphQLOutputField( |
|
163 | + 'state', |
|
164 | + $this->namespace . 'State', |
|
165 | + null, |
|
166 | + esc_html__('State', 'event_espresso'), |
|
167 | + null, |
|
168 | + null, |
|
169 | + ['ee_edit_contacts'] |
|
170 | + ), |
|
171 | + new GraphQLOutputField( |
|
172 | + 'zip', |
|
173 | + 'String', |
|
174 | + 'zip', |
|
175 | + esc_html__('ZIP/Postal Code', 'event_espresso'), |
|
176 | + null, |
|
177 | + null, |
|
178 | + ['ee_edit_contacts'] |
|
179 | + ), |
|
180 | + ]; |
|
181 | 181 | |
182 | - return apply_filters( |
|
183 | - 'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields', |
|
184 | - $fields, |
|
185 | - $this->name, |
|
186 | - $this->model |
|
187 | - ); |
|
188 | - } |
|
182 | + return apply_filters( |
|
183 | + 'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields', |
|
184 | + $fields, |
|
185 | + $this->name, |
|
186 | + $this->model |
|
187 | + ); |
|
188 | + } |
|
189 | 189 | |
190 | 190 | |
191 | - /** |
|
192 | - * @param EE_Attendee $source The source that's passed down the GraphQL queries |
|
193 | - * @param array $args The inputArgs on the field |
|
194 | - * @param AppContext $context The AppContext passed down the GraphQL tree |
|
195 | - * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
196 | - * @return string|null |
|
197 | - * @throws EE_Error |
|
198 | - */ |
|
199 | - public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string |
|
200 | - { |
|
201 | - $email = $source->email(); |
|
191 | + /** |
|
192 | + * @param EE_Attendee $source The source that's passed down the GraphQL queries |
|
193 | + * @param array $args The inputArgs on the field |
|
194 | + * @param AppContext $context The AppContext passed down the GraphQL tree |
|
195 | + * @param ResolveInfo $info The ResolveInfo passed down the GraphQL tree |
|
196 | + * @return string|null |
|
197 | + * @throws EE_Error |
|
198 | + */ |
|
199 | + public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string |
|
200 | + { |
|
201 | + $email = $source->email(); |
|
202 | 202 | |
203 | - if (empty($email)) { |
|
204 | - return get_avatar_url('', ['force_default' => true]); |
|
205 | - } |
|
206 | - $avatar = get_avatar_url($email); |
|
207 | - return $avatar ?: null; |
|
208 | - } |
|
203 | + if (empty($email)) { |
|
204 | + return get_avatar_url('', ['force_default' => true]); |
|
205 | + } |
|
206 | + $avatar = get_avatar_url($email); |
|
207 | + return $avatar ?: null; |
|
208 | + } |
|
209 | 209 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function __construct(EEM_Attendee $attendee_model) |
32 | 32 | { |
33 | - $this->setName($this->namespace . 'Attendee'); |
|
33 | + $this->setName($this->namespace.'Attendee'); |
|
34 | 34 | $this->setIsCustomPostType(false); // Set to false to use our model queries |
35 | 35 | parent::__construct($attendee_model); |
36 | 36 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | ), |
108 | 108 | new GraphQLOutputField( |
109 | 109 | 'country', |
110 | - $this->namespace . 'Country', |
|
110 | + $this->namespace.'Country', |
|
111 | 111 | null, |
112 | 112 | esc_html__('Country', 'event_espresso'), |
113 | 113 | null, |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ), |
162 | 162 | new GraphQLOutputField( |
163 | 163 | 'state', |
164 | - $this->namespace . 'State', |
|
164 | + $this->namespace.'State', |
|
165 | 165 | null, |
166 | 166 | esc_html__('State', 'event_espresso'), |
167 | 167 | null, |
@@ -14,127 +14,127 @@ |
||
14 | 14 | */ |
15 | 15 | class FormSectionConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - public function get_loader_name(): string |
|
19 | - { |
|
20 | - return 'espresso_formSection'; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @return EEM_Form_Section |
|
25 | - * @throws EE_Error |
|
26 | - * @throws InvalidArgumentException |
|
27 | - * @throws InvalidDataTypeException |
|
28 | - * @throws InvalidInterfaceException |
|
29 | - * @throws ReflectionException |
|
30 | - */ |
|
31 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | - public function get_query(): EEM_Form_Section |
|
33 | - { |
|
34 | - return EEM_Form_Section::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(): array |
|
45 | - { |
|
46 | - $results = $this->query->get_col($this->query_args); |
|
47 | - return ! empty($results) ? $results : []; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
53 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
54 | - * handle batch resolution of the posts. |
|
55 | - * |
|
56 | - * @return array |
|
57 | - * @throws InvalidArgumentException |
|
58 | - * @throws InvalidDataTypeException |
|
59 | - * @throws InvalidInterfaceException |
|
60 | - */ |
|
61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | - public function get_query_args(): array |
|
63 | - { |
|
64 | - $where_params = []; |
|
65 | - $query_args = []; |
|
66 | - |
|
67 | - $query_args['limit'] = $this->getLimit(); |
|
68 | - |
|
69 | - // Avoid multiple entries by join. |
|
70 | - $query_args['group_by'] = 'FSC_UUID'; |
|
71 | - |
|
72 | - /** |
|
73 | - * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
74 | - */ |
|
75 | - $input_fields = []; |
|
76 | - if (! empty($this->args['where'])) { |
|
77 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
78 | - |
|
79 | - // Use the proper operator. |
|
80 | - if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
81 | - $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
|
82 | - } |
|
83 | - if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
84 | - $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
|
85 | - } |
|
86 | - if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
87 | - $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * Merge the input_fields with the default query_args |
|
93 | - */ |
|
94 | - if (! empty($input_fields)) { |
|
95 | - $where_params = array_merge($where_params, $input_fields); |
|
96 | - } |
|
97 | - |
|
98 | - $where_params = apply_filters( |
|
99 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params', |
|
100 | - $where_params, |
|
101 | - $this->source, |
|
102 | - $this->args |
|
103 | - ); |
|
104 | - |
|
105 | - if (! empty($where_params)) { |
|
106 | - $query_args[] = $where_params; |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * Return the $query_args |
|
112 | - */ |
|
113 | - return apply_filters( |
|
114 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args', |
|
115 | - $query_args, |
|
116 | - $this->source, |
|
117 | - $this->args |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
124 | - * friendly keys. |
|
125 | - * |
|
126 | - * @param array $where_args |
|
127 | - * @return array |
|
128 | - */ |
|
129 | - public function sanitizeInputFields(array $where_args): array |
|
130 | - { |
|
131 | - return $this->sanitizeWhereArgsForInputFields( |
|
132 | - $where_args, |
|
133 | - [ |
|
134 | - 'appliesTo' => 'FSC_appliesTo', |
|
135 | - 'belongsTo' => 'FSC_belongsTo', |
|
136 | - 'status' => 'FSC_status', |
|
137 | - ] |
|
138 | - ); |
|
139 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + public function get_loader_name(): string |
|
19 | + { |
|
20 | + return 'espresso_formSection'; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @return EEM_Form_Section |
|
25 | + * @throws EE_Error |
|
26 | + * @throws InvalidArgumentException |
|
27 | + * @throws InvalidDataTypeException |
|
28 | + * @throws InvalidInterfaceException |
|
29 | + * @throws ReflectionException |
|
30 | + */ |
|
31 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | + public function get_query(): EEM_Form_Section |
|
33 | + { |
|
34 | + return EEM_Form_Section::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(): array |
|
45 | + { |
|
46 | + $results = $this->query->get_col($this->query_args); |
|
47 | + return ! empty($results) ? $results : []; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
53 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
54 | + * handle batch resolution of the posts. |
|
55 | + * |
|
56 | + * @return array |
|
57 | + * @throws InvalidArgumentException |
|
58 | + * @throws InvalidDataTypeException |
|
59 | + * @throws InvalidInterfaceException |
|
60 | + */ |
|
61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | + public function get_query_args(): array |
|
63 | + { |
|
64 | + $where_params = []; |
|
65 | + $query_args = []; |
|
66 | + |
|
67 | + $query_args['limit'] = $this->getLimit(); |
|
68 | + |
|
69 | + // Avoid multiple entries by join. |
|
70 | + $query_args['group_by'] = 'FSC_UUID'; |
|
71 | + |
|
72 | + /** |
|
73 | + * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
74 | + */ |
|
75 | + $input_fields = []; |
|
76 | + if (! empty($this->args['where'])) { |
|
77 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
78 | + |
|
79 | + // Use the proper operator. |
|
80 | + if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
81 | + $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
|
82 | + } |
|
83 | + if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
84 | + $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
|
85 | + } |
|
86 | + if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
87 | + $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * Merge the input_fields with the default query_args |
|
93 | + */ |
|
94 | + if (! empty($input_fields)) { |
|
95 | + $where_params = array_merge($where_params, $input_fields); |
|
96 | + } |
|
97 | + |
|
98 | + $where_params = apply_filters( |
|
99 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params', |
|
100 | + $where_params, |
|
101 | + $this->source, |
|
102 | + $this->args |
|
103 | + ); |
|
104 | + |
|
105 | + if (! empty($where_params)) { |
|
106 | + $query_args[] = $where_params; |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * Return the $query_args |
|
112 | + */ |
|
113 | + return apply_filters( |
|
114 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args', |
|
115 | + $query_args, |
|
116 | + $this->source, |
|
117 | + $this->args |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
124 | + * friendly keys. |
|
125 | + * |
|
126 | + * @param array $where_args |
|
127 | + * @return array |
|
128 | + */ |
|
129 | + public function sanitizeInputFields(array $where_args): array |
|
130 | + { |
|
131 | + return $this->sanitizeWhereArgsForInputFields( |
|
132 | + $where_args, |
|
133 | + [ |
|
134 | + 'appliesTo' => 'FSC_appliesTo', |
|
135 | + 'belongsTo' => 'FSC_belongsTo', |
|
136 | + 'status' => 'FSC_status', |
|
137 | + ] |
|
138 | + ); |
|
139 | + } |
|
140 | 140 | } |
@@ -73,17 +73,17 @@ discard block |
||
73 | 73 | * Collect the input fields and sanitize them to prepare them for sending to the Query |
74 | 74 | */ |
75 | 75 | $input_fields = []; |
76 | - if (! empty($this->args['where'])) { |
|
76 | + if ( ! empty($this->args['where'])) { |
|
77 | 77 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
78 | 78 | |
79 | 79 | // Use the proper operator. |
80 | - if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
80 | + if ( ! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) { |
|
81 | 81 | $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']]; |
82 | 82 | } |
83 | - if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
83 | + if ( ! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) { |
|
84 | 84 | $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']]; |
85 | 85 | } |
86 | - if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
86 | + if ( ! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) { |
|
87 | 87 | $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']]; |
88 | 88 | } |
89 | 89 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | /** |
92 | 92 | * Merge the input_fields with the default query_args |
93 | 93 | */ |
94 | - if (! empty($input_fields)) { |
|
94 | + if ( ! empty($input_fields)) { |
|
95 | 95 | $where_params = array_merge($where_params, $input_fields); |
96 | 96 | } |
97 | 97 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $this->args |
103 | 103 | ); |
104 | 104 | |
105 | - if (! empty($where_params)) { |
|
105 | + if ( ! empty($where_params)) { |
|
106 | 106 | $query_args[] = $where_params; |
107 | 107 | } |
108 | 108 |
@@ -14,122 +14,122 @@ |
||
14 | 14 | */ |
15 | 15 | class FormElementConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - public function get_loader_name(): string |
|
19 | - { |
|
20 | - return 'espresso_formElement'; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @return EEM_Form_Input |
|
25 | - * @throws EE_Error |
|
26 | - * @throws InvalidArgumentException |
|
27 | - * @throws InvalidDataTypeException |
|
28 | - * @throws InvalidInterfaceException |
|
29 | - * @throws ReflectionException |
|
30 | - */ |
|
31 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | - public function get_query(): EEM_Form_Input |
|
33 | - { |
|
34 | - return EEM_Form_Input::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(): array |
|
45 | - { |
|
46 | - $results = $this->query->get_col($this->query_args); |
|
47 | - return ! empty($results) ? $results : []; |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
53 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
54 | - * handle batch resolution of the posts. |
|
55 | - * |
|
56 | - * @return array |
|
57 | - * @throws InvalidArgumentException |
|
58 | - * @throws InvalidDataTypeException |
|
59 | - * @throws InvalidInterfaceException |
|
60 | - */ |
|
61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | - public function get_query_args(): array |
|
63 | - { |
|
64 | - $where_params = []; |
|
65 | - $query_args = []; |
|
66 | - |
|
67 | - $query_args['limit'] = $this->getLimit(); |
|
68 | - |
|
69 | - // Avoid multiple entries by join. |
|
70 | - $query_args['group_by'] = 'FIN_UUID'; |
|
71 | - |
|
72 | - /** |
|
73 | - * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
74 | - */ |
|
75 | - $input_fields = []; |
|
76 | - if (! empty($this->args['where'])) { |
|
77 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
78 | - |
|
79 | - // Use the proper operator. |
|
80 | - if (! empty($input_fields['FIN_belongsTo']) && is_array($input_fields['FIN_belongsTo'])) { |
|
81 | - $input_fields['FIN_belongsTo'] = ['IN', $input_fields['FIN_belongsTo']]; |
|
82 | - } |
|
83 | - if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
84 | - $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Merge the input_fields with the default query_args |
|
90 | - */ |
|
91 | - if (! empty($input_fields)) { |
|
92 | - $where_params = array_merge($where_params, $input_fields); |
|
93 | - } |
|
94 | - |
|
95 | - $where_params = apply_filters( |
|
96 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_where_params', |
|
97 | - $where_params, |
|
98 | - $this->source, |
|
99 | - $this->args |
|
100 | - ); |
|
101 | - |
|
102 | - if (! empty($where_params)) { |
|
103 | - $query_args[] = $where_params; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Return the $query_args |
|
109 | - */ |
|
110 | - return apply_filters( |
|
111 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_query_args', |
|
112 | - $query_args, |
|
113 | - $this->source, |
|
114 | - $this->args |
|
115 | - ); |
|
116 | - } |
|
117 | - |
|
118 | - /** |
|
119 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
120 | - * friendly keys. |
|
121 | - * |
|
122 | - * @param array $where_args |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function sanitizeInputFields(array $where_args): array |
|
126 | - { |
|
127 | - return $this->sanitizeWhereArgsForInputFields( |
|
128 | - $where_args, |
|
129 | - [ |
|
130 | - 'belongsTo' => 'FIN_belongsTo', |
|
131 | - 'status' => 'FIN_status', |
|
132 | - ] |
|
133 | - ); |
|
134 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + public function get_loader_name(): string |
|
19 | + { |
|
20 | + return 'espresso_formElement'; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @return EEM_Form_Input |
|
25 | + * @throws EE_Error |
|
26 | + * @throws InvalidArgumentException |
|
27 | + * @throws InvalidDataTypeException |
|
28 | + * @throws InvalidInterfaceException |
|
29 | + * @throws ReflectionException |
|
30 | + */ |
|
31 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | + public function get_query(): EEM_Form_Input |
|
33 | + { |
|
34 | + return EEM_Form_Input::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(): array |
|
45 | + { |
|
46 | + $results = $this->query->get_col($this->query_args); |
|
47 | + return ! empty($results) ? $results : []; |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
53 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
54 | + * handle batch resolution of the posts. |
|
55 | + * |
|
56 | + * @return array |
|
57 | + * @throws InvalidArgumentException |
|
58 | + * @throws InvalidDataTypeException |
|
59 | + * @throws InvalidInterfaceException |
|
60 | + */ |
|
61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | + public function get_query_args(): array |
|
63 | + { |
|
64 | + $where_params = []; |
|
65 | + $query_args = []; |
|
66 | + |
|
67 | + $query_args['limit'] = $this->getLimit(); |
|
68 | + |
|
69 | + // Avoid multiple entries by join. |
|
70 | + $query_args['group_by'] = 'FIN_UUID'; |
|
71 | + |
|
72 | + /** |
|
73 | + * Collect the input fields and sanitize them to prepare them for sending to the Query |
|
74 | + */ |
|
75 | + $input_fields = []; |
|
76 | + if (! empty($this->args['where'])) { |
|
77 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
78 | + |
|
79 | + // Use the proper operator. |
|
80 | + if (! empty($input_fields['FIN_belongsTo']) && is_array($input_fields['FIN_belongsTo'])) { |
|
81 | + $input_fields['FIN_belongsTo'] = ['IN', $input_fields['FIN_belongsTo']]; |
|
82 | + } |
|
83 | + if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
84 | + $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Merge the input_fields with the default query_args |
|
90 | + */ |
|
91 | + if (! empty($input_fields)) { |
|
92 | + $where_params = array_merge($where_params, $input_fields); |
|
93 | + } |
|
94 | + |
|
95 | + $where_params = apply_filters( |
|
96 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_where_params', |
|
97 | + $where_params, |
|
98 | + $this->source, |
|
99 | + $this->args |
|
100 | + ); |
|
101 | + |
|
102 | + if (! empty($where_params)) { |
|
103 | + $query_args[] = $where_params; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Return the $query_args |
|
109 | + */ |
|
110 | + return apply_filters( |
|
111 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_element_query_args', |
|
112 | + $query_args, |
|
113 | + $this->source, |
|
114 | + $this->args |
|
115 | + ); |
|
116 | + } |
|
117 | + |
|
118 | + /** |
|
119 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
120 | + * friendly keys. |
|
121 | + * |
|
122 | + * @param array $where_args |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function sanitizeInputFields(array $where_args): array |
|
126 | + { |
|
127 | + return $this->sanitizeWhereArgsForInputFields( |
|
128 | + $where_args, |
|
129 | + [ |
|
130 | + 'belongsTo' => 'FIN_belongsTo', |
|
131 | + 'status' => 'FIN_status', |
|
132 | + ] |
|
133 | + ); |
|
134 | + } |
|
135 | 135 | } |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | * Collect the input fields and sanitize them to prepare them for sending to the Query |
74 | 74 | */ |
75 | 75 | $input_fields = []; |
76 | - if (! empty($this->args['where'])) { |
|
76 | + if ( ! empty($this->args['where'])) { |
|
77 | 77 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
78 | 78 | |
79 | 79 | // Use the proper operator. |
80 | - if (! empty($input_fields['FIN_belongsTo']) && is_array($input_fields['FIN_belongsTo'])) { |
|
80 | + if ( ! empty($input_fields['FIN_belongsTo']) && is_array($input_fields['FIN_belongsTo'])) { |
|
81 | 81 | $input_fields['FIN_belongsTo'] = ['IN', $input_fields['FIN_belongsTo']]; |
82 | 82 | } |
83 | - if (! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
83 | + if ( ! empty($input_fields['FIN_status']) && is_array($input_fields['FIN_status'])) { |
|
84 | 84 | $input_fields['FIN_status'] = ['IN', $input_fields['FIN_status']]; |
85 | 85 | } |
86 | 86 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * Merge the input_fields with the default query_args |
90 | 90 | */ |
91 | - if (! empty($input_fields)) { |
|
91 | + if ( ! empty($input_fields)) { |
|
92 | 92 | $where_params = array_merge($where_params, $input_fields); |
93 | 93 | } |
94 | 94 | |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | $this->args |
100 | 100 | ); |
101 | 101 | |
102 | - if (! empty($where_params)) { |
|
102 | + if ( ! empty($where_params)) { |
|
103 | 103 | $query_args[] = $where_params; |
104 | 104 | } |
105 | 105 |
@@ -16,177 +16,177 @@ |
||
16 | 16 | */ |
17 | 17 | class AttendeeConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - public function get_loader_name(): string |
|
21 | - { |
|
22 | - return 'espresso_attendee'; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return EEM_Attendee |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | - public function get_query(): EEM_Attendee |
|
35 | - { |
|
36 | - return EEM_Attendee::instance(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Return an array of item IDs from the query |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | - public function get_ids(): array |
|
47 | - { |
|
48 | - $results = $this->query->get_col($this->query_args); |
|
49 | - |
|
50 | - return ! empty($results) ? $results : []; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | - * handle batch resolution of the posts. |
|
58 | - * |
|
59 | - * @return array |
|
60 | - * @throws InvalidArgumentException |
|
61 | - * @throws InvalidDataTypeException |
|
62 | - * @throws InvalidInterfaceException |
|
63 | - */ |
|
64 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | - public function get_query_args(): array |
|
66 | - { |
|
67 | - $where_params = []; |
|
68 | - $query_args = []; |
|
69 | - |
|
70 | - $query_args['limit'] = $this->getLimit(); |
|
71 | - |
|
72 | - // Avoid multiple entries by join. |
|
73 | - $query_args['group_by'] = 'ATT_ID'; |
|
74 | - |
|
75 | - $query_args['default_where_conditions'] = 'minimum'; |
|
76 | - |
|
77 | - /** |
|
78 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
79 | - */ |
|
80 | - $input_fields = []; |
|
81 | - if (! empty($this->args['where'])) { |
|
82 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
83 | - |
|
84 | - // Since we do not have any falsy values in query params |
|
85 | - // Lets get rid of empty values |
|
86 | - $input_fields = array_filter($input_fields); |
|
87 | - |
|
88 | - // Use the proper operator. |
|
89 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
90 | - $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
|
91 | - } |
|
92 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
93 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
|
94 | - } |
|
95 | - // If Ticket param is passed, it will have preference over Datetime param |
|
96 | - // So, use Datetime param only if a Ticket param is not passed |
|
97 | - if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
98 | - $datetimeIds = $input_fields['Datetime.DTT_ID']; |
|
99 | - // Make sure it's an array, ready for "IN" operator |
|
100 | - $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
|
101 | - |
|
102 | - try { |
|
103 | - // Get related ticket IDs for the given dates |
|
104 | - $ticketIds = EEM_Ticket::instance()->get_col([ |
|
105 | - [ |
|
106 | - 'Datetime.DTT_ID' => ['IN', $datetimeIds], |
|
107 | - 'TKT_deleted' => ['IN', [true, false]], |
|
108 | - ], |
|
109 | - 'default_where_conditions' => 'minimum', |
|
110 | - ]); |
|
111 | - } catch (Throwable $th) { |
|
112 | - $ticketIds = []; |
|
113 | - } |
|
114 | - |
|
115 | - if (!empty($ticketIds)) { |
|
116 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
117 | - } |
|
118 | - } |
|
119 | - // Since there is no relation between Attendee and Datetime, we need to remove it |
|
120 | - unset($input_fields['Datetime.DTT_ID']); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Merge the input_fields with the default query_args |
|
125 | - */ |
|
126 | - if (! empty($input_fields)) { |
|
127 | - $where_params = array_merge($where_params, $input_fields); |
|
128 | - } |
|
129 | - |
|
130 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
131 | - |
|
132 | - $search = $this->getSearchKeywords($this->args['where']); |
|
133 | - |
|
134 | - if (! empty($search)) { |
|
135 | - // use OR operator to search in any of the fields |
|
136 | - $where_params['OR'] = array( |
|
137 | - 'ATT_full_name' => array('LIKE', '%' . $search . '%'), |
|
138 | - 'ATT_bio' => array('LIKE', '%' . $search . '%'), |
|
139 | - 'ATT_short_bio' => array('LIKE', '%' . $search . '%'), |
|
140 | - ); |
|
141 | - } |
|
142 | - |
|
143 | - $where_params = apply_filters( |
|
144 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_where_params', |
|
145 | - $where_params, |
|
146 | - $this->source, |
|
147 | - $this->args |
|
148 | - ); |
|
149 | - |
|
150 | - $query_args[] = $where_params; |
|
151 | - |
|
152 | - /** |
|
153 | - * Return the $query_args |
|
154 | - */ |
|
155 | - return apply_filters( |
|
156 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_query_args', |
|
157 | - $query_args, |
|
158 | - $this->source, |
|
159 | - $this->args |
|
160 | - ); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
166 | - * friendly keys. |
|
167 | - * |
|
168 | - * @param array $where_args |
|
169 | - * @return array |
|
170 | - */ |
|
171 | - public function sanitizeInputFields(array $where_args): array |
|
172 | - { |
|
173 | - $arg_mapping = [ |
|
174 | - // There is no direct relation between Attendee and Datetime |
|
175 | - // But we will handle it via Tickets related to given dates |
|
176 | - 'datetime' => 'Datetime.DTT_ID', |
|
177 | - 'datetimeIn' => 'Datetime.DTT_ID', |
|
178 | - 'event' => 'Registration.Event.EVT_ID', |
|
179 | - 'eventIn' => 'Registration.Event.EVT_ID', |
|
180 | - 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
181 | - 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
182 | - 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
183 | - 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
184 | - 'regStatus' => 'Registration.Status.STS_ID', |
|
185 | - ]; |
|
186 | - return $this->sanitizeWhereArgsForInputFields( |
|
187 | - $where_args, |
|
188 | - $arg_mapping, |
|
189 | - ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
190 | - ); |
|
191 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + public function get_loader_name(): string |
|
21 | + { |
|
22 | + return 'espresso_attendee'; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return EEM_Attendee |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | + public function get_query(): EEM_Attendee |
|
35 | + { |
|
36 | + return EEM_Attendee::instance(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Return an array of item IDs from the query |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | + public function get_ids(): array |
|
47 | + { |
|
48 | + $results = $this->query->get_col($this->query_args); |
|
49 | + |
|
50 | + return ! empty($results) ? $results : []; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | + * handle batch resolution of the posts. |
|
58 | + * |
|
59 | + * @return array |
|
60 | + * @throws InvalidArgumentException |
|
61 | + * @throws InvalidDataTypeException |
|
62 | + * @throws InvalidInterfaceException |
|
63 | + */ |
|
64 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
65 | + public function get_query_args(): array |
|
66 | + { |
|
67 | + $where_params = []; |
|
68 | + $query_args = []; |
|
69 | + |
|
70 | + $query_args['limit'] = $this->getLimit(); |
|
71 | + |
|
72 | + // Avoid multiple entries by join. |
|
73 | + $query_args['group_by'] = 'ATT_ID'; |
|
74 | + |
|
75 | + $query_args['default_where_conditions'] = 'minimum'; |
|
76 | + |
|
77 | + /** |
|
78 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
79 | + */ |
|
80 | + $input_fields = []; |
|
81 | + if (! empty($this->args['where'])) { |
|
82 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
83 | + |
|
84 | + // Since we do not have any falsy values in query params |
|
85 | + // Lets get rid of empty values |
|
86 | + $input_fields = array_filter($input_fields); |
|
87 | + |
|
88 | + // Use the proper operator. |
|
89 | + if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
90 | + $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
|
91 | + } |
|
92 | + if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
93 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
|
94 | + } |
|
95 | + // If Ticket param is passed, it will have preference over Datetime param |
|
96 | + // So, use Datetime param only if a Ticket param is not passed |
|
97 | + if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
98 | + $datetimeIds = $input_fields['Datetime.DTT_ID']; |
|
99 | + // Make sure it's an array, ready for "IN" operator |
|
100 | + $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
|
101 | + |
|
102 | + try { |
|
103 | + // Get related ticket IDs for the given dates |
|
104 | + $ticketIds = EEM_Ticket::instance()->get_col([ |
|
105 | + [ |
|
106 | + 'Datetime.DTT_ID' => ['IN', $datetimeIds], |
|
107 | + 'TKT_deleted' => ['IN', [true, false]], |
|
108 | + ], |
|
109 | + 'default_where_conditions' => 'minimum', |
|
110 | + ]); |
|
111 | + } catch (Throwable $th) { |
|
112 | + $ticketIds = []; |
|
113 | + } |
|
114 | + |
|
115 | + if (!empty($ticketIds)) { |
|
116 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
117 | + } |
|
118 | + } |
|
119 | + // Since there is no relation between Attendee and Datetime, we need to remove it |
|
120 | + unset($input_fields['Datetime.DTT_ID']); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Merge the input_fields with the default query_args |
|
125 | + */ |
|
126 | + if (! empty($input_fields)) { |
|
127 | + $where_params = array_merge($where_params, $input_fields); |
|
128 | + } |
|
129 | + |
|
130 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
131 | + |
|
132 | + $search = $this->getSearchKeywords($this->args['where']); |
|
133 | + |
|
134 | + if (! empty($search)) { |
|
135 | + // use OR operator to search in any of the fields |
|
136 | + $where_params['OR'] = array( |
|
137 | + 'ATT_full_name' => array('LIKE', '%' . $search . '%'), |
|
138 | + 'ATT_bio' => array('LIKE', '%' . $search . '%'), |
|
139 | + 'ATT_short_bio' => array('LIKE', '%' . $search . '%'), |
|
140 | + ); |
|
141 | + } |
|
142 | + |
|
143 | + $where_params = apply_filters( |
|
144 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_where_params', |
|
145 | + $where_params, |
|
146 | + $this->source, |
|
147 | + $this->args |
|
148 | + ); |
|
149 | + |
|
150 | + $query_args[] = $where_params; |
|
151 | + |
|
152 | + /** |
|
153 | + * Return the $query_args |
|
154 | + */ |
|
155 | + return apply_filters( |
|
156 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__attendee_query_args', |
|
157 | + $query_args, |
|
158 | + $this->source, |
|
159 | + $this->args |
|
160 | + ); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
166 | + * friendly keys. |
|
167 | + * |
|
168 | + * @param array $where_args |
|
169 | + * @return array |
|
170 | + */ |
|
171 | + public function sanitizeInputFields(array $where_args): array |
|
172 | + { |
|
173 | + $arg_mapping = [ |
|
174 | + // There is no direct relation between Attendee and Datetime |
|
175 | + // But we will handle it via Tickets related to given dates |
|
176 | + 'datetime' => 'Datetime.DTT_ID', |
|
177 | + 'datetimeIn' => 'Datetime.DTT_ID', |
|
178 | + 'event' => 'Registration.Event.EVT_ID', |
|
179 | + 'eventIn' => 'Registration.Event.EVT_ID', |
|
180 | + 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
181 | + 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
182 | + 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
183 | + 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
184 | + 'regStatus' => 'Registration.Status.STS_ID', |
|
185 | + ]; |
|
186 | + return $this->sanitizeWhereArgsForInputFields( |
|
187 | + $where_args, |
|
188 | + $arg_mapping, |
|
189 | + ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
190 | + ); |
|
191 | + } |
|
192 | 192 | } |
@@ -17,219 +17,219 @@ |
||
17 | 17 | */ |
18 | 18 | class PriceConnectionResolver extends AbstractConnectionResolver |
19 | 19 | { |
20 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
21 | - public function get_loader_name(): string |
|
22 | - { |
|
23 | - return 'espresso_price'; |
|
24 | - } |
|
25 | - |
|
26 | - /** |
|
27 | - * @return EEM_Price |
|
28 | - * @throws EE_Error |
|
29 | - * @throws InvalidArgumentException |
|
30 | - * @throws InvalidDataTypeException |
|
31 | - * @throws InvalidInterfaceException |
|
32 | - * @throws ReflectionException |
|
33 | - */ |
|
34 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | - public function get_query(): EEM_Price |
|
36 | - { |
|
37 | - return EEM_Price::instance(); |
|
38 | - } |
|
39 | - |
|
40 | - |
|
41 | - /** |
|
42 | - * Return an array of item IDs from the query |
|
43 | - * |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | - public function get_ids(): array |
|
48 | - { |
|
49 | - $results = $this->query->get_col($this->query_args); |
|
50 | - |
|
51 | - return ! empty($results) ? $results : []; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
57 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
58 | - * handle batch resolution of the posts. |
|
59 | - * |
|
60 | - * @return array |
|
61 | - * @throws EE_Error |
|
62 | - * @throws InvalidArgumentException |
|
63 | - * @throws ReflectionException |
|
64 | - * @throws InvalidDataTypeException |
|
65 | - * @throws InvalidInterfaceException |
|
66 | - */ |
|
67 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | - public function get_query_args(): array |
|
69 | - { |
|
70 | - $where_params = []; |
|
71 | - $query_args = []; |
|
72 | - |
|
73 | - $query_args['limit'] = $this->getLimit(); |
|
74 | - |
|
75 | - // Avoid multiple entries by join. |
|
76 | - $query_args['group_by'] = 'PRC_ID'; |
|
77 | - |
|
78 | - $query_args['default_where_conditions'] = 'minimum'; |
|
79 | - |
|
80 | - /** |
|
81 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
82 | - */ |
|
83 | - $input_fields = []; |
|
84 | - if (! empty($this->args['where'])) { |
|
85 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
86 | - |
|
87 | - // Use the proper operator. |
|
88 | - if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
89 | - $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
90 | - } |
|
91 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
92 | - $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
93 | - } |
|
94 | - if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
95 | - $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
96 | - } |
|
97 | - if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
98 | - $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
99 | - } |
|
100 | - // if event ID is passed but not a ticket ID |
|
101 | - if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
102 | - $event_id = $input_fields['Event.EVT_ID']; |
|
103 | - // Ensure that this doesn't go to the query. |
|
104 | - // After all there is no DB relation between event and price |
|
105 | - unset($input_fields['Event.EVT_ID']); |
|
106 | - // get all the datetimeIds of the event |
|
107 | - $event_datetime_ids = EEM_Datetime::instance()->get_col([ |
|
108 | - [ |
|
109 | - 'EVT_ID' => $event_id, |
|
110 | - ], |
|
111 | - 'default_where_conditions' => 'minimum' |
|
112 | - ]); |
|
113 | - // get all the related ticket Ids |
|
114 | - $ticket_ids = EEM_Ticket::instance()->get_col([ |
|
115 | - [ |
|
116 | - 'Datetime.DTT_ID' => ['IN', $event_datetime_ids], |
|
117 | - ], |
|
118 | - 'default_where_conditions' => 'minimum' |
|
119 | - ]); |
|
120 | - |
|
121 | - // add tickets relation to the query |
|
122 | - $input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids]; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
128 | - */ |
|
129 | - if ($this->source instanceof EE_Ticket) { |
|
130 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Merge the input_fields with the default query_args |
|
135 | - */ |
|
136 | - if (! empty($input_fields)) { |
|
137 | - $where_params = array_merge($where_params, $input_fields); |
|
138 | - } |
|
139 | - |
|
140 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
141 | - |
|
142 | - $default_prices_params = []; |
|
143 | - |
|
144 | - // If default ticket prices should be included. |
|
145 | - if (! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
146 | - $default_ticket_ids = EEM_Ticket::instance()->get_col([ |
|
147 | - [ |
|
148 | - 'TKT_is_default' => 1, |
|
149 | - ], |
|
150 | - 'default_where_conditions' => 'minimum' |
|
151 | - ]); |
|
152 | - |
|
153 | - // if we have default tickets |
|
154 | - if (! empty($default_ticket_ids)) { |
|
155 | - $default_prices_params['OR'] = [ |
|
156 | - 'Ticket.TKT_ID' => ['IN', $default_ticket_ids], |
|
157 | - ]; |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - // If default prices should be included. |
|
162 | - if (! empty($this->args['where']['includeDefaultPrices'])) { |
|
163 | - $default_prices_params['AND'] = [ |
|
164 | - 'PRC_deleted' => 0, |
|
165 | - 'PRC_is_default' => 1, |
|
166 | - ]; |
|
167 | - } |
|
168 | - |
|
169 | - if (! empty($default_prices_params)) { |
|
170 | - if (empty($where_params)) { |
|
171 | - $where_params['OR'] = $default_prices_params; |
|
172 | - } else { |
|
173 | - $where_params = [ |
|
174 | - 'OR' => [ |
|
175 | - 'OR' => $default_prices_params, |
|
176 | - 'AND' => $where_params, |
|
177 | - ], |
|
178 | - ]; |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - $where_params = apply_filters( |
|
183 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params', |
|
184 | - $where_params, |
|
185 | - $this->source, |
|
186 | - $this->args |
|
187 | - ); |
|
188 | - |
|
189 | - $query_args[] = $where_params; |
|
190 | - |
|
191 | - /** |
|
192 | - * Return the $query_args |
|
193 | - */ |
|
194 | - return apply_filters( |
|
195 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args', |
|
196 | - $query_args, |
|
197 | - $this->source, |
|
198 | - $this->args |
|
199 | - ); |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - /** |
|
204 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
205 | - * friendly keys. |
|
206 | - * |
|
207 | - * @param array $where_args |
|
208 | - * @return array |
|
209 | - */ |
|
210 | - public function sanitizeInputFields(array $where_args): array |
|
211 | - { |
|
212 | - $arg_mapping = [ |
|
213 | - 'in' => 'PRC_ID', |
|
214 | - 'idIn' => 'PRC_ID', |
|
215 | - 'isDefault' => 'PRC_is_default', |
|
216 | - 'event' => 'Event.EVT_ID', |
|
217 | - 'eventId' => 'Event.EVT_ID', // priority. |
|
218 | - 'ticket' => 'Ticket.TKT_ID', |
|
219 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
220 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
221 | - 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
222 | - 'priceType' => 'Price_Type.PRT_ID', |
|
223 | - 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
224 | - 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
225 | - 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
226 | - 'priceBaseType' => 'Price_Type.PBT_ID', |
|
227 | - 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
228 | - ]; |
|
229 | - return $this->sanitizeWhereArgsForInputFields( |
|
230 | - $where_args, |
|
231 | - $arg_mapping, |
|
232 | - ['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
233 | - ); |
|
234 | - } |
|
20 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
21 | + public function get_loader_name(): string |
|
22 | + { |
|
23 | + return 'espresso_price'; |
|
24 | + } |
|
25 | + |
|
26 | + /** |
|
27 | + * @return EEM_Price |
|
28 | + * @throws EE_Error |
|
29 | + * @throws InvalidArgumentException |
|
30 | + * @throws InvalidDataTypeException |
|
31 | + * @throws InvalidInterfaceException |
|
32 | + * @throws ReflectionException |
|
33 | + */ |
|
34 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
35 | + public function get_query(): EEM_Price |
|
36 | + { |
|
37 | + return EEM_Price::instance(); |
|
38 | + } |
|
39 | + |
|
40 | + |
|
41 | + /** |
|
42 | + * Return an array of item IDs from the query |
|
43 | + * |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
47 | + public function get_ids(): array |
|
48 | + { |
|
49 | + $results = $this->query->get_col($this->query_args); |
|
50 | + |
|
51 | + return ! empty($results) ? $results : []; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
57 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
58 | + * handle batch resolution of the posts. |
|
59 | + * |
|
60 | + * @return array |
|
61 | + * @throws EE_Error |
|
62 | + * @throws InvalidArgumentException |
|
63 | + * @throws ReflectionException |
|
64 | + * @throws InvalidDataTypeException |
|
65 | + * @throws InvalidInterfaceException |
|
66 | + */ |
|
67 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | + public function get_query_args(): array |
|
69 | + { |
|
70 | + $where_params = []; |
|
71 | + $query_args = []; |
|
72 | + |
|
73 | + $query_args['limit'] = $this->getLimit(); |
|
74 | + |
|
75 | + // Avoid multiple entries by join. |
|
76 | + $query_args['group_by'] = 'PRC_ID'; |
|
77 | + |
|
78 | + $query_args['default_where_conditions'] = 'minimum'; |
|
79 | + |
|
80 | + /** |
|
81 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
82 | + */ |
|
83 | + $input_fields = []; |
|
84 | + if (! empty($this->args['where'])) { |
|
85 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
86 | + |
|
87 | + // Use the proper operator. |
|
88 | + if (! empty($input_fields['PRC_ID']) && is_array($input_fields['PRC_ID'])) { |
|
89 | + $input_fields['PRC_ID'] = ['in', $input_fields['PRC_ID']]; |
|
90 | + } |
|
91 | + if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
92 | + $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
|
93 | + } |
|
94 | + if (! empty($input_fields['Price_Type.PBT_ID']) && is_array($input_fields['Price_Type.PBT_ID'])) { |
|
95 | + $input_fields['Price_Type.PBT_ID'] = ['in', $input_fields['Price_Type.PBT_ID']]; |
|
96 | + } |
|
97 | + if (! empty($input_fields['Price_Type.PRT_ID']) && is_array($input_fields['Price_Type.PRT_ID'])) { |
|
98 | + $input_fields['Price_Type.PRT_ID'] = ['in', $input_fields['Price_Type.PRT_ID']]; |
|
99 | + } |
|
100 | + // if event ID is passed but not a ticket ID |
|
101 | + if (! isset($input_fields['Ticket.TKT_ID']) && isset($input_fields['Event.EVT_ID'])) { |
|
102 | + $event_id = $input_fields['Event.EVT_ID']; |
|
103 | + // Ensure that this doesn't go to the query. |
|
104 | + // After all there is no DB relation between event and price |
|
105 | + unset($input_fields['Event.EVT_ID']); |
|
106 | + // get all the datetimeIds of the event |
|
107 | + $event_datetime_ids = EEM_Datetime::instance()->get_col([ |
|
108 | + [ |
|
109 | + 'EVT_ID' => $event_id, |
|
110 | + ], |
|
111 | + 'default_where_conditions' => 'minimum' |
|
112 | + ]); |
|
113 | + // get all the related ticket Ids |
|
114 | + $ticket_ids = EEM_Ticket::instance()->get_col([ |
|
115 | + [ |
|
116 | + 'Datetime.DTT_ID' => ['IN', $event_datetime_ids], |
|
117 | + ], |
|
118 | + 'default_where_conditions' => 'minimum' |
|
119 | + ]); |
|
120 | + |
|
121 | + // add tickets relation to the query |
|
122 | + $input_fields['Ticket.TKT_ID'] = ['IN', $ticket_ids]; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
128 | + */ |
|
129 | + if ($this->source instanceof EE_Ticket) { |
|
130 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Merge the input_fields with the default query_args |
|
135 | + */ |
|
136 | + if (! empty($input_fields)) { |
|
137 | + $where_params = array_merge($where_params, $input_fields); |
|
138 | + } |
|
139 | + |
|
140 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'PRC_ID'); |
|
141 | + |
|
142 | + $default_prices_params = []; |
|
143 | + |
|
144 | + // If default ticket prices should be included. |
|
145 | + if (! empty($this->args['where']['includeDefaultTicketsPrices'])) { |
|
146 | + $default_ticket_ids = EEM_Ticket::instance()->get_col([ |
|
147 | + [ |
|
148 | + 'TKT_is_default' => 1, |
|
149 | + ], |
|
150 | + 'default_where_conditions' => 'minimum' |
|
151 | + ]); |
|
152 | + |
|
153 | + // if we have default tickets |
|
154 | + if (! empty($default_ticket_ids)) { |
|
155 | + $default_prices_params['OR'] = [ |
|
156 | + 'Ticket.TKT_ID' => ['IN', $default_ticket_ids], |
|
157 | + ]; |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + // If default prices should be included. |
|
162 | + if (! empty($this->args['where']['includeDefaultPrices'])) { |
|
163 | + $default_prices_params['AND'] = [ |
|
164 | + 'PRC_deleted' => 0, |
|
165 | + 'PRC_is_default' => 1, |
|
166 | + ]; |
|
167 | + } |
|
168 | + |
|
169 | + if (! empty($default_prices_params)) { |
|
170 | + if (empty($where_params)) { |
|
171 | + $where_params['OR'] = $default_prices_params; |
|
172 | + } else { |
|
173 | + $where_params = [ |
|
174 | + 'OR' => [ |
|
175 | + 'OR' => $default_prices_params, |
|
176 | + 'AND' => $where_params, |
|
177 | + ], |
|
178 | + ]; |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + $where_params = apply_filters( |
|
183 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_where_params', |
|
184 | + $where_params, |
|
185 | + $this->source, |
|
186 | + $this->args |
|
187 | + ); |
|
188 | + |
|
189 | + $query_args[] = $where_params; |
|
190 | + |
|
191 | + /** |
|
192 | + * Return the $query_args |
|
193 | + */ |
|
194 | + return apply_filters( |
|
195 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__price_query_args', |
|
196 | + $query_args, |
|
197 | + $this->source, |
|
198 | + $this->args |
|
199 | + ); |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + /** |
|
204 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
205 | + * friendly keys. |
|
206 | + * |
|
207 | + * @param array $where_args |
|
208 | + * @return array |
|
209 | + */ |
|
210 | + public function sanitizeInputFields(array $where_args): array |
|
211 | + { |
|
212 | + $arg_mapping = [ |
|
213 | + 'in' => 'PRC_ID', |
|
214 | + 'idIn' => 'PRC_ID', |
|
215 | + 'isDefault' => 'PRC_is_default', |
|
216 | + 'event' => 'Event.EVT_ID', |
|
217 | + 'eventId' => 'Event.EVT_ID', // priority. |
|
218 | + 'ticket' => 'Ticket.TKT_ID', |
|
219 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
220 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
221 | + 'ticketId' => 'Ticket.TKT_ID', // priority. |
|
222 | + 'priceType' => 'Price_Type.PRT_ID', |
|
223 | + 'priceTypeIn' => 'Price_Type.PRT_ID', |
|
224 | + 'priceTypeIdIn' => 'Price_Type.PRT_ID', |
|
225 | + 'priceTypeId' => 'Price_Type.PRT_ID', // priority. |
|
226 | + 'priceBaseType' => 'Price_Type.PBT_ID', |
|
227 | + 'priceBaseTypeIn' => 'Price_Type.PBT_ID', |
|
228 | + ]; |
|
229 | + return $this->sanitizeWhereArgsForInputFields( |
|
230 | + $where_args, |
|
231 | + $arg_mapping, |
|
232 | + ['in', 'event', 'ticket', 'ticketIn', 'priceType', 'priceTypeIn'] |
|
233 | + ); |
|
234 | + } |
|
235 | 235 | } |
@@ -15,178 +15,178 @@ |
||
15 | 15 | */ |
16 | 16 | class TicketConnectionResolver extends AbstractConnectionResolver |
17 | 17 | { |
18 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
19 | - public function get_loader_name(): string |
|
20 | - { |
|
21 | - return 'espresso_ticket'; |
|
22 | - } |
|
23 | - |
|
24 | - /** |
|
25 | - * @return EEM_Ticket |
|
26 | - * @throws EE_Error |
|
27 | - * @throws InvalidArgumentException |
|
28 | - * @throws InvalidDataTypeException |
|
29 | - * @throws InvalidInterfaceException |
|
30 | - * @throws ReflectionException |
|
31 | - */ |
|
32 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
33 | - public function get_query(): EEM_Ticket |
|
34 | - { |
|
35 | - return EEM_Ticket::instance(); |
|
36 | - } |
|
37 | - |
|
38 | - |
|
39 | - /** |
|
40 | - * Return an array of item IDs from the query |
|
41 | - * |
|
42 | - * @return array |
|
43 | - */ |
|
44 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
45 | - public function get_ids(): array |
|
46 | - { |
|
47 | - $results = $this->query->get_col($this->query_args); |
|
48 | - |
|
49 | - return ! empty($results) ? $results : []; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
55 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
56 | - * handle batch resolution of the posts. |
|
57 | - * |
|
58 | - * @return array |
|
59 | - * @throws EE_Error |
|
60 | - * @throws InvalidArgumentException |
|
61 | - * @throws ReflectionException |
|
62 | - * @throws InvalidDataTypeException |
|
63 | - * @throws InvalidInterfaceException |
|
64 | - */ |
|
65 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
66 | - public function get_query_args(): array |
|
67 | - { |
|
68 | - $where_params = ['TKT_deleted' => ['IN', [true, false]]]; |
|
69 | - $query_args = []; |
|
70 | - |
|
71 | - $query_args['limit'] = $this->getLimit(); |
|
72 | - |
|
73 | - // Avoid multiple entries by join. |
|
74 | - $query_args['group_by'] = 'TKT_ID'; |
|
75 | - |
|
76 | - $query_args['default_where_conditions'] = 'minimum'; |
|
77 | - |
|
78 | - /** |
|
79 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
80 | - */ |
|
81 | - $input_fields = []; |
|
82 | - if (! empty($this->args['where'])) { |
|
83 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
84 | - |
|
85 | - // Use the proper operator. |
|
86 | - if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
87 | - $input_fields['Datetime.DTT_ID'] = ['IN', $input_fields['Datetime.DTT_ID']]; |
|
88 | - } |
|
89 | - if (! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) { |
|
90 | - $input_fields['Datetime.EVT_ID'] = ['IN', $input_fields['Datetime.EVT_ID']]; |
|
91 | - } |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
96 | - */ |
|
97 | - if ($this->source instanceof EE_Datetime) { |
|
98 | - $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Merge the input_fields with the default query_args |
|
103 | - */ |
|
104 | - if (! empty($input_fields)) { |
|
105 | - $where_params = array_merge($where_params, $input_fields); |
|
106 | - } |
|
107 | - |
|
108 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); |
|
109 | - |
|
110 | - $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; |
|
111 | - |
|
112 | - if (! empty($search)) { |
|
113 | - // use OR operator to search in any of the fields |
|
114 | - $where_params['OR'] = array( |
|
115 | - 'TKT_name' => array('LIKE', '%' . $search . '%'), |
|
116 | - 'TKT_description' => array('LIKE', '%' . $search . '%'), |
|
117 | - ); |
|
118 | - } |
|
119 | - |
|
120 | - // If default tickets should be included. |
|
121 | - if (! empty($this->args['where']['includeDefaultTickets'])) { |
|
122 | - /** |
|
123 | - * We need to get each ticket that |
|
124 | - * - satisfies $where_params above |
|
125 | - * OR |
|
126 | - * - it's a default ticket |
|
127 | - */ |
|
128 | - $where_params = [ |
|
129 | - 'OR' => [ |
|
130 | - // use extra OR instead of AND to avoid it getting overridden |
|
131 | - 'OR' => [ |
|
132 | - 'AND' => [ |
|
133 | - 'TKT_deleted' => ['IN', [true, false]], |
|
134 | - 'TKT_is_default' => 1, |
|
135 | - ] |
|
136 | - ], |
|
137 | - 'AND' => $where_params, |
|
138 | - ], |
|
139 | - ]; |
|
140 | - } |
|
141 | - |
|
142 | - $where_params = apply_filters( |
|
143 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params', |
|
144 | - $where_params, |
|
145 | - $this->source, |
|
146 | - $this->args |
|
147 | - ); |
|
148 | - |
|
149 | - $query_args[] = $where_params; |
|
150 | - |
|
151 | - /** |
|
152 | - * Return the $query_args |
|
153 | - */ |
|
154 | - return apply_filters( |
|
155 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args', |
|
156 | - $query_args, |
|
157 | - $this->source, |
|
158 | - $this->args |
|
159 | - ); |
|
160 | - } |
|
161 | - |
|
162 | - |
|
163 | - /** |
|
164 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
165 | - * friendly keys. |
|
166 | - * |
|
167 | - * @param array $where_args |
|
168 | - * @return array |
|
169 | - */ |
|
170 | - public function sanitizeInputFields(array $where_args): array |
|
171 | - { |
|
172 | - $arg_mapping = [ |
|
173 | - 'event' => 'Datetime.EVT_ID', |
|
174 | - 'eventIn' => 'Datetime.EVT_ID', |
|
175 | - 'eventIdIn' => 'Datetime.EVT_ID', |
|
176 | - 'eventId' => 'Datetime.EVT_ID', // priority. |
|
177 | - 'datetime' => 'Datetime.DTT_ID', |
|
178 | - 'datetimeIn' => 'Datetime.DTT_ID', |
|
179 | - 'datetimeIdIn' => 'Datetime.DTT_ID', |
|
180 | - 'datetimeId' => 'Datetime.DTT_ID', // priority. |
|
181 | - 'isDefault' => 'TKT_is_default', |
|
182 | - 'isRequired' => 'TKT_required', |
|
183 | - 'isTaxable' => 'TKT_taxable', |
|
184 | - 'isTrashed' => 'TKT_deleted', |
|
185 | - ]; |
|
186 | - return $this->sanitizeWhereArgsForInputFields( |
|
187 | - $where_args, |
|
188 | - $arg_mapping, |
|
189 | - ['datetime', 'datetimeIn', 'event', 'eventIn'] |
|
190 | - ); |
|
191 | - } |
|
18 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
19 | + public function get_loader_name(): string |
|
20 | + { |
|
21 | + return 'espresso_ticket'; |
|
22 | + } |
|
23 | + |
|
24 | + /** |
|
25 | + * @return EEM_Ticket |
|
26 | + * @throws EE_Error |
|
27 | + * @throws InvalidArgumentException |
|
28 | + * @throws InvalidDataTypeException |
|
29 | + * @throws InvalidInterfaceException |
|
30 | + * @throws ReflectionException |
|
31 | + */ |
|
32 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
33 | + public function get_query(): EEM_Ticket |
|
34 | + { |
|
35 | + return EEM_Ticket::instance(); |
|
36 | + } |
|
37 | + |
|
38 | + |
|
39 | + /** |
|
40 | + * Return an array of item IDs from the query |
|
41 | + * |
|
42 | + * @return array |
|
43 | + */ |
|
44 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
45 | + public function get_ids(): array |
|
46 | + { |
|
47 | + $results = $this->query->get_col($this->query_args); |
|
48 | + |
|
49 | + return ! empty($results) ? $results : []; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
55 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
56 | + * handle batch resolution of the posts. |
|
57 | + * |
|
58 | + * @return array |
|
59 | + * @throws EE_Error |
|
60 | + * @throws InvalidArgumentException |
|
61 | + * @throws ReflectionException |
|
62 | + * @throws InvalidDataTypeException |
|
63 | + * @throws InvalidInterfaceException |
|
64 | + */ |
|
65 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
66 | + public function get_query_args(): array |
|
67 | + { |
|
68 | + $where_params = ['TKT_deleted' => ['IN', [true, false]]]; |
|
69 | + $query_args = []; |
|
70 | + |
|
71 | + $query_args['limit'] = $this->getLimit(); |
|
72 | + |
|
73 | + // Avoid multiple entries by join. |
|
74 | + $query_args['group_by'] = 'TKT_ID'; |
|
75 | + |
|
76 | + $query_args['default_where_conditions'] = 'minimum'; |
|
77 | + |
|
78 | + /** |
|
79 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
80 | + */ |
|
81 | + $input_fields = []; |
|
82 | + if (! empty($this->args['where'])) { |
|
83 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
84 | + |
|
85 | + // Use the proper operator. |
|
86 | + if (! empty($input_fields['Datetime.DTT_ID']) && is_array($input_fields['Datetime.DTT_ID'])) { |
|
87 | + $input_fields['Datetime.DTT_ID'] = ['IN', $input_fields['Datetime.DTT_ID']]; |
|
88 | + } |
|
89 | + if (! empty($input_fields['Datetime.EVT_ID']) && is_array($input_fields['Datetime.EVT_ID'])) { |
|
90 | + $input_fields['Datetime.EVT_ID'] = ['IN', $input_fields['Datetime.EVT_ID']]; |
|
91 | + } |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
96 | + */ |
|
97 | + if ($this->source instanceof EE_Datetime) { |
|
98 | + $where_params['Datetime.DTT_ID'] = $this->source->ID(); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Merge the input_fields with the default query_args |
|
103 | + */ |
|
104 | + if (! empty($input_fields)) { |
|
105 | + $where_params = array_merge($where_params, $input_fields); |
|
106 | + } |
|
107 | + |
|
108 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'TKT_ID'); |
|
109 | + |
|
110 | + $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; |
|
111 | + |
|
112 | + if (! empty($search)) { |
|
113 | + // use OR operator to search in any of the fields |
|
114 | + $where_params['OR'] = array( |
|
115 | + 'TKT_name' => array('LIKE', '%' . $search . '%'), |
|
116 | + 'TKT_description' => array('LIKE', '%' . $search . '%'), |
|
117 | + ); |
|
118 | + } |
|
119 | + |
|
120 | + // If default tickets should be included. |
|
121 | + if (! empty($this->args['where']['includeDefaultTickets'])) { |
|
122 | + /** |
|
123 | + * We need to get each ticket that |
|
124 | + * - satisfies $where_params above |
|
125 | + * OR |
|
126 | + * - it's a default ticket |
|
127 | + */ |
|
128 | + $where_params = [ |
|
129 | + 'OR' => [ |
|
130 | + // use extra OR instead of AND to avoid it getting overridden |
|
131 | + 'OR' => [ |
|
132 | + 'AND' => [ |
|
133 | + 'TKT_deleted' => ['IN', [true, false]], |
|
134 | + 'TKT_is_default' => 1, |
|
135 | + ] |
|
136 | + ], |
|
137 | + 'AND' => $where_params, |
|
138 | + ], |
|
139 | + ]; |
|
140 | + } |
|
141 | + |
|
142 | + $where_params = apply_filters( |
|
143 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_where_params', |
|
144 | + $where_params, |
|
145 | + $this->source, |
|
146 | + $this->args |
|
147 | + ); |
|
148 | + |
|
149 | + $query_args[] = $where_params; |
|
150 | + |
|
151 | + /** |
|
152 | + * Return the $query_args |
|
153 | + */ |
|
154 | + return apply_filters( |
|
155 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__ticket_query_args', |
|
156 | + $query_args, |
|
157 | + $this->source, |
|
158 | + $this->args |
|
159 | + ); |
|
160 | + } |
|
161 | + |
|
162 | + |
|
163 | + /** |
|
164 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
165 | + * friendly keys. |
|
166 | + * |
|
167 | + * @param array $where_args |
|
168 | + * @return array |
|
169 | + */ |
|
170 | + public function sanitizeInputFields(array $where_args): array |
|
171 | + { |
|
172 | + $arg_mapping = [ |
|
173 | + 'event' => 'Datetime.EVT_ID', |
|
174 | + 'eventIn' => 'Datetime.EVT_ID', |
|
175 | + 'eventIdIn' => 'Datetime.EVT_ID', |
|
176 | + 'eventId' => 'Datetime.EVT_ID', // priority. |
|
177 | + 'datetime' => 'Datetime.DTT_ID', |
|
178 | + 'datetimeIn' => 'Datetime.DTT_ID', |
|
179 | + 'datetimeIdIn' => 'Datetime.DTT_ID', |
|
180 | + 'datetimeId' => 'Datetime.DTT_ID', // priority. |
|
181 | + 'isDefault' => 'TKT_is_default', |
|
182 | + 'isRequired' => 'TKT_required', |
|
183 | + 'isTaxable' => 'TKT_taxable', |
|
184 | + 'isTrashed' => 'TKT_deleted', |
|
185 | + ]; |
|
186 | + return $this->sanitizeWhereArgsForInputFields( |
|
187 | + $where_args, |
|
188 | + $arg_mapping, |
|
189 | + ['datetime', 'datetimeIn', 'event', 'eventIn'] |
|
190 | + ); |
|
191 | + } |
|
192 | 192 | } |
@@ -20,172 +20,172 @@ |
||
20 | 20 | { |
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @var Utilities |
|
25 | - */ |
|
26 | - private $utilities; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @return Utilities |
|
31 | - */ |
|
32 | - public function getUtilities(): Utilities |
|
33 | - { |
|
34 | - if (! $this->utilities instanceof Utilities) { |
|
35 | - $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); |
|
36 | - } |
|
37 | - return $this->utilities; |
|
38 | - } |
|
39 | - |
|
40 | - /** |
|
41 | - * Determine whether the Query should execute. If it's determined that the query should |
|
42 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
43 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
44 | - * Return false to prevent the query from executing. |
|
45 | - * |
|
46 | - * @return bool |
|
47 | - */ |
|
48 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
49 | - public function should_execute(): bool |
|
50 | - { |
|
51 | - return $this->should_execute; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * Set limit the highest value of first and last, with a (filterable) max of 100 |
|
57 | - * |
|
58 | - * @return int |
|
59 | - */ |
|
60 | - protected function getLimit(): int |
|
61 | - { |
|
62 | - $first = ! empty($this->args['first']) |
|
63 | - ? absint($this->args['first']) |
|
64 | - : null; |
|
65 | - $last = ! empty($this->args['last']) |
|
66 | - ? absint($this->args['last']) |
|
67 | - : null; |
|
68 | - |
|
69 | - $limit = min( |
|
70 | - max($first, $last, 100), |
|
71 | - $this->query_amount |
|
72 | - ); |
|
73 | - $limit++; |
|
74 | - return $limit; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Get_amount_requested |
|
79 | - * |
|
80 | - * This checks the $args to determine the amount requested |
|
81 | - * |
|
82 | - * @return int|null |
|
83 | - * @throws Exception |
|
84 | - */ |
|
85 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
86 | - public function get_amount_requested(): ?int |
|
87 | - { |
|
88 | - $amount_requested = parent::get_amount_requested(); |
|
89 | - |
|
90 | - /** |
|
91 | - * If both first & last are used in the input args, throw an exception as that won't |
|
92 | - * work properly |
|
93 | - */ |
|
94 | - if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === 10) { |
|
95 | - return 100; // default. |
|
96 | - } |
|
97 | - |
|
98 | - return $amount_requested; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Determine whether or not the the offset is valid, i.e the entity corresponding to the |
|
103 | - * offset exists. Offset is equivalent to entity ID. So this function is equivalent to |
|
104 | - * checking if the entity with the given ID exists. |
|
105 | - * |
|
106 | - * @param int $offset The ID of the node used for the cursor offset |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
110 | - public function is_valid_offset($offset): bool |
|
111 | - { |
|
112 | - $entity = $this->get_query()->get_one_by_ID($offset); |
|
113 | - |
|
114 | - return $entity instanceof EE_Base_Class; |
|
115 | - } |
|
116 | - |
|
117 | - /** |
|
118 | - * Validates Model. |
|
119 | - * |
|
120 | - * @param array $model Entity node. |
|
121 | - * @return bool |
|
122 | - */ |
|
123 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
124 | - protected function is_valid_model($model): bool |
|
125 | - { |
|
126 | - return $model instanceof EE_Base_Class; |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | - * friendly keys. |
|
133 | - * |
|
134 | - * @param array $query_args |
|
135 | - * @param array $where_params |
|
136 | - * @param string $primary_key |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array |
|
140 | - { |
|
141 | - // ID of the current offset |
|
142 | - $offset = $this->get_offset(); |
|
143 | - /** |
|
144 | - * Map the orderby inputArgs to the WP_Query |
|
145 | - */ |
|
146 | - if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
147 | - $query_args['order_by'] = []; |
|
148 | - foreach ($this->args['where']['orderby'] as $orderby_input) { |
|
149 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
150 | - } |
|
151 | - } elseif ($offset) { |
|
152 | - $compare = $this->args['last'] ? '<' : '>'; |
|
153 | - $where_params[ $primary_key ] = [$compare, $offset]; |
|
154 | - } |
|
155 | - return [$query_args, $where_params]; |
|
156 | - } |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
161 | - * friendly keys. |
|
162 | - * |
|
163 | - * @param array $where_args |
|
164 | - * @param array $arg_mapping |
|
165 | - * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
166 | - * @return array |
|
167 | - */ |
|
168 | - protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array |
|
169 | - { |
|
170 | - $query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields); |
|
171 | - return ! empty($query_args) && is_array($query_args) |
|
172 | - ? $query_args |
|
173 | - : []; |
|
174 | - } |
|
175 | - |
|
176 | - |
|
177 | - /** |
|
178 | - * This returns the sanitized "search" keywords from where_args |
|
179 | - * |
|
180 | - * @param array $where_args |
|
181 | - * @return string |
|
182 | - */ |
|
183 | - protected function getSearchKeywords(array $where_args): string |
|
184 | - { |
|
185 | - $search = ''; |
|
186 | - if (! empty($where_args['search'])) { |
|
187 | - $search = sanitize_text_field($where_args['search']); |
|
188 | - } |
|
189 | - return esc_sql($search); |
|
190 | - } |
|
23 | + /** |
|
24 | + * @var Utilities |
|
25 | + */ |
|
26 | + private $utilities; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @return Utilities |
|
31 | + */ |
|
32 | + public function getUtilities(): Utilities |
|
33 | + { |
|
34 | + if (! $this->utilities instanceof Utilities) { |
|
35 | + $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); |
|
36 | + } |
|
37 | + return $this->utilities; |
|
38 | + } |
|
39 | + |
|
40 | + /** |
|
41 | + * Determine whether the Query should execute. If it's determined that the query should |
|
42 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
43 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
44 | + * Return false to prevent the query from executing. |
|
45 | + * |
|
46 | + * @return bool |
|
47 | + */ |
|
48 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
49 | + public function should_execute(): bool |
|
50 | + { |
|
51 | + return $this->should_execute; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * Set limit the highest value of first and last, with a (filterable) max of 100 |
|
57 | + * |
|
58 | + * @return int |
|
59 | + */ |
|
60 | + protected function getLimit(): int |
|
61 | + { |
|
62 | + $first = ! empty($this->args['first']) |
|
63 | + ? absint($this->args['first']) |
|
64 | + : null; |
|
65 | + $last = ! empty($this->args['last']) |
|
66 | + ? absint($this->args['last']) |
|
67 | + : null; |
|
68 | + |
|
69 | + $limit = min( |
|
70 | + max($first, $last, 100), |
|
71 | + $this->query_amount |
|
72 | + ); |
|
73 | + $limit++; |
|
74 | + return $limit; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Get_amount_requested |
|
79 | + * |
|
80 | + * This checks the $args to determine the amount requested |
|
81 | + * |
|
82 | + * @return int|null |
|
83 | + * @throws Exception |
|
84 | + */ |
|
85 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
86 | + public function get_amount_requested(): ?int |
|
87 | + { |
|
88 | + $amount_requested = parent::get_amount_requested(); |
|
89 | + |
|
90 | + /** |
|
91 | + * If both first & last are used in the input args, throw an exception as that won't |
|
92 | + * work properly |
|
93 | + */ |
|
94 | + if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === 10) { |
|
95 | + return 100; // default. |
|
96 | + } |
|
97 | + |
|
98 | + return $amount_requested; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Determine whether or not the the offset is valid, i.e the entity corresponding to the |
|
103 | + * offset exists. Offset is equivalent to entity ID. So this function is equivalent to |
|
104 | + * checking if the entity with the given ID exists. |
|
105 | + * |
|
106 | + * @param int $offset The ID of the node used for the cursor offset |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
110 | + public function is_valid_offset($offset): bool |
|
111 | + { |
|
112 | + $entity = $this->get_query()->get_one_by_ID($offset); |
|
113 | + |
|
114 | + return $entity instanceof EE_Base_Class; |
|
115 | + } |
|
116 | + |
|
117 | + /** |
|
118 | + * Validates Model. |
|
119 | + * |
|
120 | + * @param array $model Entity node. |
|
121 | + * @return bool |
|
122 | + */ |
|
123 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
124 | + protected function is_valid_model($model): bool |
|
125 | + { |
|
126 | + return $model instanceof EE_Base_Class; |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | + * friendly keys. |
|
133 | + * |
|
134 | + * @param array $query_args |
|
135 | + * @param array $where_params |
|
136 | + * @param string $primary_key |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array |
|
140 | + { |
|
141 | + // ID of the current offset |
|
142 | + $offset = $this->get_offset(); |
|
143 | + /** |
|
144 | + * Map the orderby inputArgs to the WP_Query |
|
145 | + */ |
|
146 | + if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
147 | + $query_args['order_by'] = []; |
|
148 | + foreach ($this->args['where']['orderby'] as $orderby_input) { |
|
149 | + $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
150 | + } |
|
151 | + } elseif ($offset) { |
|
152 | + $compare = $this->args['last'] ? '<' : '>'; |
|
153 | + $where_params[ $primary_key ] = [$compare, $offset]; |
|
154 | + } |
|
155 | + return [$query_args, $where_params]; |
|
156 | + } |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
161 | + * friendly keys. |
|
162 | + * |
|
163 | + * @param array $where_args |
|
164 | + * @param array $arg_mapping |
|
165 | + * @param array $id_fields The fields to convert from global IDs to DB IDs. |
|
166 | + * @return array |
|
167 | + */ |
|
168 | + protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array |
|
169 | + { |
|
170 | + $query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields); |
|
171 | + return ! empty($query_args) && is_array($query_args) |
|
172 | + ? $query_args |
|
173 | + : []; |
|
174 | + } |
|
175 | + |
|
176 | + |
|
177 | + /** |
|
178 | + * This returns the sanitized "search" keywords from where_args |
|
179 | + * |
|
180 | + * @param array $where_args |
|
181 | + * @return string |
|
182 | + */ |
|
183 | + protected function getSearchKeywords(array $where_args): string |
|
184 | + { |
|
185 | + $search = ''; |
|
186 | + if (! empty($where_args['search'])) { |
|
187 | + $search = sanitize_text_field($where_args['search']); |
|
188 | + } |
|
189 | + return esc_sql($search); |
|
190 | + } |
|
191 | 191 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function getUtilities(): Utilities |
33 | 33 | { |
34 | - if (! $this->utilities instanceof Utilities) { |
|
34 | + if ( ! $this->utilities instanceof Utilities) { |
|
35 | 35 | $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class); |
36 | 36 | } |
37 | 37 | return $this->utilities; |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | /** |
144 | 144 | * Map the orderby inputArgs to the WP_Query |
145 | 145 | */ |
146 | - if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
146 | + if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) { |
|
147 | 147 | $query_args['order_by'] = []; |
148 | 148 | foreach ($this->args['where']['orderby'] as $orderby_input) { |
149 | - $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order']; |
|
149 | + $query_args['order_by'][$orderby_input['field']] = $orderby_input['order']; |
|
150 | 150 | } |
151 | 151 | } elseif ($offset) { |
152 | 152 | $compare = $this->args['last'] ? '<' : '>'; |
153 | - $where_params[ $primary_key ] = [$compare, $offset]; |
|
153 | + $where_params[$primary_key] = [$compare, $offset]; |
|
154 | 154 | } |
155 | 155 | return [$query_args, $where_params]; |
156 | 156 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | protected function getSearchKeywords(array $where_args): string |
184 | 184 | { |
185 | 185 | $search = ''; |
186 | - if (! empty($where_args['search'])) { |
|
186 | + if ( ! empty($where_args['search'])) { |
|
187 | 187 | $search = sanitize_text_field($where_args['search']); |
188 | 188 | } |
189 | 189 | return esc_sql($search); |
@@ -16,130 +16,130 @@ |
||
16 | 16 | */ |
17 | 17 | class VenueConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - public function get_loader_name(): string |
|
21 | - { |
|
22 | - return 'espresso_venue'; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return EEM_Venue |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | - public function get_query(): EEM_Venue |
|
35 | - { |
|
36 | - return EEM_Venue::instance(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Return an array of item IDs from the query |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | - public function get_ids(): array |
|
47 | - { |
|
48 | - $results = $this->query->get_col($this->query_args); |
|
49 | - |
|
50 | - return ! empty($results) ? $results : []; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | - * handle batch resolution of the posts. |
|
58 | - * |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | - public function get_query_args(): array |
|
63 | - { |
|
64 | - $where_params = []; |
|
65 | - $query_args = []; |
|
66 | - |
|
67 | - $query_args['limit'] = $this->getLimit(); |
|
68 | - |
|
69 | - // Avoid multiple entries by join. |
|
70 | - $query_args['group_by'] = 'VNU_ID'; |
|
71 | - |
|
72 | - $query_args['default_where_conditions'] = 'minimum'; |
|
73 | - |
|
74 | - /** |
|
75 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | - */ |
|
77 | - $input_fields = []; |
|
78 | - if (! empty($this->args['where'])) { |
|
79 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | - * set the query to pull datetimes that belong to that event. |
|
86 | - * We can set more cases for other source types. |
|
87 | - */ |
|
88 | - if (is_object($this->source)) { |
|
89 | - switch (true) { |
|
90 | - // Assumed to be an event |
|
91 | - case $this->source instanceof Post: |
|
92 | - $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | - break; |
|
94 | - case $this->source instanceof EE_Event: |
|
95 | - $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | - break; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Merge the input_fields with the default query_args |
|
102 | - */ |
|
103 | - if (! empty($input_fields)) { |
|
104 | - $where_params = array_merge($where_params, $input_fields); |
|
105 | - } |
|
106 | - |
|
107 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | - |
|
109 | - $where_params = apply_filters( |
|
110 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | - $where_params, |
|
112 | - $this->source, |
|
113 | - $this->args |
|
114 | - ); |
|
115 | - |
|
116 | - $query_args[] = $where_params; |
|
117 | - |
|
118 | - /** |
|
119 | - * Return the $query_args |
|
120 | - */ |
|
121 | - return apply_filters( |
|
122 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | - $query_args, |
|
124 | - $this->source, |
|
125 | - $this->args |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | - * friendly keys. |
|
133 | - * |
|
134 | - * @param array $where_args |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function sanitizeInputFields(array $where_args): array |
|
138 | - { |
|
139 | - return $this->sanitizeWhereArgsForInputFields( |
|
140 | - $where_args, |
|
141 | - [], |
|
142 | - [] |
|
143 | - ); |
|
144 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + public function get_loader_name(): string |
|
21 | + { |
|
22 | + return 'espresso_venue'; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return EEM_Venue |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | + public function get_query(): EEM_Venue |
|
35 | + { |
|
36 | + return EEM_Venue::instance(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Return an array of item IDs from the query |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | + public function get_ids(): array |
|
47 | + { |
|
48 | + $results = $this->query->get_col($this->query_args); |
|
49 | + |
|
50 | + return ! empty($results) ? $results : []; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | + * handle batch resolution of the posts. |
|
58 | + * |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | + public function get_query_args(): array |
|
63 | + { |
|
64 | + $where_params = []; |
|
65 | + $query_args = []; |
|
66 | + |
|
67 | + $query_args['limit'] = $this->getLimit(); |
|
68 | + |
|
69 | + // Avoid multiple entries by join. |
|
70 | + $query_args['group_by'] = 'VNU_ID'; |
|
71 | + |
|
72 | + $query_args['default_where_conditions'] = 'minimum'; |
|
73 | + |
|
74 | + /** |
|
75 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | + */ |
|
77 | + $input_fields = []; |
|
78 | + if (! empty($this->args['where'])) { |
|
79 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | + * set the query to pull datetimes that belong to that event. |
|
86 | + * We can set more cases for other source types. |
|
87 | + */ |
|
88 | + if (is_object($this->source)) { |
|
89 | + switch (true) { |
|
90 | + // Assumed to be an event |
|
91 | + case $this->source instanceof Post: |
|
92 | + $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | + break; |
|
94 | + case $this->source instanceof EE_Event: |
|
95 | + $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | + break; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Merge the input_fields with the default query_args |
|
102 | + */ |
|
103 | + if (! empty($input_fields)) { |
|
104 | + $where_params = array_merge($where_params, $input_fields); |
|
105 | + } |
|
106 | + |
|
107 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | + |
|
109 | + $where_params = apply_filters( |
|
110 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | + $where_params, |
|
112 | + $this->source, |
|
113 | + $this->args |
|
114 | + ); |
|
115 | + |
|
116 | + $query_args[] = $where_params; |
|
117 | + |
|
118 | + /** |
|
119 | + * Return the $query_args |
|
120 | + */ |
|
121 | + return apply_filters( |
|
122 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | + $query_args, |
|
124 | + $this->source, |
|
125 | + $this->args |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | + * friendly keys. |
|
133 | + * |
|
134 | + * @param array $where_args |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function sanitizeInputFields(array $where_args): array |
|
138 | + { |
|
139 | + return $this->sanitizeWhereArgsForInputFields( |
|
140 | + $where_args, |
|
141 | + [], |
|
142 | + [] |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | } |
@@ -14,79 +14,79 @@ |
||
14 | 14 | */ |
15 | 15 | class PriceTypeConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - public function get_loader_name(): string |
|
19 | - { |
|
20 | - return 'espresso_priceType'; |
|
21 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + public function get_loader_name(): string |
|
19 | + { |
|
20 | + return 'espresso_priceType'; |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return EEM_Price_Type |
|
25 | - * @throws EE_Error |
|
26 | - * @throws InvalidArgumentException |
|
27 | - * @throws InvalidDataTypeException |
|
28 | - * @throws InvalidInterfaceException |
|
29 | - * @throws ReflectionException |
|
30 | - */ |
|
31 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | - public function get_query(): EEM_Price_Type |
|
33 | - { |
|
34 | - return EEM_Price_Type::instance(); |
|
35 | - } |
|
23 | + /** |
|
24 | + * @return EEM_Price_Type |
|
25 | + * @throws EE_Error |
|
26 | + * @throws InvalidArgumentException |
|
27 | + * @throws InvalidDataTypeException |
|
28 | + * @throws InvalidInterfaceException |
|
29 | + * @throws ReflectionException |
|
30 | + */ |
|
31 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
32 | + public function get_query(): EEM_Price_Type |
|
33 | + { |
|
34 | + return EEM_Price_Type::instance(); |
|
35 | + } |
|
36 | 36 | |
37 | 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(): array |
|
45 | - { |
|
46 | - $results = $this->query->get_col($this->query_args); |
|
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(): array |
|
45 | + { |
|
46 | + $results = $this->query->get_col($this->query_args); |
|
47 | 47 | |
48 | - return ! empty($results) ? $results : []; |
|
49 | - } |
|
48 | + return ! empty($results) ? $results : []; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
54 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
55 | - * handle batch resolution of the posts. |
|
56 | - * |
|
57 | - * @return array |
|
58 | - * @throws InvalidArgumentException |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - * @throws InvalidInterfaceException |
|
61 | - */ |
|
62 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | - public function get_query_args(): array |
|
64 | - { |
|
65 | - $where_params = []; |
|
66 | - $query_args = []; |
|
52 | + /** |
|
53 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
54 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
55 | + * handle batch resolution of the posts. |
|
56 | + * |
|
57 | + * @return array |
|
58 | + * @throws InvalidArgumentException |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + * @throws InvalidInterfaceException |
|
61 | + */ |
|
62 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | + public function get_query_args(): array |
|
64 | + { |
|
65 | + $where_params = []; |
|
66 | + $query_args = []; |
|
67 | 67 | |
68 | - $query_args['limit'] = $this->getLimit(); |
|
68 | + $query_args['limit'] = $this->getLimit(); |
|
69 | 69 | |
70 | - // Avoid multiple entries by join. |
|
71 | - $query_args['group_by'] = 'PRT_ID'; |
|
70 | + // Avoid multiple entries by join. |
|
71 | + $query_args['group_by'] = 'PRT_ID'; |
|
72 | 72 | |
73 | - $where_params = apply_filters( |
|
74 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_where_params', |
|
75 | - $where_params, |
|
76 | - $this->source, |
|
77 | - $this->args |
|
78 | - ); |
|
73 | + $where_params = apply_filters( |
|
74 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_where_params', |
|
75 | + $where_params, |
|
76 | + $this->source, |
|
77 | + $this->args |
|
78 | + ); |
|
79 | 79 | |
80 | - $query_args[] = $where_params; |
|
80 | + $query_args[] = $where_params; |
|
81 | 81 | |
82 | - /** |
|
83 | - * Return the $query_args |
|
84 | - */ |
|
85 | - return apply_filters( |
|
86 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_query_args', |
|
87 | - $query_args, |
|
88 | - $this->source, |
|
89 | - $this->args |
|
90 | - ); |
|
91 | - } |
|
82 | + /** |
|
83 | + * Return the $query_args |
|
84 | + */ |
|
85 | + return apply_filters( |
|
86 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_query_args', |
|
87 | + $query_args, |
|
88 | + $this->source, |
|
89 | + $this->args |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | } |