@@ -15,18 +15,18 @@ |
||
15 | 15 | */ |
16 | 16 | class WordPressPluginsPageAssetManager extends ReactAssetManager |
17 | 17 | { |
18 | - const DOMAIN = 'wpPluginsPage'; |
|
18 | + const DOMAIN = 'wpPluginsPage'; |
|
19 | 19 | |
20 | - const ASSET_HANDLE_WP_PLUGINS_PAGE = Domain::ASSET_NAMESPACE . '-' . WordPressPluginsPageAssetManager::DOMAIN; |
|
20 | + const ASSET_HANDLE_WP_PLUGINS_PAGE = Domain::ASSET_NAMESPACE . '-' . WordPressPluginsPageAssetManager::DOMAIN; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @throws DomainException |
|
24 | - */ |
|
25 | - public function enqueueAssets() |
|
26 | - { |
|
27 | - if ($this->verifyAssetIsRegistered(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE)) { |
|
28 | - wp_enqueue_script(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE); |
|
29 | - wp_enqueue_style(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE); |
|
30 | - } |
|
31 | - } |
|
22 | + /** |
|
23 | + * @throws DomainException |
|
24 | + */ |
|
25 | + public function enqueueAssets() |
|
26 | + { |
|
27 | + if ($this->verifyAssetIsRegistered(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE)) { |
|
28 | + wp_enqueue_script(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE); |
|
29 | + wp_enqueue_style(WordPressPluginsPageAssetManager::ASSET_HANDLE_WP_PLUGINS_PAGE); |
|
30 | + } |
|
31 | + } |
|
32 | 32 | } |
@@ -17,7 +17,7 @@ |
||
17 | 17 | { |
18 | 18 | const DOMAIN = 'wpPluginsPage'; |
19 | 19 | |
20 | - const ASSET_HANDLE_WP_PLUGINS_PAGE = Domain::ASSET_NAMESPACE . '-' . WordPressPluginsPageAssetManager::DOMAIN; |
|
20 | + const ASSET_HANDLE_WP_PLUGINS_PAGE = Domain::ASSET_NAMESPACE.'-'.WordPressPluginsPageAssetManager::DOMAIN; |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * @throws DomainException |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | { |
77 | 77 | $setterOrGetter = $this->convertCase($property, $getter); |
78 | 78 | // if not a getter, prepend with "set". ex: Show_expired => setShowExpired |
79 | - $setterOrGetter = ! $getter ? 'set' . $setterOrGetter : $setterOrGetter; |
|
79 | + $setterOrGetter = ! $getter ? 'set'.$setterOrGetter : $setterOrGetter; |
|
80 | 80 | return $this->isValidMethod($setterOrGetter) ? $setterOrGetter : ''; |
81 | 81 | } |
82 | 82 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | // convert to PascalCase and prepend with "set". ex: show_expired => setShowExpired |
127 | 127 | $setter = $this->createGetterSetter($property, false); |
128 | - $value = array_key_exists($property, $config) ? $config[ $property ] : null; |
|
128 | + $value = array_key_exists($property, $config) ? $config[$property] : null; |
|
129 | 129 | $this->{$setter}($value); |
130 | 130 | } |
131 | 131 | } |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | continue; |
195 | 195 | } |
196 | 196 | $getter = $this->createGetterSetter($property); |
197 | - $config[ $property ] = $this->{$getter}(); |
|
197 | + $config[$property] = $this->{$getter}(); |
|
198 | 198 | } |
199 | 199 | $config = wp_json_encode($config); |
200 | 200 | if ($config_exists) { |
@@ -16,191 +16,191 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class JsonConfig |
18 | 18 | { |
19 | - /** |
|
20 | - * @var boolean $has_changes |
|
21 | - */ |
|
22 | - private $has_changes = false; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var string $option_name |
|
26 | - */ |
|
27 | - private $option_name; |
|
28 | - |
|
29 | - |
|
30 | - /** |
|
31 | - * SettingsConfig constructor. |
|
32 | - * |
|
33 | - * @param array $defaults |
|
34 | - */ |
|
35 | - public function __construct(array $defaults) |
|
36 | - { |
|
37 | - $this->setOptionName(); |
|
38 | - $this->load($defaults); |
|
39 | - $this->clearChanges(); |
|
40 | - } |
|
41 | - |
|
42 | - |
|
43 | - /** |
|
44 | - * @return array |
|
45 | - */ |
|
46 | - abstract protected function getProperties(); |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * converts property name to: |
|
51 | - * camelCase for getters ex: show_expired => showExpired |
|
52 | - * PascalCase for setters ex: show_expired => ShowExpired |
|
53 | - * |
|
54 | - * @param string $string |
|
55 | - * @param false $camelCase |
|
56 | - * @return string|string[] |
|
57 | - * @since 5.0.0.p |
|
58 | - */ |
|
59 | - private function convertCase($string, $camelCase = false) |
|
60 | - { |
|
61 | - $string = str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); |
|
62 | - if ($camelCase) { |
|
63 | - $string = lcfirst($string); |
|
64 | - } |
|
65 | - return $string; |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - /** |
|
70 | - * @param string $property |
|
71 | - * @param bool $getter |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - private function createGetterSetter($property, $getter = true) |
|
75 | - { |
|
76 | - $setterOrGetter = $this->convertCase($property, $getter); |
|
77 | - // if not a getter, prepend with "set". ex: Show_expired => setShowExpired |
|
78 | - $setterOrGetter = ! $getter ? 'set' . $setterOrGetter : $setterOrGetter; |
|
79 | - return $this->isValidMethod($setterOrGetter) ? $setterOrGetter : ''; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @param string $method |
|
85 | - * @return bool |
|
86 | - * @throws DomainException |
|
87 | - */ |
|
88 | - private function isValidMethod($method) |
|
89 | - { |
|
90 | - if (method_exists($this, $method)) { |
|
91 | - return true; |
|
92 | - } |
|
93 | - throw new DomainException( |
|
94 | - sprintf( |
|
95 | - esc_html__('Missing %1$s method on JsonConfig class %2$s.', 'event_espresso'), |
|
96 | - $method, |
|
97 | - get_class($this) |
|
98 | - ) |
|
99 | - ); |
|
100 | - } |
|
101 | - |
|
102 | - |
|
103 | - /** |
|
104 | - * converts class name to option name by changing backslashes to dashes |
|
105 | - */ |
|
106 | - private function setOptionName() |
|
107 | - { |
|
108 | - $this->option_name = str_replace(['EventEspresso', '\\'], ['ee', '-'], get_class($this)); |
|
109 | - } |
|
110 | - |
|
111 | - |
|
112 | - /** |
|
113 | - * retrieves WP option for class, decodes the data, and resigns values to properties |
|
114 | - * |
|
115 | - * @param array $defaults |
|
116 | - */ |
|
117 | - protected function load(array $defaults) |
|
118 | - { |
|
119 | - $config = get_option($this->option_name, '{}'); |
|
120 | - $config = (array) json_decode($config) + $defaults; |
|
121 | - foreach ($this->getProperties() as $property => $value) { |
|
122 | - if ($property === 'option_name') { |
|
123 | - continue; |
|
124 | - } |
|
125 | - // convert to PascalCase and prepend with "set". ex: show_expired => setShowExpired |
|
126 | - $setter = $this->createGetterSetter($property, false); |
|
127 | - $value = array_key_exists($property, $config) ? $config[ $property ] : null; |
|
128 | - $this->{$setter}($value); |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - |
|
133 | - /** |
|
134 | - * updates property value and marks changes if property value has changed |
|
135 | - * |
|
136 | - * @param string $property |
|
137 | - * @param mixed $value |
|
138 | - */ |
|
139 | - protected function setProperty($property, $value) |
|
140 | - { |
|
141 | - $this->markChanges($this->{$property} === $value); |
|
142 | - $this->{$property} = $value; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * will only toggle has_changes to true otherwise keeps existing value (ie: will never toggle to false) |
|
148 | - * why? this allows this method to be fed with the result of a conditional |
|
149 | - * that compares an incoming value in a setter with it's previously set value. |
|
150 | - * ie: if $x = 1 and you call setX(1) then the value has not really changed. |
|
151 | - * |
|
152 | - * @param bool $changes |
|
153 | - * @since 5.0.0.p |
|
154 | - */ |
|
155 | - protected function markChanges($changes = true) |
|
156 | - { |
|
157 | - $this->has_changes = filter_var($changes, FILTER_VALIDATE_BOOLEAN) ? true : $this->has_changes; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * resets $has_changes flag to false but does NOT actually reset any data |
|
163 | - */ |
|
164 | - public function clearChanges() |
|
165 | - { |
|
166 | - $this->has_changes = false; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * flag for marking that changes have been made to property data |
|
172 | - * |
|
173 | - * @return bool |
|
174 | - */ |
|
175 | - public function hasChanges() |
|
176 | - { |
|
177 | - return $this->has_changes; |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - /** |
|
182 | - * encodes all property data to JSON and saves it to a WP option |
|
183 | - */ |
|
184 | - public function update() |
|
185 | - { |
|
186 | - $config_exists = get_option($this->option_name); |
|
187 | - if ($config_exists && ! $this->has_changes) { |
|
188 | - return; |
|
189 | - } |
|
190 | - $config = []; |
|
191 | - foreach ($this->getProperties() as $property => $value) { |
|
192 | - if ($property === 'option_name') { |
|
193 | - continue; |
|
194 | - } |
|
195 | - $getter = $this->createGetterSetter($property); |
|
196 | - $config[ $property ] = $this->{$getter}(); |
|
197 | - } |
|
198 | - $config = wp_json_encode($config); |
|
199 | - if ($config_exists) { |
|
200 | - update_option($this->option_name, $config); |
|
201 | - } else { |
|
202 | - add_option($this->option_name, $config, '', 'no'); |
|
203 | - } |
|
204 | - $this->clearChanges(); |
|
205 | - } |
|
19 | + /** |
|
20 | + * @var boolean $has_changes |
|
21 | + */ |
|
22 | + private $has_changes = false; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var string $option_name |
|
26 | + */ |
|
27 | + private $option_name; |
|
28 | + |
|
29 | + |
|
30 | + /** |
|
31 | + * SettingsConfig constructor. |
|
32 | + * |
|
33 | + * @param array $defaults |
|
34 | + */ |
|
35 | + public function __construct(array $defaults) |
|
36 | + { |
|
37 | + $this->setOptionName(); |
|
38 | + $this->load($defaults); |
|
39 | + $this->clearChanges(); |
|
40 | + } |
|
41 | + |
|
42 | + |
|
43 | + /** |
|
44 | + * @return array |
|
45 | + */ |
|
46 | + abstract protected function getProperties(); |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * converts property name to: |
|
51 | + * camelCase for getters ex: show_expired => showExpired |
|
52 | + * PascalCase for setters ex: show_expired => ShowExpired |
|
53 | + * |
|
54 | + * @param string $string |
|
55 | + * @param false $camelCase |
|
56 | + * @return string|string[] |
|
57 | + * @since 5.0.0.p |
|
58 | + */ |
|
59 | + private function convertCase($string, $camelCase = false) |
|
60 | + { |
|
61 | + $string = str_replace(' ', '', ucwords(str_replace('_', ' ', $string))); |
|
62 | + if ($camelCase) { |
|
63 | + $string = lcfirst($string); |
|
64 | + } |
|
65 | + return $string; |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + /** |
|
70 | + * @param string $property |
|
71 | + * @param bool $getter |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + private function createGetterSetter($property, $getter = true) |
|
75 | + { |
|
76 | + $setterOrGetter = $this->convertCase($property, $getter); |
|
77 | + // if not a getter, prepend with "set". ex: Show_expired => setShowExpired |
|
78 | + $setterOrGetter = ! $getter ? 'set' . $setterOrGetter : $setterOrGetter; |
|
79 | + return $this->isValidMethod($setterOrGetter) ? $setterOrGetter : ''; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @param string $method |
|
85 | + * @return bool |
|
86 | + * @throws DomainException |
|
87 | + */ |
|
88 | + private function isValidMethod($method) |
|
89 | + { |
|
90 | + if (method_exists($this, $method)) { |
|
91 | + return true; |
|
92 | + } |
|
93 | + throw new DomainException( |
|
94 | + sprintf( |
|
95 | + esc_html__('Missing %1$s method on JsonConfig class %2$s.', 'event_espresso'), |
|
96 | + $method, |
|
97 | + get_class($this) |
|
98 | + ) |
|
99 | + ); |
|
100 | + } |
|
101 | + |
|
102 | + |
|
103 | + /** |
|
104 | + * converts class name to option name by changing backslashes to dashes |
|
105 | + */ |
|
106 | + private function setOptionName() |
|
107 | + { |
|
108 | + $this->option_name = str_replace(['EventEspresso', '\\'], ['ee', '-'], get_class($this)); |
|
109 | + } |
|
110 | + |
|
111 | + |
|
112 | + /** |
|
113 | + * retrieves WP option for class, decodes the data, and resigns values to properties |
|
114 | + * |
|
115 | + * @param array $defaults |
|
116 | + */ |
|
117 | + protected function load(array $defaults) |
|
118 | + { |
|
119 | + $config = get_option($this->option_name, '{}'); |
|
120 | + $config = (array) json_decode($config) + $defaults; |
|
121 | + foreach ($this->getProperties() as $property => $value) { |
|
122 | + if ($property === 'option_name') { |
|
123 | + continue; |
|
124 | + } |
|
125 | + // convert to PascalCase and prepend with "set". ex: show_expired => setShowExpired |
|
126 | + $setter = $this->createGetterSetter($property, false); |
|
127 | + $value = array_key_exists($property, $config) ? $config[ $property ] : null; |
|
128 | + $this->{$setter}($value); |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + |
|
133 | + /** |
|
134 | + * updates property value and marks changes if property value has changed |
|
135 | + * |
|
136 | + * @param string $property |
|
137 | + * @param mixed $value |
|
138 | + */ |
|
139 | + protected function setProperty($property, $value) |
|
140 | + { |
|
141 | + $this->markChanges($this->{$property} === $value); |
|
142 | + $this->{$property} = $value; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * will only toggle has_changes to true otherwise keeps existing value (ie: will never toggle to false) |
|
148 | + * why? this allows this method to be fed with the result of a conditional |
|
149 | + * that compares an incoming value in a setter with it's previously set value. |
|
150 | + * ie: if $x = 1 and you call setX(1) then the value has not really changed. |
|
151 | + * |
|
152 | + * @param bool $changes |
|
153 | + * @since 5.0.0.p |
|
154 | + */ |
|
155 | + protected function markChanges($changes = true) |
|
156 | + { |
|
157 | + $this->has_changes = filter_var($changes, FILTER_VALIDATE_BOOLEAN) ? true : $this->has_changes; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * resets $has_changes flag to false but does NOT actually reset any data |
|
163 | + */ |
|
164 | + public function clearChanges() |
|
165 | + { |
|
166 | + $this->has_changes = false; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * flag for marking that changes have been made to property data |
|
172 | + * |
|
173 | + * @return bool |
|
174 | + */ |
|
175 | + public function hasChanges() |
|
176 | + { |
|
177 | + return $this->has_changes; |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + /** |
|
182 | + * encodes all property data to JSON and saves it to a WP option |
|
183 | + */ |
|
184 | + public function update() |
|
185 | + { |
|
186 | + $config_exists = get_option($this->option_name); |
|
187 | + if ($config_exists && ! $this->has_changes) { |
|
188 | + return; |
|
189 | + } |
|
190 | + $config = []; |
|
191 | + foreach ($this->getProperties() as $property => $value) { |
|
192 | + if ($property === 'option_name') { |
|
193 | + continue; |
|
194 | + } |
|
195 | + $getter = $this->createGetterSetter($property); |
|
196 | + $config[ $property ] = $this->{$getter}(); |
|
197 | + } |
|
198 | + $config = wp_json_encode($config); |
|
199 | + if ($config_exists) { |
|
200 | + update_option($this->option_name, $config); |
|
201 | + } else { |
|
202 | + add_option($this->option_name, $config, '', 'no'); |
|
203 | + } |
|
204 | + $this->clearChanges(); |
|
205 | + } |
|
206 | 206 | } |
@@ -7,32 +7,32 @@ |
||
7 | 7 | |
8 | 8 | class Capabilities extends JsonDataNode |
9 | 9 | { |
10 | - const NODE_NAME = 'capabilities'; |
|
10 | + const NODE_NAME = 'capabilities'; |
|
11 | 11 | |
12 | 12 | |
13 | - /** |
|
14 | - * @param JsonDataNodeValidator $validator |
|
15 | - */ |
|
16 | - public function __construct(JsonDataNodeValidator $validator) |
|
17 | - { |
|
18 | - parent::__construct($validator); |
|
19 | - $this->setNodeName(Capabilities::NODE_NAME); |
|
20 | - } |
|
13 | + /** |
|
14 | + * @param JsonDataNodeValidator $validator |
|
15 | + */ |
|
16 | + public function __construct(JsonDataNodeValidator $validator) |
|
17 | + { |
|
18 | + parent::__construct($validator); |
|
19 | + $this->setNodeName(Capabilities::NODE_NAME); |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @inheritDoc |
|
25 | - */ |
|
26 | - public function initialize() |
|
27 | - { |
|
28 | - $current_user = wp_get_current_user(); |
|
29 | - $capabilities = []; |
|
30 | - $role_capabilities = $current_user->get_role_caps(); |
|
31 | - foreach ($role_capabilities as $capability => $you_can_do_it) { |
|
32 | - if ($you_can_do_it) { |
|
33 | - $capabilities[] = $capability; |
|
34 | - } |
|
35 | - } |
|
36 | - $this->setDataArray($capabilities); |
|
37 | - } |
|
23 | + /** |
|
24 | + * @inheritDoc |
|
25 | + */ |
|
26 | + public function initialize() |
|
27 | + { |
|
28 | + $current_user = wp_get_current_user(); |
|
29 | + $capabilities = []; |
|
30 | + $role_capabilities = $current_user->get_role_caps(); |
|
31 | + foreach ($role_capabilities as $capability => $you_can_do_it) { |
|
32 | + if ($you_can_do_it) { |
|
33 | + $capabilities[] = $capability; |
|
34 | + } |
|
35 | + } |
|
36 | + $this->setDataArray($capabilities); |
|
37 | + } |
|
38 | 38 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | public function dataArrayEmpty(JsonDataNode $data_node) |
23 | 23 | { |
24 | 24 | $data = $data_node->data(); |
25 | - if (! empty($data)) { |
|
25 | + if ( ! empty($data)) { |
|
26 | 26 | $this->overwriteError($data_node->nodeName(), esc_html__('data array', 'event_espresso')); |
27 | 27 | return false; |
28 | 28 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | */ |
39 | 39 | public function propertyNotSet(array $data, $key, $type = 'key') |
40 | 40 | { |
41 | - if (isset($data[ $key ])) { |
|
41 | + if (isset($data[$key])) { |
|
42 | 42 | $this->overwriteError($key, $type); |
43 | 43 | return false; |
44 | 44 | } |
@@ -13,91 +13,91 @@ |
||
13 | 13 | */ |
14 | 14 | class JsonDataNodeValidator |
15 | 15 | { |
16 | - /** |
|
17 | - * @param JsonDataNode $data_node |
|
18 | - * @return bool returns true if data array is safe to set, false if overwrite will occur |
|
19 | - * @throws DomainException throws exception if WP_DEBUG is true |
|
20 | - */ |
|
21 | - public function dataArrayEmpty(JsonDataNode $data_node) |
|
22 | - { |
|
23 | - $data = $data_node->data(); |
|
24 | - if (! empty($data)) { |
|
25 | - $this->overwriteError($data_node->nodeName(), esc_html__('data array', 'event_espresso')); |
|
26 | - return false; |
|
27 | - } |
|
28 | - return true; |
|
29 | - } |
|
16 | + /** |
|
17 | + * @param JsonDataNode $data_node |
|
18 | + * @return bool returns true if data array is safe to set, false if overwrite will occur |
|
19 | + * @throws DomainException throws exception if WP_DEBUG is true |
|
20 | + */ |
|
21 | + public function dataArrayEmpty(JsonDataNode $data_node) |
|
22 | + { |
|
23 | + $data = $data_node->data(); |
|
24 | + if (! empty($data)) { |
|
25 | + $this->overwriteError($data_node->nodeName(), esc_html__('data array', 'event_espresso')); |
|
26 | + return false; |
|
27 | + } |
|
28 | + return true; |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @param array $data data array to check for property key |
|
33 | - * @param string $key value for the key being checked for |
|
34 | - * @param string $type the type of key and/or the data being checked |
|
35 | - * @return bool returns true if property is safe to write, false if overwrite will occur |
|
36 | - * @throws DomainException throws exception if WP_DEBUG is true |
|
37 | - */ |
|
38 | - public function propertyNotSet(array $data, $key, $type = 'key') |
|
39 | - { |
|
40 | - if (isset($data[ $key ])) { |
|
41 | - $this->overwriteError($key, $type); |
|
42 | - return false; |
|
43 | - } |
|
44 | - return true; |
|
45 | - } |
|
31 | + /** |
|
32 | + * @param array $data data array to check for property key |
|
33 | + * @param string $key value for the key being checked for |
|
34 | + * @param string $type the type of key and/or the data being checked |
|
35 | + * @return bool returns true if property is safe to write, false if overwrite will occur |
|
36 | + * @throws DomainException throws exception if WP_DEBUG is true |
|
37 | + */ |
|
38 | + public function propertyNotSet(array $data, $key, $type = 'key') |
|
39 | + { |
|
40 | + if (isset($data[ $key ])) { |
|
41 | + $this->overwriteError($key, $type); |
|
42 | + return false; |
|
43 | + } |
|
44 | + return true; |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param string $key value for the key being checked for |
|
50 | - * @param string $type the type of key and/or the data being checked |
|
51 | - * @throws DomainException throws exception if WP_DEBUG is true |
|
52 | - */ |
|
53 | - public function overwriteError($key, $type) |
|
54 | - { |
|
55 | - if (WP_DEBUG) { |
|
56 | - throw new DomainException( |
|
57 | - sprintf( |
|
58 | - /* |
|
48 | + /** |
|
49 | + * @param string $key value for the key being checked for |
|
50 | + * @param string $type the type of key and/or the data being checked |
|
51 | + * @throws DomainException throws exception if WP_DEBUG is true |
|
52 | + */ |
|
53 | + public function overwriteError($key, $type) |
|
54 | + { |
|
55 | + if (WP_DEBUG) { |
|
56 | + throw new DomainException( |
|
57 | + sprintf( |
|
58 | + /* |
|
59 | 59 | * translators: |
60 | 60 | * 'The "i18n" JsonDataNode key is already set and would be overwritten by the current action.' |
61 | 61 | */ |
62 | - esc_html__( |
|
63 | - 'The "%1$s" JsonDataNode %2$s is already set and would be overwritten by the current action.', |
|
64 | - 'event_espresso' |
|
65 | - ), |
|
66 | - $key, |
|
67 | - $type |
|
68 | - ) |
|
69 | - ); |
|
70 | - } |
|
71 | - } |
|
62 | + esc_html__( |
|
63 | + 'The "%1$s" JsonDataNode %2$s is already set and would be overwritten by the current action.', |
|
64 | + 'event_espresso' |
|
65 | + ), |
|
66 | + $key, |
|
67 | + $type |
|
68 | + ) |
|
69 | + ); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @param string $property name for the key being checked for |
|
76 | - * @param string $type the type of key and/or the data being checked |
|
77 | - * @param bool $throw if true [default] and WP_DEBUG is also true, then will throw exceptions |
|
78 | - * @return bool returns true if property is set, false if property is missing |
|
79 | - * @throws DomainException throws exception if WP_DEBUG is true |
|
80 | - */ |
|
81 | - public function validateCriticalProperty($property, $type, $throw = true) |
|
82 | - { |
|
83 | - if (empty($property)) { |
|
84 | - if (WP_DEBUG && $throw) { |
|
85 | - throw new DomainException( |
|
86 | - sprintf( |
|
87 | - /* |
|
74 | + /** |
|
75 | + * @param string $property name for the key being checked for |
|
76 | + * @param string $type the type of key and/or the data being checked |
|
77 | + * @param bool $throw if true [default] and WP_DEBUG is also true, then will throw exceptions |
|
78 | + * @return bool returns true if property is set, false if property is missing |
|
79 | + * @throws DomainException throws exception if WP_DEBUG is true |
|
80 | + */ |
|
81 | + public function validateCriticalProperty($property, $type, $throw = true) |
|
82 | + { |
|
83 | + if (empty($property)) { |
|
84 | + if (WP_DEBUG && $throw) { |
|
85 | + throw new DomainException( |
|
86 | + sprintf( |
|
87 | + /* |
|
88 | 88 | * translators: |
89 | 89 | * 'The JsonDataNodeHandler domain route is a required property but has not been set.' |
90 | 90 | */ |
91 | - esc_html__( |
|
92 | - 'The JsonDataNodeHandler %1$s is a required property but has not been set.', |
|
93 | - 'event_espresso' |
|
94 | - ), |
|
95 | - $type |
|
96 | - ) |
|
97 | - ); |
|
98 | - } |
|
99 | - return false; |
|
100 | - } |
|
101 | - return true; |
|
102 | - } |
|
91 | + esc_html__( |
|
92 | + 'The JsonDataNodeHandler %1$s is a required property but has not been set.', |
|
93 | + 'event_espresso' |
|
94 | + ), |
|
95 | + $type |
|
96 | + ) |
|
97 | + ); |
|
98 | + } |
|
99 | + return false; |
|
100 | + } |
|
101 | + return true; |
|
102 | + } |
|
103 | 103 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
80 | 80 | */ |
81 | 81 | $input_fields = []; |
82 | - if (! empty($this->args['where'])) { |
|
82 | + if ( ! empty($this->args['where'])) { |
|
83 | 83 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
84 | 84 | |
85 | 85 | // Since we do not have any falsy values in query params |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | $input_fields = array_filter($input_fields); |
88 | 88 | |
89 | 89 | // Use the proper operator. |
90 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
90 | + if ( ! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
91 | 91 | $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
92 | 92 | } |
93 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
93 | + if ( ! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
94 | 94 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
95 | 95 | } |
96 | 96 | // If Ticket param is passed, it will have preference over Datetime param |
97 | 97 | // So, use Datetime param only if a Ticket param is not passed |
98 | - if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
98 | + if ( ! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
99 | 99 | $datetimeIds = $input_fields['Datetime.DTT_ID']; |
100 | 100 | // Make sure it's an array, ready for "IN" operator |
101 | 101 | $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $ticketIds = []; |
114 | 114 | } |
115 | 115 | |
116 | - if (!empty($ticketIds)) { |
|
116 | + if ( ! empty($ticketIds)) { |
|
117 | 117 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
118 | 118 | } |
119 | 119 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Merge the input_fields with the default query_args |
126 | 126 | */ |
127 | - if (! empty($input_fields)) { |
|
127 | + if ( ! empty($input_fields)) { |
|
128 | 128 | $where_params = array_merge($where_params, $input_fields); |
129 | 129 | } |
130 | 130 | |
@@ -132,12 +132,12 @@ discard block |
||
132 | 132 | |
133 | 133 | $search = $this->getSearchKeywords($this->args['where']); |
134 | 134 | |
135 | - if (! empty($search)) { |
|
135 | + if ( ! empty($search)) { |
|
136 | 136 | // use OR operator to search in any of the fields |
137 | 137 | $where_params['OR'] = array( |
138 | - 'ATT_full_name' => array('LIKE', '%' . $search . '%'), |
|
139 | - 'ATT_bio' => array('LIKE', '%' . $search . '%'), |
|
140 | - 'ATT_short_bio' => array('LIKE', '%' . $search . '%'), |
|
138 | + 'ATT_full_name' => array('LIKE', '%'.$search.'%'), |
|
139 | + 'ATT_bio' => array('LIKE', '%'.$search.'%'), |
|
140 | + 'ATT_short_bio' => array('LIKE', '%'.$search.'%'), |
|
141 | 141 | ); |
142 | 142 | } |
143 | 143 |
@@ -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 | } |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
79 | 79 | */ |
80 | 80 | $input_fields = []; |
81 | - if (! empty($this->args['where'])) { |
|
81 | + if ( ! empty($this->args['where'])) { |
|
82 | 82 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
83 | 83 | |
84 | 84 | // Use the proper operator. |
85 | - if (! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
85 | + if ( ! empty($input_fields['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
86 | 86 | $input_fields['EVT_ID'] = ['in', $input_fields['EVT_ID']]; |
87 | 87 | } |
88 | - if (! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
88 | + if ( ! empty($input_fields['Ticket.TKT_ID']) && is_array($input_fields['Ticket.TKT_ID'])) { |
|
89 | 89 | $input_fields['Ticket.TKT_ID'] = ['in', $input_fields['Ticket.TKT_ID']]; |
90 | 90 | } |
91 | 91 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | /** |
119 | 119 | * Merge the input_fields with the default query_args |
120 | 120 | */ |
121 | - if (! empty($input_fields)) { |
|
121 | + if ( ! empty($input_fields)) { |
|
122 | 122 | $where_params = array_merge($where_params, $input_fields); |
123 | 123 | } |
124 | 124 | |
@@ -126,22 +126,22 @@ discard block |
||
126 | 126 | |
127 | 127 | $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; |
128 | 128 | |
129 | - if (! empty($search)) { |
|
129 | + if ( ! empty($search)) { |
|
130 | 130 | // use OR operator to search in any of the fields |
131 | 131 | $where_params['OR'] = array( |
132 | - 'DTT_name' => array('LIKE', '%' . $search . '%'), |
|
133 | - 'DTT_description' => array('LIKE', '%' . $search . '%'), |
|
132 | + 'DTT_name' => array('LIKE', '%'.$search.'%'), |
|
133 | + 'DTT_description' => array('LIKE', '%'.$search.'%'), |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | - if (! empty($this->args['where']['upcoming'])) { |
|
137 | + if ( ! empty($this->args['where']['upcoming'])) { |
|
138 | 138 | $where_params['DTT_EVT_start'] = array( |
139 | 139 | '>', |
140 | 140 | EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
141 | 141 | ); |
142 | 142 | } |
143 | 143 | |
144 | - if (! empty($this->args['where']['active'])) { |
|
144 | + if ( ! empty($this->args['where']['active'])) { |
|
145 | 145 | $where_params['DTT_EVT_start'] = array( |
146 | 146 | '<', |
147 | 147 | EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
155 | - if (! empty($this->args['where']['expired'])) { |
|
155 | + if ( ! empty($this->args['where']['expired'])) { |
|
156 | 156 | $where_params['DTT_EVT_end'] = array( |
157 | 157 | '<', |
158 | 158 | EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
@@ -19,193 +19,193 @@ |
||
19 | 19 | */ |
20 | 20 | class DatetimeConnectionResolver extends AbstractConnectionResolver |
21 | 21 | { |
22 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
23 | - public function get_loader_name(): string |
|
24 | - { |
|
25 | - return 'espresso_datetime'; |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * @return EEM_Datetime |
|
30 | - * @throws EE_Error |
|
31 | - * @throws InvalidArgumentException |
|
32 | - * @throws InvalidDataTypeException |
|
33 | - * @throws InvalidInterfaceException |
|
34 | - * @throws ReflectionException |
|
35 | - */ |
|
36 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
37 | - public function get_query(): EEM_Datetime |
|
38 | - { |
|
39 | - return EEM_Datetime::instance(); |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Return an array of item IDs from the query |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
48 | - public function get_ids(): array |
|
49 | - { |
|
50 | - $results = $this->query->get_col($this->query_args); |
|
51 | - |
|
52 | - return ! empty($results) ? $results : []; |
|
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 InvalidDataTypeException |
|
64 | - * @throws InvalidInterfaceException |
|
65 | - * @throws ReflectionException |
|
66 | - */ |
|
67 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | - public function get_query_args(): array |
|
69 | - { |
|
70 | - $where_params = ['DTT_deleted' => ['IN', [true, false]]]; |
|
71 | - $query_args = []; |
|
72 | - |
|
73 | - $query_args['limit'] = $this->getLimit(); |
|
74 | - |
|
75 | - // Avoid multiple entries by join. |
|
76 | - $query_args['group_by'] = 'DTT_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['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
89 | - $input_fields['EVT_ID'] = ['in', $input_fields['EVT_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 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
98 | - * |
|
99 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
100 | - * set the query to pull datetimes that belong to that event. |
|
101 | - * We can set more cases for other source types. |
|
102 | - */ |
|
103 | - if (is_object($this->source)) { |
|
104 | - switch (true) { |
|
105 | - // It's surely an event |
|
106 | - case $this->source instanceof Post: |
|
107 | - $where_params['EVT_ID'] = $this->source->ID; |
|
108 | - break; |
|
109 | - case $this->source instanceof EE_Event: |
|
110 | - $where_params['EVT_ID'] = $this->source->ID(); |
|
111 | - break; |
|
112 | - case $this->source instanceof EE_Ticket: |
|
113 | - $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
114 | - break; |
|
115 | - case $this->source instanceof EE_Checkin: |
|
116 | - $where_params['Checkin.CHK_ID'] = $this->source->ID(); |
|
117 | - break; |
|
118 | - } |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * Merge the input_fields with the default query_args |
|
123 | - */ |
|
124 | - if (! empty($input_fields)) { |
|
125 | - $where_params = array_merge($where_params, $input_fields); |
|
126 | - } |
|
127 | - |
|
128 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); |
|
129 | - |
|
130 | - $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; |
|
131 | - |
|
132 | - if (! empty($search)) { |
|
133 | - // use OR operator to search in any of the fields |
|
134 | - $where_params['OR'] = array( |
|
135 | - 'DTT_name' => array('LIKE', '%' . $search . '%'), |
|
136 | - 'DTT_description' => array('LIKE', '%' . $search . '%'), |
|
137 | - ); |
|
138 | - } |
|
139 | - |
|
140 | - if (! empty($this->args['where']['upcoming'])) { |
|
141 | - $where_params['DTT_EVT_start'] = array( |
|
142 | - '>', |
|
143 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
144 | - ); |
|
145 | - } |
|
146 | - |
|
147 | - if (! empty($this->args['where']['active'])) { |
|
148 | - $where_params['DTT_EVT_start'] = array( |
|
149 | - '<', |
|
150 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
151 | - ); |
|
152 | - $where_params['DTT_EVT_end'] = array( |
|
153 | - '>', |
|
154 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
155 | - ); |
|
156 | - } |
|
157 | - |
|
158 | - if (! empty($this->args['where']['expired'])) { |
|
159 | - $where_params['DTT_EVT_end'] = array( |
|
160 | - '<', |
|
161 | - EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
162 | - ); |
|
163 | - } |
|
164 | - |
|
165 | - $where_params = apply_filters( |
|
166 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_where_params', |
|
167 | - $where_params, |
|
168 | - $this->source, |
|
169 | - $this->args |
|
170 | - ); |
|
171 | - |
|
172 | - $query_args[] = $where_params; |
|
173 | - |
|
174 | - /** |
|
175 | - * Return the $query_args |
|
176 | - */ |
|
177 | - return apply_filters( |
|
178 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_query_args', |
|
179 | - $query_args, |
|
180 | - $this->source, |
|
181 | - $this->args |
|
182 | - ); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
188 | - * friendly keys. |
|
189 | - * |
|
190 | - * @param array $where_args |
|
191 | - * @return array |
|
192 | - */ |
|
193 | - public function sanitizeInputFields(array $where_args): array |
|
194 | - { |
|
195 | - $arg_mapping = [ |
|
196 | - 'event' => 'EVT_ID', |
|
197 | - 'eventIn' => 'EVT_ID', |
|
198 | - 'eventId' => 'EVT_ID', |
|
199 | - 'eventIdIn' => 'EVT_ID', |
|
200 | - 'ticket' => 'Ticket.TKT_ID', |
|
201 | - 'ticketIn' => 'Ticket.TKT_ID', |
|
202 | - 'ticketId' => 'Ticket.TKT_ID', |
|
203 | - 'ticketIdIn' => 'Ticket.TKT_ID', |
|
204 | - ]; |
|
205 | - return $this->sanitizeWhereArgsForInputFields( |
|
206 | - $where_args, |
|
207 | - $arg_mapping, |
|
208 | - ['event', 'eventIn', 'ticket', 'ticketIn'] |
|
209 | - ); |
|
210 | - } |
|
22 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
23 | + public function get_loader_name(): string |
|
24 | + { |
|
25 | + return 'espresso_datetime'; |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * @return EEM_Datetime |
|
30 | + * @throws EE_Error |
|
31 | + * @throws InvalidArgumentException |
|
32 | + * @throws InvalidDataTypeException |
|
33 | + * @throws InvalidInterfaceException |
|
34 | + * @throws ReflectionException |
|
35 | + */ |
|
36 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
37 | + public function get_query(): EEM_Datetime |
|
38 | + { |
|
39 | + return EEM_Datetime::instance(); |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Return an array of item IDs from the query |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
48 | + public function get_ids(): array |
|
49 | + { |
|
50 | + $results = $this->query->get_col($this->query_args); |
|
51 | + |
|
52 | + return ! empty($results) ? $results : []; |
|
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 InvalidDataTypeException |
|
64 | + * @throws InvalidInterfaceException |
|
65 | + * @throws ReflectionException |
|
66 | + */ |
|
67 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
68 | + public function get_query_args(): array |
|
69 | + { |
|
70 | + $where_params = ['DTT_deleted' => ['IN', [true, false]]]; |
|
71 | + $query_args = []; |
|
72 | + |
|
73 | + $query_args['limit'] = $this->getLimit(); |
|
74 | + |
|
75 | + // Avoid multiple entries by join. |
|
76 | + $query_args['group_by'] = 'DTT_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['EVT_ID']) && is_array($input_fields['EVT_ID'])) { |
|
89 | + $input_fields['EVT_ID'] = ['in', $input_fields['EVT_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 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
98 | + * |
|
99 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
100 | + * set the query to pull datetimes that belong to that event. |
|
101 | + * We can set more cases for other source types. |
|
102 | + */ |
|
103 | + if (is_object($this->source)) { |
|
104 | + switch (true) { |
|
105 | + // It's surely an event |
|
106 | + case $this->source instanceof Post: |
|
107 | + $where_params['EVT_ID'] = $this->source->ID; |
|
108 | + break; |
|
109 | + case $this->source instanceof EE_Event: |
|
110 | + $where_params['EVT_ID'] = $this->source->ID(); |
|
111 | + break; |
|
112 | + case $this->source instanceof EE_Ticket: |
|
113 | + $where_params['Ticket.TKT_ID'] = $this->source->ID(); |
|
114 | + break; |
|
115 | + case $this->source instanceof EE_Checkin: |
|
116 | + $where_params['Checkin.CHK_ID'] = $this->source->ID(); |
|
117 | + break; |
|
118 | + } |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * Merge the input_fields with the default query_args |
|
123 | + */ |
|
124 | + if (! empty($input_fields)) { |
|
125 | + $where_params = array_merge($where_params, $input_fields); |
|
126 | + } |
|
127 | + |
|
128 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'DTT_ID'); |
|
129 | + |
|
130 | + $search = isset($this->args['where']) ? $this->getSearchKeywords($this->args['where']) : ''; |
|
131 | + |
|
132 | + if (! empty($search)) { |
|
133 | + // use OR operator to search in any of the fields |
|
134 | + $where_params['OR'] = array( |
|
135 | + 'DTT_name' => array('LIKE', '%' . $search . '%'), |
|
136 | + 'DTT_description' => array('LIKE', '%' . $search . '%'), |
|
137 | + ); |
|
138 | + } |
|
139 | + |
|
140 | + if (! empty($this->args['where']['upcoming'])) { |
|
141 | + $where_params['DTT_EVT_start'] = array( |
|
142 | + '>', |
|
143 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
144 | + ); |
|
145 | + } |
|
146 | + |
|
147 | + if (! empty($this->args['where']['active'])) { |
|
148 | + $where_params['DTT_EVT_start'] = array( |
|
149 | + '<', |
|
150 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_start') |
|
151 | + ); |
|
152 | + $where_params['DTT_EVT_end'] = array( |
|
153 | + '>', |
|
154 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
155 | + ); |
|
156 | + } |
|
157 | + |
|
158 | + if (! empty($this->args['where']['expired'])) { |
|
159 | + $where_params['DTT_EVT_end'] = array( |
|
160 | + '<', |
|
161 | + EEM_Datetime::instance()->current_time_for_query('DTT_EVT_end') |
|
162 | + ); |
|
163 | + } |
|
164 | + |
|
165 | + $where_params = apply_filters( |
|
166 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_where_params', |
|
167 | + $where_params, |
|
168 | + $this->source, |
|
169 | + $this->args |
|
170 | + ); |
|
171 | + |
|
172 | + $query_args[] = $where_params; |
|
173 | + |
|
174 | + /** |
|
175 | + * Return the $query_args |
|
176 | + */ |
|
177 | + return apply_filters( |
|
178 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__datetime_query_args', |
|
179 | + $query_args, |
|
180 | + $this->source, |
|
181 | + $this->args |
|
182 | + ); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
188 | + * friendly keys. |
|
189 | + * |
|
190 | + * @param array $where_args |
|
191 | + * @return array |
|
192 | + */ |
|
193 | + public function sanitizeInputFields(array $where_args): array |
|
194 | + { |
|
195 | + $arg_mapping = [ |
|
196 | + 'event' => 'EVT_ID', |
|
197 | + 'eventIn' => 'EVT_ID', |
|
198 | + 'eventId' => 'EVT_ID', |
|
199 | + 'eventIdIn' => 'EVT_ID', |
|
200 | + 'ticket' => 'Ticket.TKT_ID', |
|
201 | + 'ticketIn' => 'Ticket.TKT_ID', |
|
202 | + 'ticketId' => 'Ticket.TKT_ID', |
|
203 | + 'ticketIdIn' => 'Ticket.TKT_ID', |
|
204 | + ]; |
|
205 | + return $this->sanitizeWhereArgsForInputFields( |
|
206 | + $where_args, |
|
207 | + $arg_mapping, |
|
208 | + ['event', 'eventIn', 'ticket', 'ticketIn'] |
|
209 | + ); |
|
210 | + } |
|
211 | 211 | } |
@@ -44,15 +44,15 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected function getQueryResponse(string $field_key, array $where_params = []) |
46 | 46 | { |
47 | - if (! empty($where_params)) { |
|
48 | - if (! array_key_exists('variables', $this->params)) { |
|
47 | + if ( ! empty($where_params)) { |
|
48 | + if ( ! array_key_exists('variables', $this->params)) { |
|
49 | 49 | $this->params['variables'] = []; |
50 | 50 | } |
51 | 51 | $this->params['variables']['where'] = $where_params; |
52 | 52 | } |
53 | 53 | |
54 | 54 | $responseData = $this->makeGraphQLRequest($this->params); |
55 | - return ! empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
55 | + return ! empty($responseData[$field_key]) ? $responseData[$field_key] : null; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $error = ''; |
67 | 67 | try { |
68 | 68 | $response = graphql($data); |
69 | - if (! empty($response['data'])) { |
|
69 | + if ( ! empty($response['data'])) { |
|
70 | 70 | return $response['data']; |
71 | 71 | } |
72 | 72 | $error = ! empty($response['errors']) |
@@ -14,72 +14,72 @@ |
||
14 | 14 | */ |
15 | 15 | abstract class GraphQLData implements GraphQLDataInterface |
16 | 16 | { |
17 | - public const QUERY_LIMIT = 250; |
|
17 | + public const QUERY_LIMIT = 250; |
|
18 | 18 | |
19 | - /** |
|
20 | - * @var string $namespace The graphql namespace/prefix. |
|
21 | - */ |
|
22 | - protected string $namespace = 'Espresso'; |
|
19 | + /** |
|
20 | + * @var string $namespace The graphql namespace/prefix. |
|
21 | + */ |
|
22 | + protected string $namespace = 'Espresso'; |
|
23 | 23 | |
24 | - private array $params = []; |
|
24 | + private array $params = []; |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * @param array $params |
|
29 | - */ |
|
30 | - public function setParams(array $params) |
|
31 | - { |
|
32 | - $this->params = $params; |
|
33 | - } |
|
27 | + /** |
|
28 | + * @param array $params |
|
29 | + */ |
|
30 | + public function setParams(array $params) |
|
31 | + { |
|
32 | + $this->params = $params; |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * @param string $field_key |
|
38 | - * @param array $where_params |
|
39 | - * @return mixed|null |
|
40 | - * @since 5.0.0.p |
|
41 | - */ |
|
42 | - protected function getQueryResponse(string $field_key, array $where_params = []) |
|
43 | - { |
|
44 | - if (! empty($where_params)) { |
|
45 | - if (! array_key_exists('variables', $this->params)) { |
|
46 | - $this->params['variables'] = []; |
|
47 | - } |
|
48 | - $this->params['variables']['where'] = $where_params; |
|
49 | - } |
|
36 | + /** |
|
37 | + * @param string $field_key |
|
38 | + * @param array $where_params |
|
39 | + * @return mixed|null |
|
40 | + * @since 5.0.0.p |
|
41 | + */ |
|
42 | + protected function getQueryResponse(string $field_key, array $where_params = []) |
|
43 | + { |
|
44 | + if (! empty($where_params)) { |
|
45 | + if (! array_key_exists('variables', $this->params)) { |
|
46 | + $this->params['variables'] = []; |
|
47 | + } |
|
48 | + $this->params['variables']['where'] = $where_params; |
|
49 | + } |
|
50 | 50 | |
51 | - $responseData = $this->makeGraphQLRequest($this->params); |
|
52 | - return ! empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
53 | - } |
|
51 | + $responseData = $this->makeGraphQLRequest($this->params); |
|
52 | + return ! empty($responseData[ $field_key ]) ? $responseData[ $field_key ] : null; |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * @param array $data |
|
58 | - * @return array|null |
|
59 | - * @since 5.0.0.p |
|
60 | - */ |
|
61 | - protected function makeGraphQLRequest(array $data): ?array |
|
62 | - { |
|
63 | - $error = ''; |
|
64 | - try { |
|
65 | - $response = graphql($data); |
|
66 | - if (! empty($response['data'])) { |
|
67 | - return $response['data']; |
|
68 | - } |
|
69 | - $error = ! empty($response['errors']) |
|
70 | - ? print_r($response['errors'], true) |
|
71 | - : esc_html__( |
|
72 | - 'An unknown error has occurred during the GraphQL request and no data was found to return.', |
|
73 | - 'event_espresso' |
|
74 | - ); |
|
75 | - } catch (Exception $e) { |
|
76 | - if (defined('GRAPHQL_DEBUG') && GRAPHQL_DEBUG) { |
|
77 | - $error = $e->getMessage(); |
|
78 | - } |
|
79 | - } |
|
80 | - if ($error !== '') { |
|
81 | - error_log($error); |
|
82 | - } |
|
83 | - return null; |
|
84 | - } |
|
56 | + /** |
|
57 | + * @param array $data |
|
58 | + * @return array|null |
|
59 | + * @since 5.0.0.p |
|
60 | + */ |
|
61 | + protected function makeGraphQLRequest(array $data): ?array |
|
62 | + { |
|
63 | + $error = ''; |
|
64 | + try { |
|
65 | + $response = graphql($data); |
|
66 | + if (! empty($response['data'])) { |
|
67 | + return $response['data']; |
|
68 | + } |
|
69 | + $error = ! empty($response['errors']) |
|
70 | + ? print_r($response['errors'], true) |
|
71 | + : esc_html__( |
|
72 | + 'An unknown error has occurred during the GraphQL request and no data was found to return.', |
|
73 | + 'event_espresso' |
|
74 | + ); |
|
75 | + } catch (Exception $e) { |
|
76 | + if (defined('GRAPHQL_DEBUG') && GRAPHQL_DEBUG) { |
|
77 | + $error = $e->getMessage(); |
|
78 | + } |
|
79 | + } |
|
80 | + if ($error !== '') { |
|
81 | + error_log($error); |
|
82 | + } |
|
83 | + return null; |
|
84 | + } |
|
85 | 85 | } |
@@ -4,45 +4,45 @@ |
||
4 | 4 | interface EnqueueAssetsInterface |
5 | 5 | { |
6 | 6 | |
7 | - /** |
|
8 | - * a place to register scripts and stylesheets with WordPress core |
|
9 | - * IMPORTANT !!! |
|
10 | - * ALL JavaScript files need to be registered for loading in the footer |
|
11 | - * by setting the 5th parameter of wp_register_script() to ` true ` |
|
12 | - * |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - public function registerScriptsAndStylesheets(); |
|
7 | + /** |
|
8 | + * a place to register scripts and stylesheets with WordPress core |
|
9 | + * IMPORTANT !!! |
|
10 | + * ALL JavaScript files need to be registered for loading in the footer |
|
11 | + * by setting the 5th parameter of wp_register_script() to ` true ` |
|
12 | + * |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + public function registerScriptsAndStylesheets(); |
|
16 | 16 | |
17 | - /** |
|
18 | - * a place to enqueue previously registered stylesheets |
|
19 | - * this will be called during the wp_enqueue_scripts hook for frontend requests |
|
20 | - * |
|
21 | - * @return void |
|
22 | - */ |
|
23 | - public function enqueueStylesheets(); |
|
17 | + /** |
|
18 | + * a place to enqueue previously registered stylesheets |
|
19 | + * this will be called during the wp_enqueue_scripts hook for frontend requests |
|
20 | + * |
|
21 | + * @return void |
|
22 | + */ |
|
23 | + public function enqueueStylesheets(); |
|
24 | 24 | |
25 | - /** |
|
26 | - * a place to enqueue previously registered stylesheets |
|
27 | - * this will be called during the admin_enqueue_scripts hook for admin requests |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function enqueueAdminStylesheets(); |
|
25 | + /** |
|
26 | + * a place to enqueue previously registered stylesheets |
|
27 | + * this will be called during the admin_enqueue_scripts hook for admin requests |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function enqueueAdminStylesheets(); |
|
32 | 32 | |
33 | - /** |
|
34 | - * a place to enqueue previously registered scripts for frontend requests |
|
35 | - * |
|
36 | - * @return void |
|
37 | - */ |
|
38 | - public function enqueueScripts(); |
|
33 | + /** |
|
34 | + * a place to enqueue previously registered scripts for frontend requests |
|
35 | + * |
|
36 | + * @return void |
|
37 | + */ |
|
38 | + public function enqueueScripts(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * a place to enqueue previously registered scripts for admin requests |
|
42 | - * |
|
43 | - * @return void |
|
44 | - */ |
|
45 | - public function enqueueAdminScripts(); |
|
40 | + /** |
|
41 | + * a place to enqueue previously registered scripts for admin requests |
|
42 | + * |
|
43 | + * @return void |
|
44 | + */ |
|
45 | + public function enqueueAdminScripts(); |
|
46 | 46 | } |
47 | 47 | // End of file EnqueueAssetsInterface.php |
48 | 48 | // Location: EventEspresso\core\domain/EnqueueAssetsInterface.php |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | <p><?php esc_html_e('Adjust the settings for the PayPal Pro payment gateway.', 'event_espresso'); ?></p> |
3 | 3 | <p> |
4 | 4 | <?php |
5 | - printf( |
|
6 | - esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'), |
|
7 | - "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>", |
|
8 | - "</a>" |
|
9 | - ); |
|
10 | - ?> |
|
5 | + printf( |
|
6 | + esc_html__('See %1$shere%2$s for list of currencies supported by Paypal Pro.', 'event_espresso'), |
|
7 | + "<a href='https://www.paypal.com/multicurrency' target='_blank' rel='noopener noreferrer'>", |
|
8 | + "</a>" |
|
9 | + ); |
|
10 | + ?> |
|
11 | 11 | </p> |
12 | 12 | <p><strong><?php esc_html_e('PayPal Pro Settings', 'event_espresso'); ?></strong></p> |
13 | 13 | <ul> |
@@ -18,48 +18,48 @@ discard block |
||
18 | 18 | <li> |
19 | 19 | <strong><?php esc_html_e('PayPal API Username', 'event_espresso'); ?></strong><br/> |
20 | 20 | <?php |
21 | - printf( |
|
22 | - esc_html__( |
|
23 | - 'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.', |
|
24 | - 'event_espresso' |
|
25 | - ), |
|
26 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
27 | - '</a>' |
|
28 | - ); |
|
29 | - ?> |
|
21 | + printf( |
|
22 | + esc_html__( |
|
23 | + 'Enter your API Username for PayPal. Learn how to find your %1$sAPI Username%2$s.', |
|
24 | + 'event_espresso' |
|
25 | + ), |
|
26 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
27 | + '</a>' |
|
28 | + ); |
|
29 | + ?> |
|
30 | 30 | </li> |
31 | 31 | <li> |
32 | 32 | <strong><?php esc_html_e('PayPal API Password', 'event_espresso'); ?></strong><br/> |
33 | 33 | <?php |
34 | - printf( |
|
35 | - esc_html__( |
|
36 | - 'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.', |
|
37 | - 'event_espresso' |
|
38 | - ), |
|
39 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
40 | - '</a>' |
|
41 | - ); |
|
42 | - ?> |
|
34 | + printf( |
|
35 | + esc_html__( |
|
36 | + 'Enter your API Password for PayPal. Learn how to find your %1$sAPI Password%2$s.', |
|
37 | + 'event_espresso' |
|
38 | + ), |
|
39 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
40 | + '</a>' |
|
41 | + ); |
|
42 | + ?> |
|
43 | 43 | </li> |
44 | 44 | <li> |
45 | 45 | <strong><?php esc_html_e('PayPal API Signature', 'event_espresso'); ?></strong><br/> |
46 | 46 | <?php |
47 | - printf( |
|
48 | - esc_html__( |
|
49 | - 'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.', |
|
50 | - 'event_espresso' |
|
51 | - ), |
|
52 | - '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
53 | - '</a>' |
|
54 | - ); |
|
55 | - ?> |
|
47 | + printf( |
|
48 | + esc_html__( |
|
49 | + 'Enter your API Signature for PayPal. Learn how to find your %1$sAPI Signature%2$s.', |
|
50 | + 'event_espresso' |
|
51 | + ), |
|
52 | + '<a href="https://www.paypal.com/us/cgi-bin/webscr?cmd=xpt/cps/merchant/wppro/WPProIntegrationSteps-outside#SectionB" target="_blank" rel="noopener noreferrer">', |
|
53 | + '</a>' |
|
54 | + ); |
|
55 | + ?> |
|
56 | 56 | </li> |
57 | 57 | <li> |
58 | 58 | <strong><?php esc_html_e('Country Currency', 'event_espresso'); ?></strong><br/> |
59 | 59 | <?php esc_html_e( |
60 | - 'Select the currency for your country. Payments will be accepted in this currency.', |
|
61 | - 'event_espresso' |
|
62 | - ); ?> |
|
60 | + 'Select the currency for your country. Payments will be accepted in this currency.', |
|
61 | + 'event_espresso' |
|
62 | + ); ?> |
|
63 | 63 | </li> |
64 | 64 | <li> |
65 | 65 | <strong><?php esc_html_e('Accepted Card Types', 'event_espresso'); ?></strong><br/> |
@@ -68,9 +68,9 @@ discard block |
||
68 | 68 | <li> |
69 | 69 | <strong><?php esc_html_e('Use the Debugging Feature and the PayPal Sandbox', 'event_espresso'); ?></strong><br/> |
70 | 70 | <?php esc_html_e( |
71 | - 'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.', |
|
72 | - 'event_espresso' |
|
73 | - ); ?> |
|
71 | + 'Specify if you want to test the payment gateway by submitting a test transaction. If this option is enabled, be sure to enter your PayPal sandbox credentials in the fields above. Be sure to turn this setting off when you are done testing.', |
|
72 | + 'event_espresso' |
|
73 | + ); ?> |
|
74 | 74 | </li> |
75 | 75 | <li> |
76 | 76 | <strong><?php esc_html_e('Button Image URL', 'event_espresso'); ?></strong><br/> |