@@ -16,76 +16,76 @@ |
||
16 | 16 | class GraphQLManager implements GQLManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var ConnectionsManager $connections_manager |
|
21 | - */ |
|
22 | - protected $connections_manager; |
|
19 | + /** |
|
20 | + * @var ConnectionsManager $connections_manager |
|
21 | + */ |
|
22 | + protected $connections_manager; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @var DataLoaderManager $data_loader_manager |
|
26 | - */ |
|
27 | - protected $data_loader_manager; |
|
24 | + /** |
|
25 | + * @var DataLoaderManager $data_loader_manager |
|
26 | + */ |
|
27 | + protected $data_loader_manager; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @var EnumsManager $enums_manager |
|
31 | - */ |
|
32 | - protected $enums_manager; |
|
29 | + /** |
|
30 | + * @var EnumsManager $enums_manager |
|
31 | + */ |
|
32 | + protected $enums_manager; |
|
33 | 33 | |
34 | - /** |
|
35 | - * @var InputsManager $inputs_manager |
|
36 | - */ |
|
37 | - protected $inputs_manager; |
|
34 | + /** |
|
35 | + * @var InputsManager $inputs_manager |
|
36 | + */ |
|
37 | + protected $inputs_manager; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @var TypesManager $types_manager |
|
41 | - */ |
|
42 | - protected $types_manager; |
|
39 | + /** |
|
40 | + * @var TypesManager $types_manager |
|
41 | + */ |
|
42 | + protected $types_manager; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var boolean $initialized |
|
46 | - */ |
|
47 | - private $initialized = false; |
|
44 | + /** |
|
45 | + * @var boolean $initialized |
|
46 | + */ |
|
47 | + private $initialized = false; |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * GraphQLManager constructor. |
|
52 | - * |
|
53 | - * @param ConnectionsManager $connections_manager |
|
54 | - * @param DataLoaderManager $data_loader_manager |
|
55 | - * @param EnumsManager $enums_manager |
|
56 | - * @param InputsManager $inputs_manager |
|
57 | - * @param TypesManager $types_manager |
|
58 | - */ |
|
59 | - public function __construct( |
|
60 | - ConnectionsManager $connections_manager, |
|
61 | - DataLoaderManager $data_loader_manager, |
|
62 | - EnumsManager $enums_manager, |
|
63 | - InputsManager $inputs_manager, |
|
64 | - TypesManager $types_manager |
|
65 | - ) { |
|
66 | - $this->connections_manager = $connections_manager; |
|
67 | - $this->data_loader_manager = $data_loader_manager; |
|
68 | - $this->enums_manager = $enums_manager; |
|
69 | - $this->inputs_manager = $inputs_manager; |
|
70 | - $this->types_manager = $types_manager; |
|
71 | - } |
|
50 | + /** |
|
51 | + * GraphQLManager constructor. |
|
52 | + * |
|
53 | + * @param ConnectionsManager $connections_manager |
|
54 | + * @param DataLoaderManager $data_loader_manager |
|
55 | + * @param EnumsManager $enums_manager |
|
56 | + * @param InputsManager $inputs_manager |
|
57 | + * @param TypesManager $types_manager |
|
58 | + */ |
|
59 | + public function __construct( |
|
60 | + ConnectionsManager $connections_manager, |
|
61 | + DataLoaderManager $data_loader_manager, |
|
62 | + EnumsManager $enums_manager, |
|
63 | + InputsManager $inputs_manager, |
|
64 | + TypesManager $types_manager |
|
65 | + ) { |
|
66 | + $this->connections_manager = $connections_manager; |
|
67 | + $this->data_loader_manager = $data_loader_manager; |
|
68 | + $this->enums_manager = $enums_manager; |
|
69 | + $this->inputs_manager = $inputs_manager; |
|
70 | + $this->types_manager = $types_manager; |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * @throws CollectionDetailsException |
|
76 | - * @throws CollectionLoaderException |
|
77 | - * @since $VID:$ |
|
78 | - */ |
|
79 | - public function init() |
|
80 | - { |
|
81 | - if ($this->initialized) { |
|
82 | - return; |
|
83 | - } |
|
84 | - $this->connections_manager->init(); |
|
85 | - $this->data_loader_manager->init(); |
|
86 | - $this->enums_manager->init(); |
|
87 | - $this->inputs_manager->init(); |
|
88 | - $this->types_manager->init(); |
|
89 | - $this->initialized = true; |
|
90 | - } |
|
74 | + /** |
|
75 | + * @throws CollectionDetailsException |
|
76 | + * @throws CollectionLoaderException |
|
77 | + * @since $VID:$ |
|
78 | + */ |
|
79 | + public function init() |
|
80 | + { |
|
81 | + if ($this->initialized) { |
|
82 | + return; |
|
83 | + } |
|
84 | + $this->connections_manager->init(); |
|
85 | + $this->data_loader_manager->init(); |
|
86 | + $this->enums_manager->init(); |
|
87 | + $this->inputs_manager->init(); |
|
88 | + $this->types_manager->init(); |
|
89 | + $this->initialized = true; |
|
90 | + } |
|
91 | 91 | } |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public function setEditorScriptHandle($editor_script_handle) |
61 | 61 | { |
62 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
63 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | + if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
63 | + $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle; |
|
64 | 64 | } |
65 | 65 | $this->editor_script_handle = $editor_script_handle; |
66 | 66 | } |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public function setEditorStyleHandle($editor_style_handle) |
82 | 82 | { |
83 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
84 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
84 | + $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle; |
|
85 | 85 | } |
86 | 86 | $this->editor_style_handle = $editor_style_handle; |
87 | 87 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | public function setScriptHandle($script_handle) |
103 | 103 | { |
104 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
105 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | + if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
105 | + $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle; |
|
106 | 106 | } |
107 | 107 | $this->script_handle = $script_handle; |
108 | 108 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function setStyleHandle($style_handle) |
124 | 124 | { |
125 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
126 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | + if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
126 | + $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle; |
|
127 | 127 | } |
128 | 128 | $this->style_handle = $style_handle; |
129 | 129 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | */ |
155 | 155 | public function addEditorScript($handle, array $dependencies = array()) |
156 | 156 | { |
157 | - if ($this->assets->hasJavascriptAsset($handle)){ |
|
157 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
158 | 158 | return $this->assets->getJavascriptAsset($handle); |
159 | 159 | } |
160 | 160 | $dependencies = array_merge( |
@@ -20,253 +20,253 @@ |
||
20 | 20 | */ |
21 | 21 | abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface |
22 | 22 | { |
23 | - /** |
|
24 | - * @var string $editor_script_handle |
|
25 | - */ |
|
26 | - private $editor_script_handle; |
|
27 | - |
|
28 | - /** |
|
29 | - * @var string $editor_style_handle |
|
30 | - */ |
|
31 | - private $editor_style_handle; |
|
32 | - |
|
33 | - /** |
|
34 | - * @var string $script_handle |
|
35 | - */ |
|
36 | - private $script_handle; |
|
37 | - |
|
38 | - /** |
|
39 | - * @var string $style_handle |
|
40 | - */ |
|
41 | - private $style_handle; |
|
42 | - |
|
43 | - |
|
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function getEditorScriptHandle() |
|
48 | - { |
|
49 | - return $this->editor_script_handle; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $editor_script_handle |
|
55 | - */ |
|
56 | - public function setEditorScriptHandle($editor_script_handle) |
|
57 | - { |
|
58 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
59 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | - } |
|
61 | - $this->editor_script_handle = $editor_script_handle; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getEditorStyleHandle() |
|
69 | - { |
|
70 | - return $this->editor_style_handle; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $editor_style_handle |
|
76 | - */ |
|
77 | - public function setEditorStyleHandle($editor_style_handle) |
|
78 | - { |
|
79 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
80 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | - } |
|
82 | - $this->editor_style_handle = $editor_style_handle; |
|
83 | - } |
|
84 | - |
|
85 | - |
|
86 | - /** |
|
87 | - * @return string |
|
88 | - */ |
|
89 | - public function getScriptHandle() |
|
90 | - { |
|
91 | - return $this->script_handle; |
|
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * @param string $script_handle |
|
97 | - */ |
|
98 | - public function setScriptHandle($script_handle) |
|
99 | - { |
|
100 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
101 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | - } |
|
103 | - $this->script_handle = $script_handle; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function getStyleHandle() |
|
111 | - { |
|
112 | - return $this->style_handle; |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $style_handle |
|
118 | - */ |
|
119 | - public function setStyleHandle($style_handle) |
|
120 | - { |
|
121 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
122 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | - } |
|
124 | - $this->style_handle = $style_handle; |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * @since 4.9.71.p |
|
129 | - * @throws InvalidDataTypeException |
|
130 | - * @throws InvalidEntityException |
|
131 | - * @throws DuplicateCollectionIdentifierException |
|
132 | - */ |
|
133 | - public function addAssets() |
|
134 | - { |
|
135 | - $this->addEditorScript($this->getEditorScriptHandle()); |
|
136 | - // $this->addEditorStyle($this->getEditorStyleHandle()); |
|
137 | - $this->addScript($this->getScriptHandle()); |
|
138 | - // $this->addStyle($this->getStyleHandle()); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - /** |
|
143 | - * @param $handle |
|
144 | - * @param array $dependencies |
|
145 | - * @since 4.9.71.p |
|
146 | - * @return JavascriptAsset |
|
147 | - * @throws InvalidDataTypeException |
|
148 | - * @throws InvalidEntityException |
|
149 | - * @throws DuplicateCollectionIdentifierException |
|
150 | - */ |
|
151 | - public function addEditorScript($handle, array $dependencies = array()) |
|
152 | - { |
|
153 | - if ($this->assets->hasJavascriptAsset($handle)){ |
|
154 | - return $this->assets->getJavascriptAsset($handle); |
|
155 | - } |
|
156 | - $dependencies = array_merge( |
|
157 | - $dependencies, |
|
158 | - ['wp-blocks'] |
|
159 | - ); |
|
160 | - return $this->addJs($handle, $dependencies); |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param $handle |
|
166 | - * @param array $dependencies |
|
167 | - * @since 4.9.71.p |
|
168 | - * @return StylesheetAsset |
|
169 | - * @throws InvalidDataTypeException |
|
170 | - * @throws InvalidEntityException |
|
171 | - * @throws DuplicateCollectionIdentifierException |
|
172 | - */ |
|
173 | - public function addEditorStyle($handle, array $dependencies = array()) |
|
174 | - { |
|
175 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
176 | - return $this->assets->getStylesheetAsset($handle); |
|
177 | - } |
|
178 | - return $this->addCss($handle, $dependencies); |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * @param $handle |
|
184 | - * @param array $dependencies |
|
185 | - * @since 4.9.71.p |
|
186 | - * @return JavascriptAsset |
|
187 | - * @throws InvalidDataTypeException |
|
188 | - * @throws InvalidEntityException |
|
189 | - * @throws DuplicateCollectionIdentifierException |
|
190 | - */ |
|
191 | - public function addScript($handle, array $dependencies = array()) |
|
192 | - { |
|
193 | - if ($this->assets->hasJavascriptAsset($handle)) { |
|
194 | - return $this->assets->getJavascriptAsset($handle); |
|
195 | - } |
|
196 | - return $this->addJs($handle, $dependencies); |
|
197 | - } |
|
198 | - |
|
199 | - |
|
200 | - /** |
|
201 | - * @param $handle |
|
202 | - * @param array $dependencies |
|
203 | - * @since 4.9.71.p |
|
204 | - * @return StylesheetAsset |
|
205 | - * @throws InvalidDataTypeException |
|
206 | - * @throws InvalidEntityException |
|
207 | - * @throws DuplicateCollectionIdentifierException |
|
208 | - */ |
|
209 | - public function addStyle($handle, array $dependencies = array()) |
|
210 | - { |
|
211 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
212 | - return $this->assets->getStylesheetAsset($handle); |
|
213 | - } |
|
214 | - return $this->addCss($handle, $dependencies); |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - /** |
|
219 | - * @return JavascriptAsset|null |
|
220 | - */ |
|
221 | - public function getEditorScript() |
|
222 | - { |
|
223 | - return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @return StylesheetAsset|null |
|
229 | - */ |
|
230 | - public function getEditorStyle() |
|
231 | - { |
|
232 | - return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - /** |
|
237 | - * @return JavascriptAsset|null |
|
238 | - */ |
|
239 | - public function getScript() |
|
240 | - { |
|
241 | - return $this->assets->getJavascriptAsset($this->script_handle); |
|
242 | - } |
|
243 | - |
|
244 | - |
|
245 | - /** |
|
246 | - * @return StylesheetAsset|null |
|
247 | - */ |
|
248 | - public function getStyle() |
|
249 | - { |
|
250 | - return $this->assets->getStylesheetAsset($this->style_handle); |
|
251 | - } |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * @return void |
|
256 | - */ |
|
257 | - public function enqueueAssets() |
|
258 | - { |
|
259 | - $assets = array( |
|
260 | - $this->getEditorScript(), |
|
261 | - $this->getEditorStyle(), |
|
262 | - $this->getScript(), |
|
263 | - $this->getStyle(), |
|
264 | - ); |
|
265 | - foreach ($assets as $asset) { |
|
266 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
267 | - $asset->enqueueAsset(); |
|
268 | - } |
|
269 | - } |
|
270 | - } |
|
23 | + /** |
|
24 | + * @var string $editor_script_handle |
|
25 | + */ |
|
26 | + private $editor_script_handle; |
|
27 | + |
|
28 | + /** |
|
29 | + * @var string $editor_style_handle |
|
30 | + */ |
|
31 | + private $editor_style_handle; |
|
32 | + |
|
33 | + /** |
|
34 | + * @var string $script_handle |
|
35 | + */ |
|
36 | + private $script_handle; |
|
37 | + |
|
38 | + /** |
|
39 | + * @var string $style_handle |
|
40 | + */ |
|
41 | + private $style_handle; |
|
42 | + |
|
43 | + |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function getEditorScriptHandle() |
|
48 | + { |
|
49 | + return $this->editor_script_handle; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $editor_script_handle |
|
55 | + */ |
|
56 | + public function setEditorScriptHandle($editor_script_handle) |
|
57 | + { |
|
58 | + if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
59 | + $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | + } |
|
61 | + $this->editor_script_handle = $editor_script_handle; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getEditorStyleHandle() |
|
69 | + { |
|
70 | + return $this->editor_style_handle; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $editor_style_handle |
|
76 | + */ |
|
77 | + public function setEditorStyleHandle($editor_style_handle) |
|
78 | + { |
|
79 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
80 | + $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | + } |
|
82 | + $this->editor_style_handle = $editor_style_handle; |
|
83 | + } |
|
84 | + |
|
85 | + |
|
86 | + /** |
|
87 | + * @return string |
|
88 | + */ |
|
89 | + public function getScriptHandle() |
|
90 | + { |
|
91 | + return $this->script_handle; |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * @param string $script_handle |
|
97 | + */ |
|
98 | + public function setScriptHandle($script_handle) |
|
99 | + { |
|
100 | + if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
101 | + $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | + } |
|
103 | + $this->script_handle = $script_handle; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function getStyleHandle() |
|
111 | + { |
|
112 | + return $this->style_handle; |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $style_handle |
|
118 | + */ |
|
119 | + public function setStyleHandle($style_handle) |
|
120 | + { |
|
121 | + if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
122 | + $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | + } |
|
124 | + $this->style_handle = $style_handle; |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * @since 4.9.71.p |
|
129 | + * @throws InvalidDataTypeException |
|
130 | + * @throws InvalidEntityException |
|
131 | + * @throws DuplicateCollectionIdentifierException |
|
132 | + */ |
|
133 | + public function addAssets() |
|
134 | + { |
|
135 | + $this->addEditorScript($this->getEditorScriptHandle()); |
|
136 | + // $this->addEditorStyle($this->getEditorStyleHandle()); |
|
137 | + $this->addScript($this->getScriptHandle()); |
|
138 | + // $this->addStyle($this->getStyleHandle()); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + /** |
|
143 | + * @param $handle |
|
144 | + * @param array $dependencies |
|
145 | + * @since 4.9.71.p |
|
146 | + * @return JavascriptAsset |
|
147 | + * @throws InvalidDataTypeException |
|
148 | + * @throws InvalidEntityException |
|
149 | + * @throws DuplicateCollectionIdentifierException |
|
150 | + */ |
|
151 | + public function addEditorScript($handle, array $dependencies = array()) |
|
152 | + { |
|
153 | + if ($this->assets->hasJavascriptAsset($handle)){ |
|
154 | + return $this->assets->getJavascriptAsset($handle); |
|
155 | + } |
|
156 | + $dependencies = array_merge( |
|
157 | + $dependencies, |
|
158 | + ['wp-blocks'] |
|
159 | + ); |
|
160 | + return $this->addJs($handle, $dependencies); |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param $handle |
|
166 | + * @param array $dependencies |
|
167 | + * @since 4.9.71.p |
|
168 | + * @return StylesheetAsset |
|
169 | + * @throws InvalidDataTypeException |
|
170 | + * @throws InvalidEntityException |
|
171 | + * @throws DuplicateCollectionIdentifierException |
|
172 | + */ |
|
173 | + public function addEditorStyle($handle, array $dependencies = array()) |
|
174 | + { |
|
175 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
176 | + return $this->assets->getStylesheetAsset($handle); |
|
177 | + } |
|
178 | + return $this->addCss($handle, $dependencies); |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * @param $handle |
|
184 | + * @param array $dependencies |
|
185 | + * @since 4.9.71.p |
|
186 | + * @return JavascriptAsset |
|
187 | + * @throws InvalidDataTypeException |
|
188 | + * @throws InvalidEntityException |
|
189 | + * @throws DuplicateCollectionIdentifierException |
|
190 | + */ |
|
191 | + public function addScript($handle, array $dependencies = array()) |
|
192 | + { |
|
193 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
194 | + return $this->assets->getJavascriptAsset($handle); |
|
195 | + } |
|
196 | + return $this->addJs($handle, $dependencies); |
|
197 | + } |
|
198 | + |
|
199 | + |
|
200 | + /** |
|
201 | + * @param $handle |
|
202 | + * @param array $dependencies |
|
203 | + * @since 4.9.71.p |
|
204 | + * @return StylesheetAsset |
|
205 | + * @throws InvalidDataTypeException |
|
206 | + * @throws InvalidEntityException |
|
207 | + * @throws DuplicateCollectionIdentifierException |
|
208 | + */ |
|
209 | + public function addStyle($handle, array $dependencies = array()) |
|
210 | + { |
|
211 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
212 | + return $this->assets->getStylesheetAsset($handle); |
|
213 | + } |
|
214 | + return $this->addCss($handle, $dependencies); |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + /** |
|
219 | + * @return JavascriptAsset|null |
|
220 | + */ |
|
221 | + public function getEditorScript() |
|
222 | + { |
|
223 | + return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @return StylesheetAsset|null |
|
229 | + */ |
|
230 | + public function getEditorStyle() |
|
231 | + { |
|
232 | + return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + /** |
|
237 | + * @return JavascriptAsset|null |
|
238 | + */ |
|
239 | + public function getScript() |
|
240 | + { |
|
241 | + return $this->assets->getJavascriptAsset($this->script_handle); |
|
242 | + } |
|
243 | + |
|
244 | + |
|
245 | + /** |
|
246 | + * @return StylesheetAsset|null |
|
247 | + */ |
|
248 | + public function getStyle() |
|
249 | + { |
|
250 | + return $this->assets->getStylesheetAsset($this->style_handle); |
|
251 | + } |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * @return void |
|
256 | + */ |
|
257 | + public function enqueueAssets() |
|
258 | + { |
|
259 | + $assets = array( |
|
260 | + $this->getEditorScript(), |
|
261 | + $this->getEditorStyle(), |
|
262 | + $this->getScript(), |
|
263 | + $this->getStyle(), |
|
264 | + ); |
|
265 | + foreach ($assets as $asset) { |
|
266 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
267 | + $asset->enqueueAsset(); |
|
268 | + } |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | 272 | } |
@@ -17,76 +17,76 @@ |
||
17 | 17 | class RouteCollection extends Collection |
18 | 18 | { |
19 | 19 | |
20 | - const COLLECTION_NAME = 'routes'; |
|
20 | + const COLLECTION_NAME = 'routes'; |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * RouteMatchSpecificationCollection constructor |
|
25 | - * |
|
26 | - * @throws InvalidInterfaceException |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - parent::__construct( |
|
31 | - 'EventEspresso\core\services\routing\RouteInterface', |
|
32 | - RouteCollection::COLLECTION_NAME |
|
33 | - ); |
|
34 | - } |
|
23 | + /** |
|
24 | + * RouteMatchSpecificationCollection constructor |
|
25 | + * |
|
26 | + * @throws InvalidInterfaceException |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + parent::__construct( |
|
31 | + 'EventEspresso\core\services\routing\RouteInterface', |
|
32 | + RouteCollection::COLLECTION_NAME |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * getIdentifier |
|
39 | - * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
40 | - * If no $identifier is supplied, then the fully qualified class name is used |
|
41 | - * |
|
42 | - * @param $object |
|
43 | - * @param mixed $identifier |
|
44 | - * @return bool |
|
45 | - */ |
|
46 | - public function getIdentifier($object, $identifier = null) |
|
47 | - { |
|
48 | - return ! empty($identifier) |
|
49 | - ? $identifier |
|
50 | - : get_class($object); |
|
51 | - } |
|
37 | + /** |
|
38 | + * getIdentifier |
|
39 | + * Overrides EventEspresso\core\services\collections\Collection::getIdentifier() |
|
40 | + * If no $identifier is supplied, then the fully qualified class name is used |
|
41 | + * |
|
42 | + * @param $object |
|
43 | + * @param mixed $identifier |
|
44 | + * @return bool |
|
45 | + */ |
|
46 | + public function getIdentifier($object, $identifier = null) |
|
47 | + { |
|
48 | + return ! empty($identifier) |
|
49 | + ? $identifier |
|
50 | + : get_class($object); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * finds and returns all Routes that have yet to be handled |
|
56 | - * |
|
57 | - * @return RouteInterface[] |
|
58 | - */ |
|
59 | - public function getRoutesForCurrentRequest() |
|
60 | - { |
|
61 | - $routes = []; |
|
62 | - $this->rewind(); |
|
63 | - while ($this->valid()) { |
|
64 | - /** @var RouteInterface $route */ |
|
65 | - $route = $this->current(); |
|
66 | - if ($route->matchesCurrentRequest()) { |
|
67 | - $routes[] = $route; |
|
68 | - } |
|
69 | - $this->next(); |
|
70 | - } |
|
71 | - $this->rewind(); |
|
72 | - return $routes; |
|
73 | - } |
|
54 | + /** |
|
55 | + * finds and returns all Routes that have yet to be handled |
|
56 | + * |
|
57 | + * @return RouteInterface[] |
|
58 | + */ |
|
59 | + public function getRoutesForCurrentRequest() |
|
60 | + { |
|
61 | + $routes = []; |
|
62 | + $this->rewind(); |
|
63 | + while ($this->valid()) { |
|
64 | + /** @var RouteInterface $route */ |
|
65 | + $route = $this->current(); |
|
66 | + if ($route->matchesCurrentRequest()) { |
|
67 | + $routes[] = $route; |
|
68 | + } |
|
69 | + $this->next(); |
|
70 | + } |
|
71 | + $this->rewind(); |
|
72 | + return $routes; |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | - /** |
|
77 | - * calls RouteInterface::handleRequest() on all Routes that |
|
78 | - * - match current request |
|
79 | - * - have yet to be handled |
|
80 | - * |
|
81 | - * @return void |
|
82 | - */ |
|
83 | - public function handleRoutesForCurrentRequest() |
|
84 | - { |
|
85 | - $this->rewind(); |
|
86 | - while ($this->valid()) { |
|
87 | - $this->current()->handleRequest(); |
|
88 | - $this->next(); |
|
89 | - } |
|
90 | - $this->rewind(); |
|
91 | - } |
|
76 | + /** |
|
77 | + * calls RouteInterface::handleRequest() on all Routes that |
|
78 | + * - match current request |
|
79 | + * - have yet to be handled |
|
80 | + * |
|
81 | + * @return void |
|
82 | + */ |
|
83 | + public function handleRoutesForCurrentRequest() |
|
84 | + { |
|
85 | + $this->rewind(); |
|
86 | + while ($this->valid()) { |
|
87 | + $this->current()->handleRequest(); |
|
88 | + $this->next(); |
|
89 | + } |
|
90 | + $this->rewind(); |
|
91 | + } |
|
92 | 92 | } |
@@ -19,61 +19,61 @@ |
||
19 | 19 | interface JsonDataNodeInterface extends JsonSerializable |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @param JsonDataNode $data_node |
|
24 | - * @throws DomainException |
|
25 | - */ |
|
26 | - public function addDataNode(JsonDataNode $data_node); |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * the actual data in key value array format |
|
31 | - * |
|
32 | - * @return array |
|
33 | - */ |
|
34 | - public function data(); |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * specifies the domain (use case) that this route defines |
|
39 | - * ! IMPORTANT ! |
|
40 | - * only one domain can be set pre request |
|
41 | - * |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function domain(); |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * !!! IMPORTANT !!! |
|
49 | - * JsonDataNode::setInitialized(true) needs to be called once initialization is complete |
|
50 | - * else you're a bad person and bad things will happen to you !!! |
|
51 | - * |
|
52 | - * @since $VID:$ |
|
53 | - */ |
|
54 | - public function initialize(); |
|
55 | - |
|
56 | - |
|
57 | - /** |
|
58 | - * true if the data node has been initialized, |
|
59 | - * which entails retrieving the required data and adding it to the data node data array |
|
60 | - * |
|
61 | - * @return bool |
|
62 | - */ |
|
63 | - public function isInitialized(); |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * true if the data node has NOT been initialized |
|
68 | - * |
|
69 | - * @return bool |
|
70 | - */ |
|
71 | - public function isNotInitialized(); |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @return string |
|
76 | - * @since $VID:$ |
|
77 | - */ |
|
78 | - public function nodeName(); |
|
22 | + /** |
|
23 | + * @param JsonDataNode $data_node |
|
24 | + * @throws DomainException |
|
25 | + */ |
|
26 | + public function addDataNode(JsonDataNode $data_node); |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * the actual data in key value array format |
|
31 | + * |
|
32 | + * @return array |
|
33 | + */ |
|
34 | + public function data(); |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * specifies the domain (use case) that this route defines |
|
39 | + * ! IMPORTANT ! |
|
40 | + * only one domain can be set pre request |
|
41 | + * |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function domain(); |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * !!! IMPORTANT !!! |
|
49 | + * JsonDataNode::setInitialized(true) needs to be called once initialization is complete |
|
50 | + * else you're a bad person and bad things will happen to you !!! |
|
51 | + * |
|
52 | + * @since $VID:$ |
|
53 | + */ |
|
54 | + public function initialize(); |
|
55 | + |
|
56 | + |
|
57 | + /** |
|
58 | + * true if the data node has been initialized, |
|
59 | + * which entails retrieving the required data and adding it to the data node data array |
|
60 | + * |
|
61 | + * @return bool |
|
62 | + */ |
|
63 | + public function isInitialized(); |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * true if the data node has NOT been initialized |
|
68 | + * |
|
69 | + * @return bool |
|
70 | + */ |
|
71 | + public function isNotInitialized(); |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @return string |
|
76 | + * @since $VID:$ |
|
77 | + */ |
|
78 | + public function nodeName(); |
|
79 | 79 | } |
@@ -17,40 +17,40 @@ |
||
17 | 17 | class EspressoCoreDomain extends JsonDataNode |
18 | 18 | { |
19 | 19 | |
20 | - const NODE_NAME = 'coreDomain'; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var Domain $domain |
|
24 | - */ |
|
25 | - private $domain; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * JsonDataNode constructor. |
|
30 | - * |
|
31 | - * @param Domain $domain |
|
32 | - * @param JsonDataNodeValidator $validator |
|
33 | - */ |
|
34 | - public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
35 | - { |
|
36 | - $this->domain = $domain; |
|
37 | - parent::__construct($validator); |
|
38 | - $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @inheritDoc |
|
44 | - */ |
|
45 | - public function initialize() |
|
46 | - { |
|
47 | - $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
48 | - $this->addData('brandName', Domain::brandName()); |
|
49 | - $this->addData('coreVersion', $this->domain->version()); |
|
50 | - $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
51 | - $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
52 | - $this->addData('pluginPath', $this->domain->pluginPath()); |
|
53 | - $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
54 | - $this->setInitialized(true); |
|
55 | - } |
|
20 | + const NODE_NAME = 'coreDomain'; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var Domain $domain |
|
24 | + */ |
|
25 | + private $domain; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * JsonDataNode constructor. |
|
30 | + * |
|
31 | + * @param Domain $domain |
|
32 | + * @param JsonDataNodeValidator $validator |
|
33 | + */ |
|
34 | + public function __construct(Domain $domain, JsonDataNodeValidator $validator) |
|
35 | + { |
|
36 | + $this->domain = $domain; |
|
37 | + parent::__construct($validator); |
|
38 | + $this->setNodeName(EspressoCoreDomain::NODE_NAME); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @inheritDoc |
|
44 | + */ |
|
45 | + public function initialize() |
|
46 | + { |
|
47 | + $this->addData('assetNamespace', $this->domain->assetNamespace()); |
|
48 | + $this->addData('brandName', Domain::brandName()); |
|
49 | + $this->addData('coreVersion', $this->domain->version()); |
|
50 | + $this->addData('distributionAssetsPath', $this->domain->distributionAssetsPath()); |
|
51 | + $this->addData('distributionAssetsUrl', $this->domain->distributionAssetsUrl()); |
|
52 | + $this->addData('pluginPath', $this->domain->pluginPath()); |
|
53 | + $this->addData('pluginUrl', $this->domain->pluginUrl()); |
|
54 | + $this->setInitialized(true); |
|
55 | + } |
|
56 | 56 | } |
@@ -17,41 +17,41 @@ |
||
17 | 17 | class SiteCurrency extends JsonDataNode |
18 | 18 | { |
19 | 19 | |
20 | - const NODE_NAME = 'siteCurrency'; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var EE_Currency_Config $currency_config |
|
24 | - */ |
|
25 | - protected $currency_config; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * SiteCurrency constructor. |
|
30 | - * |
|
31 | - * @param EE_Currency_Config $currency_config |
|
32 | - * @param JsonDataNodeValidator $validator |
|
33 | - */ |
|
34 | - public function __construct(EE_Currency_Config $currency_config, JsonDataNodeValidator $validator) |
|
35 | - { |
|
36 | - parent::__construct($validator); |
|
37 | - $this->currency_config = $currency_config; |
|
38 | - $this->setNodeName(SiteCurrency::NODE_NAME); |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * @inheritDoc |
|
44 | - */ |
|
45 | - public function initialize() |
|
46 | - { |
|
47 | - $this->addData('code', $this->currency_config->code); |
|
48 | - $this->addData('singularLabel', $this->currency_config->name); |
|
49 | - $this->addData('pluralLabel', $this->currency_config->plural); |
|
50 | - $this->addData('sign', $this->currency_config->sign); |
|
51 | - $this->addData('signB4', $this->currency_config->sign_b4); |
|
52 | - $this->addData('decimalPlaces', $this->currency_config->dec_plc); |
|
53 | - $this->addData('decimalMark', $this->currency_config->dec_mrk); |
|
54 | - $this->addData('thousandsSeparator', $this->currency_config->thsnds); |
|
55 | - $this->setInitialized(true); |
|
56 | - } |
|
20 | + const NODE_NAME = 'siteCurrency'; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var EE_Currency_Config $currency_config |
|
24 | + */ |
|
25 | + protected $currency_config; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * SiteCurrency constructor. |
|
30 | + * |
|
31 | + * @param EE_Currency_Config $currency_config |
|
32 | + * @param JsonDataNodeValidator $validator |
|
33 | + */ |
|
34 | + public function __construct(EE_Currency_Config $currency_config, JsonDataNodeValidator $validator) |
|
35 | + { |
|
36 | + parent::__construct($validator); |
|
37 | + $this->currency_config = $currency_config; |
|
38 | + $this->setNodeName(SiteCurrency::NODE_NAME); |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * @inheritDoc |
|
44 | + */ |
|
45 | + public function initialize() |
|
46 | + { |
|
47 | + $this->addData('code', $this->currency_config->code); |
|
48 | + $this->addData('singularLabel', $this->currency_config->name); |
|
49 | + $this->addData('pluralLabel', $this->currency_config->plural); |
|
50 | + $this->addData('sign', $this->currency_config->sign); |
|
51 | + $this->addData('signB4', $this->currency_config->sign_b4); |
|
52 | + $this->addData('decimalPlaces', $this->currency_config->dec_plc); |
|
53 | + $this->addData('decimalMark', $this->currency_config->dec_mrk); |
|
54 | + $this->addData('thousandsSeparator', $this->currency_config->thsnds); |
|
55 | + $this->setInitialized(true); |
|
56 | + } |
|
57 | 57 | } |
@@ -17,37 +17,37 @@ |
||
17 | 17 | class WordPressPluginsPageData extends JsonDataNode |
18 | 18 | { |
19 | 19 | |
20 | - const NODE_NAME = 'wpPluginsPage'; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var ExitModal $exit_modal |
|
24 | - */ |
|
25 | - private $exit_modal; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * WordPressPluginsPageData JsonDataNode constructor. |
|
30 | - * |
|
31 | - * @param ExitModal $exit_modal |
|
32 | - * @param JsonDataNodeValidator $validator |
|
33 | - */ |
|
34 | - public function __construct( |
|
35 | - ExitModal $exit_modal, |
|
36 | - JsonDataNodeValidator $validator |
|
37 | - ) { |
|
38 | - parent::__construct($validator); |
|
39 | - $this->exit_modal = $exit_modal; |
|
40 | - $this->setDomain(WordPressPluginsPageData::NODE_NAME); |
|
41 | - $this->setNodeName(WordPressPluginsPageData::NODE_NAME); |
|
42 | - } |
|
43 | - |
|
44 | - |
|
45 | - /** |
|
46 | - * @inheritDoc |
|
47 | - */ |
|
48 | - public function initialize() |
|
49 | - { |
|
50 | - $data = $this->exit_modal->getExitSurveyInfo(); |
|
51 | - $this->addData('eeExitSurveyInfo', $data); |
|
52 | - } |
|
20 | + const NODE_NAME = 'wpPluginsPage'; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var ExitModal $exit_modal |
|
24 | + */ |
|
25 | + private $exit_modal; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * WordPressPluginsPageData JsonDataNode constructor. |
|
30 | + * |
|
31 | + * @param ExitModal $exit_modal |
|
32 | + * @param JsonDataNodeValidator $validator |
|
33 | + */ |
|
34 | + public function __construct( |
|
35 | + ExitModal $exit_modal, |
|
36 | + JsonDataNodeValidator $validator |
|
37 | + ) { |
|
38 | + parent::__construct($validator); |
|
39 | + $this->exit_modal = $exit_modal; |
|
40 | + $this->setDomain(WordPressPluginsPageData::NODE_NAME); |
|
41 | + $this->setNodeName(WordPressPluginsPageData::NODE_NAME); |
|
42 | + } |
|
43 | + |
|
44 | + |
|
45 | + /** |
|
46 | + * @inheritDoc |
|
47 | + */ |
|
48 | + public function initialize() |
|
49 | + { |
|
50 | + $data = $this->exit_modal->getExitSurveyInfo(); |
|
51 | + $this->addData('eeExitSurveyInfo', $data); |
|
52 | + } |
|
53 | 53 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
74 | 74 | */ |
75 | 75 | $input_fields = []; |
76 | - if (! empty($this->args['where'])) { |
|
76 | + if ( ! empty($this->args['where'])) { |
|
77 | 77 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
78 | 78 | } |
79 | 79 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Merge the input_fields with the default query_args |
100 | 100 | */ |
101 | - if (! empty($input_fields)) { |
|
101 | + if ( ! empty($input_fields)) { |
|
102 | 102 | $where_params = array_merge($where_params, $input_fields); |
103 | 103 | } |
104 | 104 |
@@ -16,130 +16,130 @@ |
||
16 | 16 | */ |
17 | 17 | class VenueConnectionResolver extends AbstractConnectionResolver |
18 | 18 | { |
19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | - public function get_loader_name(): string |
|
21 | - { |
|
22 | - return 'espresso_venue'; |
|
23 | - } |
|
24 | - |
|
25 | - /** |
|
26 | - * @return EEM_Venue |
|
27 | - * @throws EE_Error |
|
28 | - * @throws InvalidArgumentException |
|
29 | - * @throws InvalidDataTypeException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws ReflectionException |
|
32 | - */ |
|
33 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | - public function get_query(): EEM_Venue |
|
35 | - { |
|
36 | - return EEM_Venue::instance(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Return an array of item IDs from the query |
|
42 | - * |
|
43 | - * @return array |
|
44 | - */ |
|
45 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | - public function get_ids(): array |
|
47 | - { |
|
48 | - $results = $this->query->get_col($this->query_args); |
|
49 | - |
|
50 | - return ! empty($results) ? $results : []; |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | - * handle batch resolution of the posts. |
|
58 | - * |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | - public function get_query_args(): array |
|
63 | - { |
|
64 | - $where_params = []; |
|
65 | - $query_args = []; |
|
66 | - |
|
67 | - $query_args['limit'] = $this->getLimit(); |
|
68 | - |
|
69 | - // Avoid multiple entries by join. |
|
70 | - $query_args['group_by'] = 'VNU_ID'; |
|
71 | - |
|
72 | - $query_args['default_where_conditions'] = 'minimum'; |
|
73 | - |
|
74 | - /** |
|
75 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | - */ |
|
77 | - $input_fields = []; |
|
78 | - if (! empty($this->args['where'])) { |
|
79 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | - * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | - * set the query to pull datetimes that belong to that event. |
|
86 | - * We can set more cases for other source types. |
|
87 | - */ |
|
88 | - if (is_object($this->source)) { |
|
89 | - switch (true) { |
|
90 | - // Assumed to be an event |
|
91 | - case $this->source instanceof Post: |
|
92 | - $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | - break; |
|
94 | - case $this->source instanceof EE_Event: |
|
95 | - $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | - break; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Merge the input_fields with the default query_args |
|
102 | - */ |
|
103 | - if (! empty($input_fields)) { |
|
104 | - $where_params = array_merge($where_params, $input_fields); |
|
105 | - } |
|
106 | - |
|
107 | - [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | - |
|
109 | - $where_params = apply_filters( |
|
110 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | - $where_params, |
|
112 | - $this->source, |
|
113 | - $this->args |
|
114 | - ); |
|
115 | - |
|
116 | - $query_args[] = $where_params; |
|
117 | - |
|
118 | - /** |
|
119 | - * Return the $query_args |
|
120 | - */ |
|
121 | - return apply_filters( |
|
122 | - 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | - $query_args, |
|
124 | - $this->source, |
|
125 | - $this->args |
|
126 | - ); |
|
127 | - } |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | - * friendly keys. |
|
133 | - * |
|
134 | - * @param array $where_args |
|
135 | - * @return array |
|
136 | - */ |
|
137 | - public function sanitizeInputFields(array $where_args): array |
|
138 | - { |
|
139 | - return $this->sanitizeWhereArgsForInputFields( |
|
140 | - $where_args, |
|
141 | - [], |
|
142 | - [] |
|
143 | - ); |
|
144 | - } |
|
19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
20 | + public function get_loader_name(): string |
|
21 | + { |
|
22 | + return 'espresso_venue'; |
|
23 | + } |
|
24 | + |
|
25 | + /** |
|
26 | + * @return EEM_Venue |
|
27 | + * @throws EE_Error |
|
28 | + * @throws InvalidArgumentException |
|
29 | + * @throws InvalidDataTypeException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws ReflectionException |
|
32 | + */ |
|
33 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
34 | + public function get_query(): EEM_Venue |
|
35 | + { |
|
36 | + return EEM_Venue::instance(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Return an array of item IDs from the query |
|
42 | + * |
|
43 | + * @return array |
|
44 | + */ |
|
45 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
46 | + public function get_ids(): array |
|
47 | + { |
|
48 | + $results = $this->query->get_col($this->query_args); |
|
49 | + |
|
50 | + return ! empty($results) ? $results : []; |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
56 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
57 | + * handle batch resolution of the posts. |
|
58 | + * |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
62 | + public function get_query_args(): array |
|
63 | + { |
|
64 | + $where_params = []; |
|
65 | + $query_args = []; |
|
66 | + |
|
67 | + $query_args['limit'] = $this->getLimit(); |
|
68 | + |
|
69 | + // Avoid multiple entries by join. |
|
70 | + $query_args['group_by'] = 'VNU_ID'; |
|
71 | + |
|
72 | + $query_args['default_where_conditions'] = 'minimum'; |
|
73 | + |
|
74 | + /** |
|
75 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
76 | + */ |
|
77 | + $input_fields = []; |
|
78 | + if (! empty($this->args['where'])) { |
|
79 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Determine where we're at in the Graph and adjust the query context appropriately. |
|
84 | + * For example, if we're querying for datetime as a field of event query, this will automatically |
|
85 | + * set the query to pull datetimes that belong to that event. |
|
86 | + * We can set more cases for other source types. |
|
87 | + */ |
|
88 | + if (is_object($this->source)) { |
|
89 | + switch (true) { |
|
90 | + // Assumed to be an event |
|
91 | + case $this->source instanceof Post: |
|
92 | + $where_params['Event.EVT_ID'] = $this->source->ID; |
|
93 | + break; |
|
94 | + case $this->source instanceof EE_Event: |
|
95 | + $where_params['Event.EVT_ID'] = $this->source->ID(); |
|
96 | + break; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Merge the input_fields with the default query_args |
|
102 | + */ |
|
103 | + if (! empty($input_fields)) { |
|
104 | + $where_params = array_merge($where_params, $input_fields); |
|
105 | + } |
|
106 | + |
|
107 | + [$query_args, $where_params] = $this->mapOrderbyInputArgs($query_args, $where_params, 'VNU_ID'); |
|
108 | + |
|
109 | + $where_params = apply_filters( |
|
110 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_where_params', |
|
111 | + $where_params, |
|
112 | + $this->source, |
|
113 | + $this->args |
|
114 | + ); |
|
115 | + |
|
116 | + $query_args[] = $where_params; |
|
117 | + |
|
118 | + /** |
|
119 | + * Return the $query_args |
|
120 | + */ |
|
121 | + return apply_filters( |
|
122 | + 'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__venue_query_args', |
|
123 | + $query_args, |
|
124 | + $this->source, |
|
125 | + $this->args |
|
126 | + ); |
|
127 | + } |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
132 | + * friendly keys. |
|
133 | + * |
|
134 | + * @param array $where_args |
|
135 | + * @return array |
|
136 | + */ |
|
137 | + public function sanitizeInputFields(array $where_args): array |
|
138 | + { |
|
139 | + return $this->sanitizeWhereArgsForInputFields( |
|
140 | + $where_args, |
|
141 | + [], |
|
142 | + [] |
|
143 | + ); |
|
144 | + } |
|
145 | 145 | } |
@@ -13,15 +13,15 @@ discard block |
||
13 | 13 | class CurrentUser extends GraphQLData |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param array $where_params |
|
18 | - * @return array|null |
|
19 | - * @since $VID:$ |
|
20 | - */ |
|
21 | - public function getData(array $where_params = []) |
|
22 | - { |
|
23 | - $field_key = 'viewer'; |
|
24 | - $query = <<<QUERY |
|
16 | + /** |
|
17 | + * @param array $where_params |
|
18 | + * @return array|null |
|
19 | + * @since $VID:$ |
|
20 | + */ |
|
21 | + public function getData(array $where_params = []) |
|
22 | + { |
|
23 | + $field_key = 'viewer'; |
|
24 | + $query = <<<QUERY |
|
25 | 25 | query GET_CURRENT_USER { |
26 | 26 | {$field_key} { |
27 | 27 | id |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | } |
40 | 40 | } |
41 | 41 | QUERY; |
42 | - $this->setParams([ |
|
43 | - 'operation_name' => 'GET_CURRENT_USER', |
|
44 | - 'query' => $query, |
|
45 | - ]); |
|
42 | + $this->setParams([ |
|
43 | + 'operation_name' => 'GET_CURRENT_USER', |
|
44 | + 'query' => $query, |
|
45 | + ]); |
|
46 | 46 | |
47 | - return $this->getQueryResponse($field_key, $where_params); |
|
48 | - } |
|
47 | + return $this->getQueryResponse($field_key, $where_params); |
|
48 | + } |
|
49 | 49 | } |