@@ -15,31 +15,31 @@ |
||
15 | 15 | class StatesConnectionOrderbyEnum extends EnumBase |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * StatesConnectionOrderbyEnum constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - $this->setName($this->namespace . 'StatesConnectionOrderbyEnum'); |
|
24 | - $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | - parent::__construct(); |
|
26 | - } |
|
18 | + /** |
|
19 | + * StatesConnectionOrderbyEnum constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + $this->setName($this->namespace . 'StatesConnectionOrderbyEnum'); |
|
24 | + $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
|
25 | + parent::__construct(); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @return array |
|
31 | - */ |
|
32 | - protected function getValues(): array |
|
33 | - { |
|
34 | - return [ |
|
35 | - 'NAME' => [ |
|
36 | - 'value' => 'CNT_name', |
|
37 | - 'description' => esc_html__('Order by state name', 'event_espresso'), |
|
38 | - ], |
|
39 | - 'COUNTRY_ISO' => [ |
|
40 | - 'value' => 'CNT_ISO', |
|
41 | - 'description' => esc_html__('Order by country ISO', 'event_espresso'), |
|
42 | - ], |
|
43 | - ]; |
|
44 | - } |
|
29 | + /** |
|
30 | + * @return array |
|
31 | + */ |
|
32 | + protected function getValues(): array |
|
33 | + { |
|
34 | + return [ |
|
35 | + 'NAME' => [ |
|
36 | + 'value' => 'CNT_name', |
|
37 | + 'description' => esc_html__('Order by state name', 'event_espresso'), |
|
38 | + ], |
|
39 | + 'COUNTRY_ISO' => [ |
|
40 | + 'value' => 'CNT_ISO', |
|
41 | + 'description' => esc_html__('Order by country ISO', 'event_espresso'), |
|
42 | + ], |
|
43 | + ]; |
|
44 | + } |
|
45 | 45 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | public function __construct() |
22 | 22 | { |
23 | - $this->setName($this->namespace . 'StatesConnectionOrderbyEnum'); |
|
23 | + $this->setName($this->namespace.'StatesConnectionOrderbyEnum'); |
|
24 | 24 | $this->setDescription(esc_html__('Field to order the connection by', 'event_espresso')); |
25 | 25 | parent::__construct(); |
26 | 26 | } |
@@ -14,152 +14,152 @@ |
||
14 | 14 | */ |
15 | 15 | class StateConnectionResolver extends AbstractConnectionResolver |
16 | 16 | { |
17 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | - public function get_loader_name(): string |
|
19 | - { |
|
20 | - return 'espresso_state'; |
|
21 | - } |
|
22 | - |
|
23 | - /** |
|
24 | - * @return EEM_State |
|
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_State |
|
33 | - { |
|
34 | - return EEM_State::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 | - |
|
48 | - return ! empty($results) ? $results : []; |
|
49 | - } |
|
50 | - |
|
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 = []; |
|
67 | - |
|
68 | - $query_args['limit'] = $this->getLimit(); |
|
69 | - |
|
70 | - // Avoid multiple entries by join. |
|
71 | - $query_args['group_by'] = 'STA_ID'; |
|
72 | - |
|
73 | - $query_args['default_where_conditions'] = 'minimum'; |
|
74 | - |
|
75 | - /** |
|
76 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
77 | - */ |
|
78 | - $input_fields = []; |
|
79 | - if (! empty($this->args['where'])) { |
|
80 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | - |
|
82 | - // Since we do not have any falsy values in query params |
|
83 | - // Lets get rid of empty values |
|
84 | - $input_fields = array_filter($input_fields); |
|
85 | - |
|
86 | - // Use the proper operator. |
|
87 | - if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) { |
|
88 | - $input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']]; |
|
89 | - } |
|
90 | - if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
91 | - $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Merge the input_fields with the default query_args |
|
97 | - */ |
|
98 | - if (! empty($input_fields)) { |
|
99 | - $where_params = array_merge($where_params, $input_fields); |
|
100 | - } |
|
101 | - |
|
102 | - // limit to active countries by default. |
|
103 | - if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
104 | - $where_params['STA_active'] = true; |
|
105 | - } |
|
106 | - |
|
107 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'STA_ID'); |
|
108 | - |
|
109 | - if (empty($query_args['order_by'])) { |
|
110 | - // set order_by to 'name' by default |
|
111 | - $query_args['order_by'] = [ |
|
112 | - 'STA_name' => 'ASC', |
|
113 | - ]; |
|
114 | - } |
|
115 | - |
|
116 | - $search = $this->getSearchKeywords($this->args['where']); |
|
117 | - |
|
118 | - if (! empty($search)) { |
|
119 | - // use OR operator to search in any of the fields |
|
120 | - $where_params['OR'] = array( |
|
121 | - 'STA_name' => array('LIKE', '%' . $search . '%'), |
|
122 | - ); |
|
123 | - } |
|
124 | - |
|
125 | - $where_params = apply_filters( |
|
126 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_where_params', |
|
127 | - $where_params, |
|
128 | - $this->source, |
|
129 | - $this->args |
|
130 | - ); |
|
131 | - |
|
132 | - $query_args[] = $where_params; |
|
133 | - |
|
134 | - /** |
|
135 | - * Return the $query_args |
|
136 | - */ |
|
137 | - return apply_filters( |
|
138 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_query_args', |
|
139 | - $query_args, |
|
140 | - $this->source, |
|
141 | - $this->args |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
148 | - * friendly keys. |
|
149 | - * |
|
150 | - * @param array $where_args |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function sanitizeInputFields(array $where_args): array |
|
154 | - { |
|
155 | - $arg_mapping = [ |
|
156 | - 'in' => 'STA_ID', |
|
157 | - 'countryIsoIn' => 'CNT_ISO', |
|
158 | - ]; |
|
159 | - return $this->sanitizeWhereArgsForInputFields( |
|
160 | - $where_args, |
|
161 | - $arg_mapping, |
|
162 | - ['in'] |
|
163 | - ); |
|
164 | - } |
|
17 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
18 | + public function get_loader_name(): string |
|
19 | + { |
|
20 | + return 'espresso_state'; |
|
21 | + } |
|
22 | + |
|
23 | + /** |
|
24 | + * @return EEM_State |
|
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_State |
|
33 | + { |
|
34 | + return EEM_State::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 | + |
|
48 | + return ! empty($results) ? $results : []; |
|
49 | + } |
|
50 | + |
|
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 = []; |
|
67 | + |
|
68 | + $query_args['limit'] = $this->getLimit(); |
|
69 | + |
|
70 | + // Avoid multiple entries by join. |
|
71 | + $query_args['group_by'] = 'STA_ID'; |
|
72 | + |
|
73 | + $query_args['default_where_conditions'] = 'minimum'; |
|
74 | + |
|
75 | + /** |
|
76 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
77 | + */ |
|
78 | + $input_fields = []; |
|
79 | + if (! empty($this->args['where'])) { |
|
80 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
81 | + |
|
82 | + // Since we do not have any falsy values in query params |
|
83 | + // Lets get rid of empty values |
|
84 | + $input_fields = array_filter($input_fields); |
|
85 | + |
|
86 | + // Use the proper operator. |
|
87 | + if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) { |
|
88 | + $input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']]; |
|
89 | + } |
|
90 | + if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
91 | + $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Merge the input_fields with the default query_args |
|
97 | + */ |
|
98 | + if (! empty($input_fields)) { |
|
99 | + $where_params = array_merge($where_params, $input_fields); |
|
100 | + } |
|
101 | + |
|
102 | + // limit to active countries by default. |
|
103 | + if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
104 | + $where_params['STA_active'] = true; |
|
105 | + } |
|
106 | + |
|
107 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'STA_ID'); |
|
108 | + |
|
109 | + if (empty($query_args['order_by'])) { |
|
110 | + // set order_by to 'name' by default |
|
111 | + $query_args['order_by'] = [ |
|
112 | + 'STA_name' => 'ASC', |
|
113 | + ]; |
|
114 | + } |
|
115 | + |
|
116 | + $search = $this->getSearchKeywords($this->args['where']); |
|
117 | + |
|
118 | + if (! empty($search)) { |
|
119 | + // use OR operator to search in any of the fields |
|
120 | + $where_params['OR'] = array( |
|
121 | + 'STA_name' => array('LIKE', '%' . $search . '%'), |
|
122 | + ); |
|
123 | + } |
|
124 | + |
|
125 | + $where_params = apply_filters( |
|
126 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_where_params', |
|
127 | + $where_params, |
|
128 | + $this->source, |
|
129 | + $this->args |
|
130 | + ); |
|
131 | + |
|
132 | + $query_args[] = $where_params; |
|
133 | + |
|
134 | + /** |
|
135 | + * Return the $query_args |
|
136 | + */ |
|
137 | + return apply_filters( |
|
138 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__state_query_args', |
|
139 | + $query_args, |
|
140 | + $this->source, |
|
141 | + $this->args |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
148 | + * friendly keys. |
|
149 | + * |
|
150 | + * @param array $where_args |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function sanitizeInputFields(array $where_args): array |
|
154 | + { |
|
155 | + $arg_mapping = [ |
|
156 | + 'in' => 'STA_ID', |
|
157 | + 'countryIsoIn' => 'CNT_ISO', |
|
158 | + ]; |
|
159 | + return $this->sanitizeWhereArgsForInputFields( |
|
160 | + $where_args, |
|
161 | + $arg_mapping, |
|
162 | + ['in'] |
|
163 | + ); |
|
164 | + } |
|
165 | 165 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
77 | 77 | */ |
78 | 78 | $input_fields = []; |
79 | - if (! empty($this->args['where'])) { |
|
79 | + if ( ! empty($this->args['where'])) { |
|
80 | 80 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
81 | 81 | |
82 | 82 | // Since we do not have any falsy values in query params |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | $input_fields = array_filter($input_fields); |
85 | 85 | |
86 | 86 | // Use the proper operator. |
87 | - if (! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) { |
|
87 | + if ( ! empty($input_fields['STA_ID']) && is_array($input_fields['STA_ID'])) { |
|
88 | 88 | $input_fields['STA_ID'] = ['IN', $input_fields['STA_ID']]; |
89 | 89 | } |
90 | - if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
90 | + if ( ! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
91 | 91 | $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
92 | 92 | } |
93 | 93 | } |
@@ -95,12 +95,12 @@ discard block |
||
95 | 95 | /** |
96 | 96 | * Merge the input_fields with the default query_args |
97 | 97 | */ |
98 | - if (! empty($input_fields)) { |
|
98 | + if ( ! empty($input_fields)) { |
|
99 | 99 | $where_params = array_merge($where_params, $input_fields); |
100 | 100 | } |
101 | 101 | |
102 | 102 | // limit to active countries by default. |
103 | - if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
103 | + if ( ! isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
104 | 104 | $where_params['STA_active'] = true; |
105 | 105 | } |
106 | 106 | |
@@ -115,10 +115,10 @@ discard block |
||
115 | 115 | |
116 | 116 | $search = $this->getSearchKeywords($this->args['where']); |
117 | 117 | |
118 | - if (! empty($search)) { |
|
118 | + if ( ! empty($search)) { |
|
119 | 119 | // use OR operator to search in any of the fields |
120 | 120 | $where_params['OR'] = array( |
121 | - 'STA_name' => array('LIKE', '%' . $search . '%'), |
|
121 | + 'STA_name' => array('LIKE', '%'.$search.'%'), |
|
122 | 122 | ); |
123 | 123 | } |
124 | 124 |
@@ -16,170 +16,170 @@ |
||
16 | 16 | */ |
17 | 17 | class CountryConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - public function get_loader_name(): string |
|
21 | - { |
|
22 | - return 'espresso_country'; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return EEM_Country |
|
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_Country |
|
35 | - { |
|
36 | - return EEM_Country::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 | - * Get_query_amount |
|
55 | - * |
|
56 | - * Returns the max between what was requested and what is defined as the $max_query_amount to |
|
57 | - * ensure that queries don't exceed unwanted limits when querying data. |
|
58 | - * |
|
59 | - * @return int |
|
60 | - * @throws Exception |
|
61 | - */ |
|
62 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | - public function get_query_amount() |
|
64 | - { |
|
65 | - // Override the default limit (100) for countries |
|
66 | - return 300; |
|
67 | - } |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
72 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
73 | - * handle batch resolution of the posts. |
|
74 | - * |
|
75 | - * @return array |
|
76 | - * @throws InvalidArgumentException |
|
77 | - * @throws InvalidDataTypeException |
|
78 | - * @throws InvalidInterfaceException |
|
79 | - */ |
|
80 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
81 | - public function get_query_args(): array |
|
82 | - { |
|
83 | - $where_params = []; |
|
84 | - $query_args = []; |
|
85 | - |
|
86 | - $query_args['limit'] = $this->getLimit(); |
|
87 | - |
|
88 | - // Avoid multiple entries by join. |
|
89 | - $query_args['group_by'] = 'CNT_ISO'; |
|
90 | - |
|
91 | - $query_args['default_where_conditions'] = 'minimum'; |
|
92 | - |
|
93 | - /** |
|
94 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
95 | - */ |
|
96 | - $input_fields = []; |
|
97 | - if (! empty($this->args['where'])) { |
|
98 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
99 | - |
|
100 | - // Since we do not have any falsy values in query params |
|
101 | - // Lets get rid of empty values |
|
102 | - $input_fields = array_filter($input_fields); |
|
103 | - |
|
104 | - // Use the proper operator. |
|
105 | - if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
106 | - $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
|
107 | - } |
|
108 | - if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) { |
|
109 | - $input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']]; |
|
110 | - } |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Merge the input_fields with the default query_args |
|
115 | - */ |
|
116 | - if (! empty($input_fields)) { |
|
117 | - $where_params = array_merge($where_params, $input_fields); |
|
118 | - } |
|
119 | - |
|
120 | - // limit to active countries by default. |
|
121 | - if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
122 | - $where_params['CNT_active'] = true; |
|
123 | - } |
|
124 | - |
|
125 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'CNT_ISO'); |
|
126 | - |
|
127 | - if (empty($query_args['order_by'])) { |
|
128 | - // set order_by to 'name' by default |
|
129 | - $query_args['order_by'] = [ |
|
130 | - 'CNT_name' => 'ASC', |
|
131 | - ]; |
|
132 | - } |
|
133 | - |
|
134 | - $search = $this->getSearchKeywords($this->args['where']); |
|
135 | - |
|
136 | - if (! empty($search)) { |
|
137 | - // use OR operator to search in any of the fields |
|
138 | - $where_params['OR'] = array( |
|
139 | - 'CNT_name' => array('LIKE', '%' . $search . '%'), |
|
140 | - 'CNT_ISO' => array('LIKE', '%' . $search . '%'), |
|
141 | - ); |
|
142 | - } |
|
143 | - |
|
144 | - $where_params = apply_filters( |
|
145 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_where_params', |
|
146 | - $where_params, |
|
147 | - $this->source, |
|
148 | - $this->args |
|
149 | - ); |
|
150 | - |
|
151 | - $query_args[] = $where_params; |
|
152 | - |
|
153 | - /** |
|
154 | - * Return the $query_args |
|
155 | - */ |
|
156 | - return apply_filters( |
|
157 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_query_args', |
|
158 | - $query_args, |
|
159 | - $this->source, |
|
160 | - $this->args |
|
161 | - ); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - /** |
|
166 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
167 | - * friendly keys. |
|
168 | - * |
|
169 | - * @param array $where_args |
|
170 | - * @return array |
|
171 | - */ |
|
172 | - public function sanitizeInputFields(array $where_args): array |
|
173 | - { |
|
174 | - $arg_mapping = [ |
|
175 | - 'isoIn' => 'CNT_ISO', |
|
176 | - 'in' => 'CNT_ISO', |
|
177 | - 'iso3In' => 'CNT_ISO3', |
|
178 | - ]; |
|
179 | - return $this->sanitizeWhereArgsForInputFields( |
|
180 | - $where_args, |
|
181 | - $arg_mapping, |
|
182 | - ['in'] |
|
183 | - ); |
|
184 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + public function get_loader_name(): string |
|
21 | + { |
|
22 | + return 'espresso_country'; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return EEM_Country |
|
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_Country |
|
35 | + { |
|
36 | + return EEM_Country::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 | + * Get_query_amount |
|
55 | + * |
|
56 | + * Returns the max between what was requested and what is defined as the $max_query_amount to |
|
57 | + * ensure that queries don't exceed unwanted limits when querying data. |
|
58 | + * |
|
59 | + * @return int |
|
60 | + * @throws Exception |
|
61 | + */ |
|
62 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
63 | + public function get_query_amount() |
|
64 | + { |
|
65 | + // Override the default limit (100) for countries |
|
66 | + return 300; |
|
67 | + } |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
72 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
73 | + * handle batch resolution of the posts. |
|
74 | + * |
|
75 | + * @return array |
|
76 | + * @throws InvalidArgumentException |
|
77 | + * @throws InvalidDataTypeException |
|
78 | + * @throws InvalidInterfaceException |
|
79 | + */ |
|
80 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
81 | + public function get_query_args(): array |
|
82 | + { |
|
83 | + $where_params = []; |
|
84 | + $query_args = []; |
|
85 | + |
|
86 | + $query_args['limit'] = $this->getLimit(); |
|
87 | + |
|
88 | + // Avoid multiple entries by join. |
|
89 | + $query_args['group_by'] = 'CNT_ISO'; |
|
90 | + |
|
91 | + $query_args['default_where_conditions'] = 'minimum'; |
|
92 | + |
|
93 | + /** |
|
94 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
95 | + */ |
|
96 | + $input_fields = []; |
|
97 | + if (! empty($this->args['where'])) { |
|
98 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
99 | + |
|
100 | + // Since we do not have any falsy values in query params |
|
101 | + // Lets get rid of empty values |
|
102 | + $input_fields = array_filter($input_fields); |
|
103 | + |
|
104 | + // Use the proper operator. |
|
105 | + if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
106 | + $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
|
107 | + } |
|
108 | + if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) { |
|
109 | + $input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']]; |
|
110 | + } |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Merge the input_fields with the default query_args |
|
115 | + */ |
|
116 | + if (! empty($input_fields)) { |
|
117 | + $where_params = array_merge($where_params, $input_fields); |
|
118 | + } |
|
119 | + |
|
120 | + // limit to active countries by default. |
|
121 | + if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
122 | + $where_params['CNT_active'] = true; |
|
123 | + } |
|
124 | + |
|
125 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'CNT_ISO'); |
|
126 | + |
|
127 | + if (empty($query_args['order_by'])) { |
|
128 | + // set order_by to 'name' by default |
|
129 | + $query_args['order_by'] = [ |
|
130 | + 'CNT_name' => 'ASC', |
|
131 | + ]; |
|
132 | + } |
|
133 | + |
|
134 | + $search = $this->getSearchKeywords($this->args['where']); |
|
135 | + |
|
136 | + if (! empty($search)) { |
|
137 | + // use OR operator to search in any of the fields |
|
138 | + $where_params['OR'] = array( |
|
139 | + 'CNT_name' => array('LIKE', '%' . $search . '%'), |
|
140 | + 'CNT_ISO' => array('LIKE', '%' . $search . '%'), |
|
141 | + ); |
|
142 | + } |
|
143 | + |
|
144 | + $where_params = apply_filters( |
|
145 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_where_params', |
|
146 | + $where_params, |
|
147 | + $this->source, |
|
148 | + $this->args |
|
149 | + ); |
|
150 | + |
|
151 | + $query_args[] = $where_params; |
|
152 | + |
|
153 | + /** |
|
154 | + * Return the $query_args |
|
155 | + */ |
|
156 | + return apply_filters( |
|
157 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__country_query_args', |
|
158 | + $query_args, |
|
159 | + $this->source, |
|
160 | + $this->args |
|
161 | + ); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + /** |
|
166 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
167 | + * friendly keys. |
|
168 | + * |
|
169 | + * @param array $where_args |
|
170 | + * @return array |
|
171 | + */ |
|
172 | + public function sanitizeInputFields(array $where_args): array |
|
173 | + { |
|
174 | + $arg_mapping = [ |
|
175 | + 'isoIn' => 'CNT_ISO', |
|
176 | + 'in' => 'CNT_ISO', |
|
177 | + 'iso3In' => 'CNT_ISO3', |
|
178 | + ]; |
|
179 | + return $this->sanitizeWhereArgsForInputFields( |
|
180 | + $where_args, |
|
181 | + $arg_mapping, |
|
182 | + ['in'] |
|
183 | + ); |
|
184 | + } |
|
185 | 185 | } |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
95 | 95 | */ |
96 | 96 | $input_fields = []; |
97 | - if (! empty($this->args['where'])) { |
|
97 | + if ( ! empty($this->args['where'])) { |
|
98 | 98 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
99 | 99 | |
100 | 100 | // Since we do not have any falsy values in query params |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | $input_fields = array_filter($input_fields); |
103 | 103 | |
104 | 104 | // Use the proper operator. |
105 | - if (! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
105 | + if ( ! empty($input_fields['CNT_ISO']) && is_array($input_fields['CNT_ISO'])) { |
|
106 | 106 | $input_fields['CNT_ISO'] = ['IN', $input_fields['CNT_ISO']]; |
107 | 107 | } |
108 | - if (! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) { |
|
108 | + if ( ! empty($input_fields['CNT_ISO3']) && is_array($input_fields['CNT_ISO3'])) { |
|
109 | 109 | $input_fields['CNT_ISO3'] = ['IN', $input_fields['CNT_ISO3']]; |
110 | 110 | } |
111 | 111 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * Merge the input_fields with the default query_args |
115 | 115 | */ |
116 | - if (! empty($input_fields)) { |
|
116 | + if ( ! empty($input_fields)) { |
|
117 | 117 | $where_params = array_merge($where_params, $input_fields); |
118 | 118 | } |
119 | 119 | |
120 | 120 | // limit to active countries by default. |
121 | - if (!isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
121 | + if ( ! isset($this->args['where']['activeOnly']) || $this->args['where']['activeOnly']) { |
|
122 | 122 | $where_params['CNT_active'] = true; |
123 | 123 | } |
124 | 124 | |
@@ -133,11 +133,11 @@ discard block |
||
133 | 133 | |
134 | 134 | $search = $this->getSearchKeywords($this->args['where']); |
135 | 135 | |
136 | - if (! empty($search)) { |
|
136 | + if ( ! empty($search)) { |
|
137 | 137 | // use OR operator to search in any of the fields |
138 | 138 | $where_params['OR'] = array( |
139 | - 'CNT_name' => array('LIKE', '%' . $search . '%'), |
|
140 | - 'CNT_ISO' => array('LIKE', '%' . $search . '%'), |
|
139 | + 'CNT_name' => array('LIKE', '%'.$search.'%'), |
|
140 | + 'CNT_ISO' => array('LIKE', '%'.$search.'%'), |
|
141 | 141 | ); |
142 | 142 | } |
143 | 143 |
@@ -19,231 +19,231 @@ |
||
19 | 19 | */ |
20 | 20 | class GQLRequests extends Route |
21 | 21 | { |
22 | - /** |
|
23 | - * @var AssetManifestFactory |
|
24 | - */ |
|
25 | - private $manifest_factory; |
|
22 | + /** |
|
23 | + * @var AssetManifestFactory |
|
24 | + */ |
|
25 | + private $manifest_factory; |
|
26 | 26 | |
27 | 27 | |
28 | - /** |
|
29 | - * AssetRequests constructor. |
|
30 | - * |
|
31 | - * @param EE_Dependency_Map $dependency_map |
|
32 | - * @param LoaderInterface $loader |
|
33 | - * @param RequestInterface $request |
|
34 | - * @param AssetManifestFactory $manifest_factory |
|
35 | - */ |
|
36 | - public function __construct( |
|
37 | - EE_Dependency_Map $dependency_map, |
|
38 | - LoaderInterface $loader, |
|
39 | - RequestInterface $request, |
|
40 | - AssetManifestFactory $manifest_factory |
|
41 | - ) { |
|
42 | - $this->manifest_factory = $manifest_factory; |
|
43 | - parent::__construct($dependency_map, $loader, $request); |
|
44 | - } |
|
28 | + /** |
|
29 | + * AssetRequests constructor. |
|
30 | + * |
|
31 | + * @param EE_Dependency_Map $dependency_map |
|
32 | + * @param LoaderInterface $loader |
|
33 | + * @param RequestInterface $request |
|
34 | + * @param AssetManifestFactory $manifest_factory |
|
35 | + */ |
|
36 | + public function __construct( |
|
37 | + EE_Dependency_Map $dependency_map, |
|
38 | + LoaderInterface $loader, |
|
39 | + RequestInterface $request, |
|
40 | + AssetManifestFactory $manifest_factory |
|
41 | + ) { |
|
42 | + $this->manifest_factory = $manifest_factory; |
|
43 | + parent::__construct($dependency_map, $loader, $request); |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * returns true if the current request matches this route |
|
49 | - * |
|
50 | - * @return bool |
|
51 | - * @since $VID:$ |
|
52 | - */ |
|
53 | - public function matchesCurrentRequest(): bool |
|
54 | - { |
|
55 | - global $pagenow; |
|
56 | - return ( |
|
57 | - $this->request->isGQL() |
|
58 | - || $this->request->isUnitTesting() |
|
59 | - || ( |
|
60 | - $this->request->isAdmin() |
|
61 | - && $this->request->getRequestParam('page') === 'espresso_events' |
|
62 | - && ( |
|
63 | - $this->request->getRequestParam('action') === 'create_new' |
|
64 | - || $this->request->getRequestParam('action') === 'edit' |
|
65 | - ) |
|
66 | - ) |
|
67 | - || ( |
|
68 | - $pagenow |
|
69 | - && ( |
|
70 | - $pagenow === 'post-new.php' |
|
71 | - || ( |
|
72 | - $pagenow === 'post.php' |
|
73 | - && $this->request->getRequestParam('action') === 'edit' |
|
74 | - ) |
|
75 | - ) |
|
76 | - ) |
|
77 | - ); |
|
78 | - } |
|
47 | + /** |
|
48 | + * returns true if the current request matches this route |
|
49 | + * |
|
50 | + * @return bool |
|
51 | + * @since $VID:$ |
|
52 | + */ |
|
53 | + public function matchesCurrentRequest(): bool |
|
54 | + { |
|
55 | + global $pagenow; |
|
56 | + return ( |
|
57 | + $this->request->isGQL() |
|
58 | + || $this->request->isUnitTesting() |
|
59 | + || ( |
|
60 | + $this->request->isAdmin() |
|
61 | + && $this->request->getRequestParam('page') === 'espresso_events' |
|
62 | + && ( |
|
63 | + $this->request->getRequestParam('action') === 'create_new' |
|
64 | + || $this->request->getRequestParam('action') === 'edit' |
|
65 | + ) |
|
66 | + ) |
|
67 | + || ( |
|
68 | + $pagenow |
|
69 | + && ( |
|
70 | + $pagenow === 'post-new.php' |
|
71 | + || ( |
|
72 | + $pagenow === 'post.php' |
|
73 | + && $this->request->getRequestParam('action') === 'edit' |
|
74 | + ) |
|
75 | + ) |
|
76 | + ) |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | |
81 | - /** |
|
82 | - * @since $VID:$ |
|
83 | - */ |
|
84 | - protected function registerDependencies() |
|
85 | - { |
|
86 | - $this->dependency_map->registerDependencies( |
|
87 | - 'EventEspresso\core\services\graphql\GraphQLManager', |
|
88 | - [ |
|
89 | - 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
90 | - 'EventEspresso\core\services\graphql\DataLoaderManager' => EE_Dependency_Map::load_from_cache, |
|
91 | - 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
92 | - 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
93 | - 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
94 | - ] |
|
95 | - ); |
|
96 | - $this->dependency_map->registerDependencies( |
|
97 | - 'EventEspresso\core\services\graphql\TypesManager', |
|
98 | - [ |
|
99 | - 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
100 | - ] |
|
101 | - ); |
|
102 | - $this->dependency_map->registerDependencies( |
|
103 | - 'EventEspresso\core\services\graphql\InputsManager', |
|
104 | - [ |
|
105 | - 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
106 | - ] |
|
107 | - ); |
|
108 | - $this->dependency_map->registerDependencies( |
|
109 | - 'EventEspresso\core\services\graphql\EnumsManager', |
|
110 | - [ |
|
111 | - 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
112 | - ] |
|
113 | - ); |
|
114 | - $this->dependency_map->registerDependencies( |
|
115 | - 'EventEspresso\core\services\graphql\ConnectionsManager', |
|
116 | - [ |
|
117 | - 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
118 | - ] |
|
119 | - ); |
|
120 | - $this->dependency_map->registerDependencies( |
|
121 | - 'EventEspresso\core\services\graphql\DataLoaderManager', |
|
122 | - [ |
|
123 | - 'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache, |
|
124 | - ] |
|
125 | - ); |
|
126 | - $this->dependency_map->registerDependencies( |
|
127 | - 'EventEspresso\core\domain\services\graphql\types\Datetime', |
|
128 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
129 | - ); |
|
130 | - $this->dependency_map->registerDependencies( |
|
131 | - 'EventEspresso\core\domain\services\graphql\types\Attendee', |
|
132 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
133 | - ); |
|
134 | - $this->dependency_map->registerDependencies( |
|
135 | - 'EventEspresso\core\domain\services\graphql\types\Event', |
|
136 | - ['EEM_Event' => EE_Dependency_Map::load_from_cache] |
|
137 | - ); |
|
138 | - $this->dependency_map->registerDependencies( |
|
139 | - 'EventEspresso\core\domain\services\graphql\types\FormElement', |
|
140 | - ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache] |
|
141 | - ); |
|
142 | - $this->dependency_map->registerDependencies( |
|
143 | - 'EventEspresso\core\domain\services\graphql\types\FormSection', |
|
144 | - ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache] |
|
145 | - ); |
|
146 | - $this->dependency_map->registerDependencies( |
|
147 | - 'EventEspresso\core\domain\services\graphql\types\Ticket', |
|
148 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
149 | - ); |
|
150 | - $this->dependency_map->registerDependencies( |
|
151 | - 'EventEspresso\core\domain\services\graphql\types\Price', |
|
152 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
153 | - ); |
|
154 | - $this->dependency_map->registerDependencies( |
|
155 | - 'EventEspresso\core\domain\services\graphql\types\PriceType', |
|
156 | - ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
157 | - ); |
|
158 | - $this->dependency_map->registerDependencies( |
|
159 | - 'EventEspresso\core\domain\services\graphql\types\Venue', |
|
160 | - ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
161 | - ); |
|
162 | - $this->dependency_map->registerDependencies( |
|
163 | - 'EventEspresso\core\domain\services\graphql\types\State', |
|
164 | - ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
165 | - ); |
|
166 | - $this->dependency_map->registerDependencies( |
|
167 | - 'EventEspresso\core\domain\services\graphql\types\Country', |
|
168 | - ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
169 | - ); |
|
170 | - $this->dependency_map->registerDependencies( |
|
171 | - 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection', |
|
172 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
173 | - ); |
|
174 | - $this->dependency_map->registerDependencies( |
|
175 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection', |
|
176 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
177 | - ); |
|
178 | - $this->dependency_map->registerDependencies( |
|
179 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection', |
|
180 | - ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
181 | - ); |
|
182 | - $this->dependency_map->registerDependencies( |
|
183 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryCountriesConnection', |
|
184 | - ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
185 | - ); |
|
186 | - $this->dependency_map->registerDependencies( |
|
187 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection', |
|
188 | - ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache] |
|
189 | - ); |
|
190 | - $this->dependency_map->registerDependencies( |
|
191 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection', |
|
192 | - ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache] |
|
193 | - ); |
|
194 | - $this->dependency_map->registerDependencies( |
|
195 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryStatesConnection', |
|
196 | - ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
197 | - ); |
|
198 | - $this->dependency_map->registerDependencies( |
|
199 | - 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection', |
|
200 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
201 | - ); |
|
202 | - $this->dependency_map->registerDependencies( |
|
203 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection', |
|
204 | - ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
205 | - ); |
|
206 | - $this->dependency_map->registerDependencies( |
|
207 | - 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection', |
|
208 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
209 | - ); |
|
210 | - $this->dependency_map->registerDependencies( |
|
211 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection', |
|
212 | - ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
213 | - ); |
|
214 | - $this->dependency_map->registerDependencies( |
|
215 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection', |
|
216 | - ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
217 | - ); |
|
218 | - $this->dependency_map->registerDependencies( |
|
219 | - 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection', |
|
220 | - ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
221 | - ); |
|
222 | - $this->dependency_map->registerDependencies( |
|
223 | - 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection', |
|
224 | - ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
225 | - ); |
|
226 | - } |
|
81 | + /** |
|
82 | + * @since $VID:$ |
|
83 | + */ |
|
84 | + protected function registerDependencies() |
|
85 | + { |
|
86 | + $this->dependency_map->registerDependencies( |
|
87 | + 'EventEspresso\core\services\graphql\GraphQLManager', |
|
88 | + [ |
|
89 | + 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
90 | + 'EventEspresso\core\services\graphql\DataLoaderManager' => EE_Dependency_Map::load_from_cache, |
|
91 | + 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
92 | + 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
93 | + 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
94 | + ] |
|
95 | + ); |
|
96 | + $this->dependency_map->registerDependencies( |
|
97 | + 'EventEspresso\core\services\graphql\TypesManager', |
|
98 | + [ |
|
99 | + 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
100 | + ] |
|
101 | + ); |
|
102 | + $this->dependency_map->registerDependencies( |
|
103 | + 'EventEspresso\core\services\graphql\InputsManager', |
|
104 | + [ |
|
105 | + 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
106 | + ] |
|
107 | + ); |
|
108 | + $this->dependency_map->registerDependencies( |
|
109 | + 'EventEspresso\core\services\graphql\EnumsManager', |
|
110 | + [ |
|
111 | + 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
112 | + ] |
|
113 | + ); |
|
114 | + $this->dependency_map->registerDependencies( |
|
115 | + 'EventEspresso\core\services\graphql\ConnectionsManager', |
|
116 | + [ |
|
117 | + 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
118 | + ] |
|
119 | + ); |
|
120 | + $this->dependency_map->registerDependencies( |
|
121 | + 'EventEspresso\core\services\graphql\DataLoaderManager', |
|
122 | + [ |
|
123 | + 'EventEspresso\core\services\graphql\loaders\DataLoaderCollection' => EE_Dependency_Map::load_from_cache, |
|
124 | + ] |
|
125 | + ); |
|
126 | + $this->dependency_map->registerDependencies( |
|
127 | + 'EventEspresso\core\domain\services\graphql\types\Datetime', |
|
128 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
129 | + ); |
|
130 | + $this->dependency_map->registerDependencies( |
|
131 | + 'EventEspresso\core\domain\services\graphql\types\Attendee', |
|
132 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
133 | + ); |
|
134 | + $this->dependency_map->registerDependencies( |
|
135 | + 'EventEspresso\core\domain\services\graphql\types\Event', |
|
136 | + ['EEM_Event' => EE_Dependency_Map::load_from_cache] |
|
137 | + ); |
|
138 | + $this->dependency_map->registerDependencies( |
|
139 | + 'EventEspresso\core\domain\services\graphql\types\FormElement', |
|
140 | + ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache] |
|
141 | + ); |
|
142 | + $this->dependency_map->registerDependencies( |
|
143 | + 'EventEspresso\core\domain\services\graphql\types\FormSection', |
|
144 | + ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache] |
|
145 | + ); |
|
146 | + $this->dependency_map->registerDependencies( |
|
147 | + 'EventEspresso\core\domain\services\graphql\types\Ticket', |
|
148 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
149 | + ); |
|
150 | + $this->dependency_map->registerDependencies( |
|
151 | + 'EventEspresso\core\domain\services\graphql\types\Price', |
|
152 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
153 | + ); |
|
154 | + $this->dependency_map->registerDependencies( |
|
155 | + 'EventEspresso\core\domain\services\graphql\types\PriceType', |
|
156 | + ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
157 | + ); |
|
158 | + $this->dependency_map->registerDependencies( |
|
159 | + 'EventEspresso\core\domain\services\graphql\types\Venue', |
|
160 | + ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
161 | + ); |
|
162 | + $this->dependency_map->registerDependencies( |
|
163 | + 'EventEspresso\core\domain\services\graphql\types\State', |
|
164 | + ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
165 | + ); |
|
166 | + $this->dependency_map->registerDependencies( |
|
167 | + 'EventEspresso\core\domain\services\graphql\types\Country', |
|
168 | + ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
169 | + ); |
|
170 | + $this->dependency_map->registerDependencies( |
|
171 | + 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection', |
|
172 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
173 | + ); |
|
174 | + $this->dependency_map->registerDependencies( |
|
175 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection', |
|
176 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
177 | + ); |
|
178 | + $this->dependency_map->registerDependencies( |
|
179 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection', |
|
180 | + ['EEM_Attendee' => EE_Dependency_Map::load_from_cache] |
|
181 | + ); |
|
182 | + $this->dependency_map->registerDependencies( |
|
183 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryCountriesConnection', |
|
184 | + ['EEM_Country' => EE_Dependency_Map::load_from_cache] |
|
185 | + ); |
|
186 | + $this->dependency_map->registerDependencies( |
|
187 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryFormElementsConnection', |
|
188 | + ['EEM_Form_Element' => EE_Dependency_Map::load_from_cache] |
|
189 | + ); |
|
190 | + $this->dependency_map->registerDependencies( |
|
191 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryFormSectionsConnection', |
|
192 | + ['EEM_Form_Section' => EE_Dependency_Map::load_from_cache] |
|
193 | + ); |
|
194 | + $this->dependency_map->registerDependencies( |
|
195 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryStatesConnection', |
|
196 | + ['EEM_State' => EE_Dependency_Map::load_from_cache] |
|
197 | + ); |
|
198 | + $this->dependency_map->registerDependencies( |
|
199 | + 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection', |
|
200 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
201 | + ); |
|
202 | + $this->dependency_map->registerDependencies( |
|
203 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection', |
|
204 | + ['EEM_Ticket' => EE_Dependency_Map::load_from_cache] |
|
205 | + ); |
|
206 | + $this->dependency_map->registerDependencies( |
|
207 | + 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection', |
|
208 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
209 | + ); |
|
210 | + $this->dependency_map->registerDependencies( |
|
211 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection', |
|
212 | + ['EEM_Price' => EE_Dependency_Map::load_from_cache] |
|
213 | + ); |
|
214 | + $this->dependency_map->registerDependencies( |
|
215 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection', |
|
216 | + ['EEM_Price_Type' => EE_Dependency_Map::load_from_cache] |
|
217 | + ); |
|
218 | + $this->dependency_map->registerDependencies( |
|
219 | + 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection', |
|
220 | + ['EEM_Datetime' => EE_Dependency_Map::load_from_cache] |
|
221 | + ); |
|
222 | + $this->dependency_map->registerDependencies( |
|
223 | + 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection', |
|
224 | + ['EEM_Venue' => EE_Dependency_Map::load_from_cache] |
|
225 | + ); |
|
226 | + } |
|
227 | 227 | |
228 | 228 | |
229 | - /** |
|
230 | - * implements logic required to run during request |
|
231 | - * |
|
232 | - * @return bool |
|
233 | - * @since $VID:$ |
|
234 | - */ |
|
235 | - protected function requestHandler(): bool |
|
236 | - { |
|
237 | - if (! class_exists('WPGraphQL')) { |
|
238 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
239 | - } |
|
240 | - // load handler for EE GraphQL requests |
|
241 | - $graphQL_manager = $this->loader->getShared( |
|
242 | - 'EventEspresso\core\services\graphql\GraphQLManager' |
|
243 | - ); |
|
244 | - $graphQL_manager->init(); |
|
245 | - $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain()); |
|
246 | - $manifest->initialize(); |
|
247 | - return true; |
|
248 | - } |
|
229 | + /** |
|
230 | + * implements logic required to run during request |
|
231 | + * |
|
232 | + * @return bool |
|
233 | + * @since $VID:$ |
|
234 | + */ |
|
235 | + protected function requestHandler(): bool |
|
236 | + { |
|
237 | + if (! class_exists('WPGraphQL')) { |
|
238 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
239 | + } |
|
240 | + // load handler for EE GraphQL requests |
|
241 | + $graphQL_manager = $this->loader->getShared( |
|
242 | + 'EventEspresso\core\services\graphql\GraphQLManager' |
|
243 | + ); |
|
244 | + $graphQL_manager->init(); |
|
245 | + $manifest = $this->manifest_factory->createFromDomainObject(DomainFactory::getEventEspressoCoreDomain()); |
|
246 | + $manifest->initialize(); |
|
247 | + return true; |
|
248 | + } |
|
249 | 249 | } |