@@ -17,43 +17,43 @@ |
||
17 | 17 | class Attendee extends AttendeeCalculationsBase |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * @param array $wpdb_row |
|
22 | - * @param WP_REST_Request $request |
|
23 | - * @param AttendeeControllerBase $controller |
|
24 | - * @since 4.9.66.p |
|
25 | - * @return string |
|
26 | - */ |
|
27 | - public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller) |
|
28 | - { |
|
29 | - if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) { |
|
30 | - $email_address = $wpdb_row['Attendee_Meta.ATT_email']; |
|
31 | - } |
|
32 | - if (empty($email_address)) { |
|
33 | - return get_avatar_url('', array('default' => 'mm', 'force_default' => true)); |
|
34 | - } |
|
35 | - $avatar = get_avatar_url($email_address); |
|
36 | - return $avatar ? $avatar : ''; |
|
37 | - } |
|
20 | + /** |
|
21 | + * @param array $wpdb_row |
|
22 | + * @param WP_REST_Request $request |
|
23 | + * @param AttendeeControllerBase $controller |
|
24 | + * @since 4.9.66.p |
|
25 | + * @return string |
|
26 | + */ |
|
27 | + public function userAvatar(array $wpdb_row, WP_REST_Request $request, AttendeeControllerBase $controller) |
|
28 | + { |
|
29 | + if (is_array($wpdb_row) && isset($wpdb_row['Attendee_Meta.ATT_email'])) { |
|
30 | + $email_address = $wpdb_row['Attendee_Meta.ATT_email']; |
|
31 | + } |
|
32 | + if (empty($email_address)) { |
|
33 | + return get_avatar_url('', array('default' => 'mm', 'force_default' => true)); |
|
34 | + } |
|
35 | + $avatar = get_avatar_url($email_address); |
|
36 | + return $avatar ? $avatar : ''; |
|
37 | + } |
|
38 | 38 | |
39 | 39 | |
40 | - /** |
|
41 | - * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
42 | - * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
43 | - * |
|
44 | - * @since 4.9.68.p |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function schemaForCalculations() |
|
48 | - { |
|
49 | - return array( |
|
50 | - 'user_avatar' => array( |
|
51 | - 'description' => esc_html__( |
|
52 | - 'The avatar url for the attendee (if available).', |
|
53 | - 'event_espresso' |
|
54 | - ), |
|
55 | - 'type' => 'string', |
|
56 | - ), |
|
57 | - ); |
|
58 | - } |
|
40 | + /** |
|
41 | + * Provides an array for all the calculations possible that outlines a json schema for those calculations. |
|
42 | + * Array is indexed by calculation (snake case) and value is the schema for that calculation. |
|
43 | + * |
|
44 | + * @since 4.9.68.p |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function schemaForCalculations() |
|
48 | + { |
|
49 | + return array( |
|
50 | + 'user_avatar' => array( |
|
51 | + 'description' => esc_html__( |
|
52 | + 'The avatar url for the attendee (if available).', |
|
53 | + 'event_espresso' |
|
54 | + ), |
|
55 | + 'type' => 'string', |
|
56 | + ), |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | } |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | |
143 | 143 | |
144 | 144 | /** |
145 | - * @param $handle |
|
145 | + * @param string $handle |
|
146 | 146 | * @param array $dependencies |
147 | 147 | * @since $VID:$ |
148 | 148 | * @return JavascriptAsset |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | /** |
171 | - * @param $handle |
|
171 | + * @param string $handle |
|
172 | 172 | * @param array $dependencies |
173 | 173 | * @since $VID:$ |
174 | 174 | * @return StylesheetAsset |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | |
195 | 195 | /** |
196 | - * @param $handle |
|
196 | + * @param string $handle |
|
197 | 197 | * @param array $dependencies |
198 | 198 | * @since $VID:$ |
199 | 199 | * @return JavascriptAsset |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | /** |
222 | - * @param $handle |
|
222 | + * @param string $handle |
|
223 | 223 | * @param array $dependencies |
224 | 224 | * @since $VID:$ |
225 | 225 | * @return StylesheetAsset |
@@ -22,309 +22,309 @@ |
||
22 | 22 | abstract class BlockAssetManager extends AssetManager implements BlockAssetManagerInterface |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var string $editor_script_handle |
|
27 | - */ |
|
28 | - private $editor_script_handle; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var string $editor_style_handle |
|
32 | - */ |
|
33 | - private $editor_style_handle; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $script_handle |
|
37 | - */ |
|
38 | - private $script_handle; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $style_handle |
|
42 | - */ |
|
43 | - private $style_handle; |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function getEditorScriptHandle() |
|
50 | - { |
|
51 | - return $this->editor_script_handle; |
|
52 | - } |
|
53 | - |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $editor_script_handle |
|
57 | - */ |
|
58 | - public function setEditorScriptHandle($editor_script_handle) |
|
59 | - { |
|
60 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | - } |
|
63 | - $this->editor_script_handle = $editor_script_handle; |
|
64 | - } |
|
65 | - |
|
66 | - |
|
67 | - /** |
|
68 | - * @return string |
|
69 | - */ |
|
70 | - public function getEditorStyleHandle() |
|
71 | - { |
|
72 | - return $this->editor_style_handle; |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @param string $editor_style_handle |
|
78 | - */ |
|
79 | - public function setEditorStyleHandle($editor_style_handle) |
|
80 | - { |
|
81 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | - } |
|
84 | - $this->editor_style_handle = $editor_style_handle; |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * @return string |
|
90 | - */ |
|
91 | - public function getScriptHandle() |
|
92 | - { |
|
93 | - return $this->script_handle; |
|
94 | - } |
|
95 | - |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string $script_handle |
|
99 | - */ |
|
100 | - public function setScriptHandle($script_handle) |
|
101 | - { |
|
102 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | - } |
|
105 | - $this->script_handle = $script_handle; |
|
106 | - } |
|
107 | - |
|
108 | - |
|
109 | - /** |
|
110 | - * @return string |
|
111 | - */ |
|
112 | - public function getStyleHandle() |
|
113 | - { |
|
114 | - return $this->style_handle; |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @param string $style_handle |
|
120 | - */ |
|
121 | - public function setStyleHandle($style_handle) |
|
122 | - { |
|
123 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | - } |
|
126 | - $this->style_handle = $style_handle; |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * @since $VID:$ |
|
131 | - * @throws InvalidDataTypeException |
|
132 | - * @throws InvalidEntityException |
|
133 | - * @throws DuplicateCollectionIdentifierException |
|
134 | - */ |
|
135 | - public function addAssets() |
|
136 | - { |
|
137 | - $this->addEditorScript($this->getEditorScriptHandle()); |
|
138 | - $this->addEditorStyle($this->getEditorStyleHandle()); |
|
139 | - $this->addScript($this->getScriptHandle()); |
|
140 | - $this->addStyle($this->getStyleHandle()); |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param $handle |
|
146 | - * @param array $dependencies |
|
147 | - * @since $VID:$ |
|
148 | - * @return JavascriptAsset |
|
149 | - * @throws InvalidDataTypeException |
|
150 | - * @throws InvalidEntityException |
|
151 | - * @throws DuplicateCollectionIdentifierException |
|
152 | - */ |
|
153 | - public function addEditorScript($handle, array $dependencies = array()) |
|
154 | - { |
|
155 | - if($this->assets->hasJavascriptAsset($handle)){ |
|
156 | - return $this->assets->getJavascriptAsset($handle); |
|
157 | - } |
|
158 | - return parent::addJavascript( |
|
159 | - $handle, |
|
160 | - $this->registry->getJsUrl( |
|
161 | - $this->domain->assetNamespace(), |
|
162 | - $handle |
|
163 | - ), |
|
164 | - $this->addDefaultBlockScriptDependencies($dependencies) |
|
165 | - ) |
|
166 | - ->setRequiresTranslation(); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param $handle |
|
172 | - * @param array $dependencies |
|
173 | - * @since $VID:$ |
|
174 | - * @return StylesheetAsset |
|
175 | - * @throws InvalidDataTypeException |
|
176 | - * @throws InvalidEntityException |
|
177 | - * @throws DuplicateCollectionIdentifierException |
|
178 | - */ |
|
179 | - public function addEditorStyle($handle, array $dependencies = array()) |
|
180 | - { |
|
181 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
182 | - return $this->assets->getStylesheetAsset($handle); |
|
183 | - } |
|
184 | - return parent::addStylesheet( |
|
185 | - $handle, |
|
186 | - $this->registry->getCssUrl( |
|
187 | - $this->domain->assetNamespace(), |
|
188 | - $handle |
|
189 | - ), |
|
190 | - $this->addDefaultBlockStyleDependencies($dependencies) |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * @param $handle |
|
197 | - * @param array $dependencies |
|
198 | - * @since $VID:$ |
|
199 | - * @return JavascriptAsset |
|
200 | - * @throws InvalidDataTypeException |
|
201 | - * @throws InvalidEntityException |
|
202 | - * @throws DuplicateCollectionIdentifierException |
|
203 | - */ |
|
204 | - public function addScript($handle, array $dependencies = array()) |
|
205 | - { |
|
206 | - if ($this->assets->hasJavascriptAsset($handle)) { |
|
207 | - return $this->assets->getJavascriptAsset($handle); |
|
208 | - } |
|
209 | - return parent::addJavascript( |
|
210 | - $handle, |
|
211 | - $this->registry->getJsUrl( |
|
212 | - $this->domain->assetNamespace(), |
|
213 | - $handle |
|
214 | - ), |
|
215 | - $dependencies + array( CoreAssetManager::JS_HANDLE_EE_COMPONENTS ) |
|
216 | - ) |
|
217 | - ->setRequiresTranslation(); |
|
218 | - } |
|
219 | - |
|
220 | - |
|
221 | - /** |
|
222 | - * @param $handle |
|
223 | - * @param array $dependencies |
|
224 | - * @since $VID:$ |
|
225 | - * @return StylesheetAsset |
|
226 | - * @throws InvalidDataTypeException |
|
227 | - * @throws InvalidEntityException |
|
228 | - * @throws DuplicateCollectionIdentifierException |
|
229 | - */ |
|
230 | - public function addStyle($handle, array $dependencies = array()) |
|
231 | - { |
|
232 | - if ($this->assets->hasStylesheetAsset($handle)) { |
|
233 | - return $this->assets->getStylesheetAsset($handle); |
|
234 | - } |
|
235 | - return parent::addStylesheet( |
|
236 | - $handle, |
|
237 | - $this->registry->getCssUrl( |
|
238 | - $this->domain->assetNamespace(), |
|
239 | - $handle |
|
240 | - ), |
|
241 | - $this->addDefaultBlockStyleDependencies($dependencies) |
|
242 | - ); |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param array $dependencies |
|
248 | - * @return array |
|
249 | - */ |
|
250 | - protected function addDefaultBlockScriptDependencies(array $dependencies) |
|
251 | - { |
|
252 | - $dependencies += array( |
|
253 | - 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | - 'wp-i18n', // Provides localization functions |
|
255 | - 'wp-element', // Provides React.Component |
|
256 | - 'wp-components', // Provides many prebuilt components and controls |
|
257 | - CoreAssetManager::JS_HANDLE_EE_COMPONENTS |
|
258 | - ); |
|
259 | - return $dependencies; |
|
260 | - } |
|
261 | - |
|
262 | - |
|
263 | - /** |
|
264 | - * @param array $dependencies |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
268 | - { |
|
269 | - $dependencies += array( |
|
270 | - CoreAssetManager::CSS_HANDLE_EE_COMPONENTS, |
|
271 | - ); |
|
272 | - return $dependencies; |
|
273 | - } |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * @return JavascriptAsset|null |
|
278 | - */ |
|
279 | - public function getEditorScript() |
|
280 | - { |
|
281 | - return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
282 | - } |
|
283 | - |
|
284 | - |
|
285 | - /** |
|
286 | - * @return StylesheetAsset|null |
|
287 | - */ |
|
288 | - public function getEditorStyle() |
|
289 | - { |
|
290 | - return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
291 | - } |
|
292 | - |
|
293 | - |
|
294 | - /** |
|
295 | - * @return JavascriptAsset|null |
|
296 | - */ |
|
297 | - public function getScript() |
|
298 | - { |
|
299 | - return $this->assets->getJavascriptAsset($this->script_handle); |
|
300 | - } |
|
301 | - |
|
302 | - |
|
303 | - /** |
|
304 | - * @return StylesheetAsset|null |
|
305 | - */ |
|
306 | - public function getStyle() |
|
307 | - { |
|
308 | - return $this->assets->getStylesheetAsset($this->style_handle); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - /** |
|
313 | - * @return void |
|
314 | - */ |
|
315 | - public function enqueueAssets() |
|
316 | - { |
|
317 | - $assets = array( |
|
318 | - $this->getEditorScript(), |
|
319 | - $this->getEditorStyle(), |
|
320 | - $this->getScript(), |
|
321 | - $this->getStyle(), |
|
322 | - ); |
|
323 | - foreach ($assets as $asset) { |
|
324 | - if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
325 | - $asset->enqueueAsset(); |
|
326 | - } |
|
327 | - } |
|
328 | - } |
|
25 | + /** |
|
26 | + * @var string $editor_script_handle |
|
27 | + */ |
|
28 | + private $editor_script_handle; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var string $editor_style_handle |
|
32 | + */ |
|
33 | + private $editor_style_handle; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $script_handle |
|
37 | + */ |
|
38 | + private $script_handle; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $style_handle |
|
42 | + */ |
|
43 | + private $style_handle; |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function getEditorScriptHandle() |
|
50 | + { |
|
51 | + return $this->editor_script_handle; |
|
52 | + } |
|
53 | + |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $editor_script_handle |
|
57 | + */ |
|
58 | + public function setEditorScriptHandle($editor_script_handle) |
|
59 | + { |
|
60 | + if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | + $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
62 | + } |
|
63 | + $this->editor_script_handle = $editor_script_handle; |
|
64 | + } |
|
65 | + |
|
66 | + |
|
67 | + /** |
|
68 | + * @return string |
|
69 | + */ |
|
70 | + public function getEditorStyleHandle() |
|
71 | + { |
|
72 | + return $this->editor_style_handle; |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @param string $editor_style_handle |
|
78 | + */ |
|
79 | + public function setEditorStyleHandle($editor_style_handle) |
|
80 | + { |
|
81 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | + $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
83 | + } |
|
84 | + $this->editor_style_handle = $editor_style_handle; |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * @return string |
|
90 | + */ |
|
91 | + public function getScriptHandle() |
|
92 | + { |
|
93 | + return $this->script_handle; |
|
94 | + } |
|
95 | + |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string $script_handle |
|
99 | + */ |
|
100 | + public function setScriptHandle($script_handle) |
|
101 | + { |
|
102 | + if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | + $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
104 | + } |
|
105 | + $this->script_handle = $script_handle; |
|
106 | + } |
|
107 | + |
|
108 | + |
|
109 | + /** |
|
110 | + * @return string |
|
111 | + */ |
|
112 | + public function getStyleHandle() |
|
113 | + { |
|
114 | + return $this->style_handle; |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @param string $style_handle |
|
120 | + */ |
|
121 | + public function setStyleHandle($style_handle) |
|
122 | + { |
|
123 | + if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | + $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
125 | + } |
|
126 | + $this->style_handle = $style_handle; |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * @since $VID:$ |
|
131 | + * @throws InvalidDataTypeException |
|
132 | + * @throws InvalidEntityException |
|
133 | + * @throws DuplicateCollectionIdentifierException |
|
134 | + */ |
|
135 | + public function addAssets() |
|
136 | + { |
|
137 | + $this->addEditorScript($this->getEditorScriptHandle()); |
|
138 | + $this->addEditorStyle($this->getEditorStyleHandle()); |
|
139 | + $this->addScript($this->getScriptHandle()); |
|
140 | + $this->addStyle($this->getStyleHandle()); |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param $handle |
|
146 | + * @param array $dependencies |
|
147 | + * @since $VID:$ |
|
148 | + * @return JavascriptAsset |
|
149 | + * @throws InvalidDataTypeException |
|
150 | + * @throws InvalidEntityException |
|
151 | + * @throws DuplicateCollectionIdentifierException |
|
152 | + */ |
|
153 | + public function addEditorScript($handle, array $dependencies = array()) |
|
154 | + { |
|
155 | + if($this->assets->hasJavascriptAsset($handle)){ |
|
156 | + return $this->assets->getJavascriptAsset($handle); |
|
157 | + } |
|
158 | + return parent::addJavascript( |
|
159 | + $handle, |
|
160 | + $this->registry->getJsUrl( |
|
161 | + $this->domain->assetNamespace(), |
|
162 | + $handle |
|
163 | + ), |
|
164 | + $this->addDefaultBlockScriptDependencies($dependencies) |
|
165 | + ) |
|
166 | + ->setRequiresTranslation(); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param $handle |
|
172 | + * @param array $dependencies |
|
173 | + * @since $VID:$ |
|
174 | + * @return StylesheetAsset |
|
175 | + * @throws InvalidDataTypeException |
|
176 | + * @throws InvalidEntityException |
|
177 | + * @throws DuplicateCollectionIdentifierException |
|
178 | + */ |
|
179 | + public function addEditorStyle($handle, array $dependencies = array()) |
|
180 | + { |
|
181 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
182 | + return $this->assets->getStylesheetAsset($handle); |
|
183 | + } |
|
184 | + return parent::addStylesheet( |
|
185 | + $handle, |
|
186 | + $this->registry->getCssUrl( |
|
187 | + $this->domain->assetNamespace(), |
|
188 | + $handle |
|
189 | + ), |
|
190 | + $this->addDefaultBlockStyleDependencies($dependencies) |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * @param $handle |
|
197 | + * @param array $dependencies |
|
198 | + * @since $VID:$ |
|
199 | + * @return JavascriptAsset |
|
200 | + * @throws InvalidDataTypeException |
|
201 | + * @throws InvalidEntityException |
|
202 | + * @throws DuplicateCollectionIdentifierException |
|
203 | + */ |
|
204 | + public function addScript($handle, array $dependencies = array()) |
|
205 | + { |
|
206 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
207 | + return $this->assets->getJavascriptAsset($handle); |
|
208 | + } |
|
209 | + return parent::addJavascript( |
|
210 | + $handle, |
|
211 | + $this->registry->getJsUrl( |
|
212 | + $this->domain->assetNamespace(), |
|
213 | + $handle |
|
214 | + ), |
|
215 | + $dependencies + array( CoreAssetManager::JS_HANDLE_EE_COMPONENTS ) |
|
216 | + ) |
|
217 | + ->setRequiresTranslation(); |
|
218 | + } |
|
219 | + |
|
220 | + |
|
221 | + /** |
|
222 | + * @param $handle |
|
223 | + * @param array $dependencies |
|
224 | + * @since $VID:$ |
|
225 | + * @return StylesheetAsset |
|
226 | + * @throws InvalidDataTypeException |
|
227 | + * @throws InvalidEntityException |
|
228 | + * @throws DuplicateCollectionIdentifierException |
|
229 | + */ |
|
230 | + public function addStyle($handle, array $dependencies = array()) |
|
231 | + { |
|
232 | + if ($this->assets->hasStylesheetAsset($handle)) { |
|
233 | + return $this->assets->getStylesheetAsset($handle); |
|
234 | + } |
|
235 | + return parent::addStylesheet( |
|
236 | + $handle, |
|
237 | + $this->registry->getCssUrl( |
|
238 | + $this->domain->assetNamespace(), |
|
239 | + $handle |
|
240 | + ), |
|
241 | + $this->addDefaultBlockStyleDependencies($dependencies) |
|
242 | + ); |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param array $dependencies |
|
248 | + * @return array |
|
249 | + */ |
|
250 | + protected function addDefaultBlockScriptDependencies(array $dependencies) |
|
251 | + { |
|
252 | + $dependencies += array( |
|
253 | + 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | + 'wp-i18n', // Provides localization functions |
|
255 | + 'wp-element', // Provides React.Component |
|
256 | + 'wp-components', // Provides many prebuilt components and controls |
|
257 | + CoreAssetManager::JS_HANDLE_EE_COMPONENTS |
|
258 | + ); |
|
259 | + return $dependencies; |
|
260 | + } |
|
261 | + |
|
262 | + |
|
263 | + /** |
|
264 | + * @param array $dependencies |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + protected function addDefaultBlockStyleDependencies(array $dependencies) |
|
268 | + { |
|
269 | + $dependencies += array( |
|
270 | + CoreAssetManager::CSS_HANDLE_EE_COMPONENTS, |
|
271 | + ); |
|
272 | + return $dependencies; |
|
273 | + } |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * @return JavascriptAsset|null |
|
278 | + */ |
|
279 | + public function getEditorScript() |
|
280 | + { |
|
281 | + return $this->assets->getJavascriptAsset($this->editor_script_handle); |
|
282 | + } |
|
283 | + |
|
284 | + |
|
285 | + /** |
|
286 | + * @return StylesheetAsset|null |
|
287 | + */ |
|
288 | + public function getEditorStyle() |
|
289 | + { |
|
290 | + return $this->assets->getStylesheetAsset($this->editor_style_handle); |
|
291 | + } |
|
292 | + |
|
293 | + |
|
294 | + /** |
|
295 | + * @return JavascriptAsset|null |
|
296 | + */ |
|
297 | + public function getScript() |
|
298 | + { |
|
299 | + return $this->assets->getJavascriptAsset($this->script_handle); |
|
300 | + } |
|
301 | + |
|
302 | + |
|
303 | + /** |
|
304 | + * @return StylesheetAsset|null |
|
305 | + */ |
|
306 | + public function getStyle() |
|
307 | + { |
|
308 | + return $this->assets->getStylesheetAsset($this->style_handle); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + /** |
|
313 | + * @return void |
|
314 | + */ |
|
315 | + public function enqueueAssets() |
|
316 | + { |
|
317 | + $assets = array( |
|
318 | + $this->getEditorScript(), |
|
319 | + $this->getEditorStyle(), |
|
320 | + $this->getScript(), |
|
321 | + $this->getStyle(), |
|
322 | + ); |
|
323 | + foreach ($assets as $asset) { |
|
324 | + if ($asset instanceof BrowserAsset && $asset->isRegistered()) { |
|
325 | + $asset->enqueueAsset(); |
|
326 | + } |
|
327 | + } |
|
328 | + } |
|
329 | 329 | |
330 | 330 | } |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function setEditorScriptHandle($editor_script_handle) |
59 | 59 | { |
60 | - if(strpos($editor_script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
61 | - $editor_script_handle = BlockInterface::NAME_SPACE . '-' . $editor_script_handle; |
|
60 | + if (strpos($editor_script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
61 | + $editor_script_handle = BlockInterface::NAME_SPACE.'-'.$editor_script_handle; |
|
62 | 62 | } |
63 | 63 | $this->editor_script_handle = $editor_script_handle; |
64 | 64 | } |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | */ |
79 | 79 | public function setEditorStyleHandle($editor_style_handle) |
80 | 80 | { |
81 | - if (strpos($editor_style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
82 | - $editor_style_handle = BlockInterface::NAME_SPACE . '-' . $editor_style_handle; |
|
81 | + if (strpos($editor_style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
82 | + $editor_style_handle = BlockInterface::NAME_SPACE.'-'.$editor_style_handle; |
|
83 | 83 | } |
84 | 84 | $this->editor_style_handle = $editor_style_handle; |
85 | 85 | } |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function setScriptHandle($script_handle) |
101 | 101 | { |
102 | - if (strpos($script_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
103 | - $script_handle = BlockInterface::NAME_SPACE . '-' . $script_handle; |
|
102 | + if (strpos($script_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
103 | + $script_handle = BlockInterface::NAME_SPACE.'-'.$script_handle; |
|
104 | 104 | } |
105 | 105 | $this->script_handle = $script_handle; |
106 | 106 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function setStyleHandle($style_handle) |
122 | 122 | { |
123 | - if (strpos($style_handle, BlockInterface::NAME_SPACE . '-') !== 0) { |
|
124 | - $style_handle = BlockInterface::NAME_SPACE . '-' . $style_handle; |
|
123 | + if (strpos($style_handle, BlockInterface::NAME_SPACE.'-') !== 0) { |
|
124 | + $style_handle = BlockInterface::NAME_SPACE.'-'.$style_handle; |
|
125 | 125 | } |
126 | 126 | $this->style_handle = $style_handle; |
127 | 127 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function addEditorScript($handle, array $dependencies = array()) |
154 | 154 | { |
155 | - if($this->assets->hasJavascriptAsset($handle)){ |
|
155 | + if ($this->assets->hasJavascriptAsset($handle)) { |
|
156 | 156 | return $this->assets->getJavascriptAsset($handle); |
157 | 157 | } |
158 | 158 | return parent::addJavascript( |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | $this->domain->assetNamespace(), |
213 | 213 | $handle |
214 | 214 | ), |
215 | - $dependencies + array( CoreAssetManager::JS_HANDLE_EE_COMPONENTS ) |
|
215 | + $dependencies + array(CoreAssetManager::JS_HANDLE_EE_COMPONENTS) |
|
216 | 216 | ) |
217 | 217 | ->setRequiresTranslation(); |
218 | 218 | } |
@@ -250,9 +250,9 @@ discard block |
||
250 | 250 | protected function addDefaultBlockScriptDependencies(array $dependencies) |
251 | 251 | { |
252 | 252 | $dependencies += array( |
253 | - 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | - 'wp-i18n', // Provides localization functions |
|
255 | - 'wp-element', // Provides React.Component |
|
253 | + 'wp-blocks', // Provides useful functions and components for extending the editor |
|
254 | + 'wp-i18n', // Provides localization functions |
|
255 | + 'wp-element', // Provides React.Component |
|
256 | 256 | 'wp-components', // Provides many prebuilt components and controls |
257 | 257 | CoreAssetManager::JS_HANDLE_EE_COMPONENTS |
258 | 258 | ); |
@@ -20,1056 +20,1056 @@ |
||
20 | 20 | class EE_Dependency_Map |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @type EE_Dependency_Map $_instance |
|
55 | - */ |
|
56 | - protected static $_instance; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var ClassInterfaceCache $class_cache |
|
60 | - */ |
|
61 | - private $class_cache; |
|
62 | - |
|
63 | - /** |
|
64 | - * @type RequestInterface $request |
|
65 | - */ |
|
66 | - protected $request; |
|
67 | - |
|
68 | - /** |
|
69 | - * @type LegacyRequestInterface $legacy_request |
|
70 | - */ |
|
71 | - protected $legacy_request; |
|
72 | - |
|
73 | - /** |
|
74 | - * @type ResponseInterface $response |
|
75 | - */ |
|
76 | - protected $response; |
|
77 | - |
|
78 | - /** |
|
79 | - * @type LoaderInterface $loader |
|
80 | - */ |
|
81 | - protected $loader; |
|
82 | - |
|
83 | - /** |
|
84 | - * @type array $_dependency_map |
|
85 | - */ |
|
86 | - protected $_dependency_map = array(); |
|
87 | - |
|
88 | - /** |
|
89 | - * @type array $_class_loaders |
|
90 | - */ |
|
91 | - protected $_class_loaders = array(); |
|
92 | - |
|
93 | - |
|
94 | - /** |
|
95 | - * EE_Dependency_Map constructor. |
|
96 | - * |
|
97 | - * @param ClassInterfaceCache $class_cache |
|
98 | - */ |
|
99 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | - { |
|
101 | - $this->class_cache = $class_cache; |
|
102 | - do_action('EE_Dependency_Map____construct', $this); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * @return void |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | - && $class_cache instanceof ClassInterfaceCache |
|
127 | - ) { |
|
128 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | - } |
|
130 | - return self::$_instance; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param RequestInterface $request |
|
136 | - */ |
|
137 | - public function setRequest(RequestInterface $request) |
|
138 | - { |
|
139 | - $this->request = $request; |
|
140 | - } |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @param LegacyRequestInterface $legacy_request |
|
145 | - */ |
|
146 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | - { |
|
148 | - $this->legacy_request = $legacy_request; |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - /** |
|
153 | - * @param ResponseInterface $response |
|
154 | - */ |
|
155 | - public function setResponse(ResponseInterface $response) |
|
156 | - { |
|
157 | - $this->response = $response; |
|
158 | - } |
|
159 | - |
|
160 | - |
|
161 | - /** |
|
162 | - * @param LoaderInterface $loader |
|
163 | - */ |
|
164 | - public function setLoader(LoaderInterface $loader) |
|
165 | - { |
|
166 | - $this->loader = $loader; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param string $class |
|
172 | - * @param array $dependencies |
|
173 | - * @param int $overwrite |
|
174 | - * @return bool |
|
175 | - */ |
|
176 | - public static function register_dependencies( |
|
177 | - $class, |
|
178 | - array $dependencies, |
|
179 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | - ) { |
|
181 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - /** |
|
186 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | - * to the class specified by the first parameter. |
|
188 | - * IMPORTANT !!! |
|
189 | - * The order of elements in the incoming $dependencies array MUST match |
|
190 | - * the order of the constructor parameters for the class in question. |
|
191 | - * This is especially important when overriding any existing dependencies that are registered. |
|
192 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | - * |
|
194 | - * @param string $class |
|
195 | - * @param array $dependencies |
|
196 | - * @param int $overwrite |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function registerDependencies( |
|
200 | - $class, |
|
201 | - array $dependencies, |
|
202 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | - ) { |
|
204 | - $class = trim($class, '\\'); |
|
205 | - $registered = false; |
|
206 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | - } |
|
209 | - // we need to make sure that any aliases used when registering a dependency |
|
210 | - // get resolved to the correct class name |
|
211 | - foreach ($dependencies as $dependency => $load_source) { |
|
212 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | - if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | - ) { |
|
216 | - unset($dependencies[ $dependency ]); |
|
217 | - $dependencies[ $alias ] = $load_source; |
|
218 | - $registered = true; |
|
219 | - } |
|
220 | - } |
|
221 | - // now add our two lists of dependencies together. |
|
222 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | - // so $dependencies is NOT overwritten because it is listed first |
|
224 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | - // Union is way faster than array_merge() but should be used with caution... |
|
226 | - // especially with numerically indexed arrays |
|
227 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | - // now we need to ensure that the resulting dependencies |
|
229 | - // array only has the entries that are required for the class |
|
230 | - // so first count how many dependencies were originally registered for the class |
|
231 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | - // if that count is non-zero (meaning dependencies were already registered) |
|
233 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | - // then truncate the final array to match that count |
|
235 | - ? array_slice($dependencies, 0, $dependency_count) |
|
236 | - // otherwise just take the incoming array because nothing previously existed |
|
237 | - : $dependencies; |
|
238 | - return $registered; |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - /** |
|
243 | - * @param string $class_name |
|
244 | - * @param string $loader |
|
245 | - * @return bool |
|
246 | - * @throws DomainException |
|
247 | - */ |
|
248 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | - { |
|
250 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | - throw new DomainException( |
|
252 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | - ); |
|
254 | - } |
|
255 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | - if (! is_callable($loader) |
|
257 | - && ( |
|
258 | - strpos($loader, 'load_') !== 0 |
|
259 | - || ! method_exists('EE_Registry', $loader) |
|
260 | - ) |
|
261 | - ) { |
|
262 | - throw new DomainException( |
|
263 | - sprintf( |
|
264 | - esc_html__( |
|
265 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | - 'event_espresso' |
|
267 | - ), |
|
268 | - $loader |
|
269 | - ) |
|
270 | - ); |
|
271 | - } |
|
272 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | - if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | - return true; |
|
276 | - } |
|
277 | - return false; |
|
278 | - } |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * @return array |
|
283 | - */ |
|
284 | - public function dependency_map() |
|
285 | - { |
|
286 | - return $this->_dependency_map; |
|
287 | - } |
|
288 | - |
|
289 | - |
|
290 | - /** |
|
291 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | - * |
|
293 | - * @param string $class_name |
|
294 | - * @return boolean |
|
295 | - */ |
|
296 | - public function has($class_name = '') |
|
297 | - { |
|
298 | - // all legacy models have the same dependencies |
|
299 | - if (strpos($class_name, 'EEM_') === 0) { |
|
300 | - $class_name = 'LEGACY_MODELS'; |
|
301 | - } |
|
302 | - return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | - } |
|
304 | - |
|
305 | - |
|
306 | - /** |
|
307 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | - * |
|
309 | - * @param string $class_name |
|
310 | - * @param string $dependency |
|
311 | - * @return bool |
|
312 | - */ |
|
313 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | - { |
|
315 | - // all legacy models have the same dependencies |
|
316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
317 | - $class_name = 'LEGACY_MODELS'; |
|
318 | - } |
|
319 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | - ? true |
|
322 | - : false; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | - * |
|
329 | - * @param string $class_name |
|
330 | - * @param string $dependency |
|
331 | - * @return int |
|
332 | - */ |
|
333 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | - { |
|
335 | - // all legacy models have the same dependencies |
|
336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
337 | - $class_name = 'LEGACY_MODELS'; |
|
338 | - } |
|
339 | - $dependency = $this->getFqnForAlias($dependency); |
|
340 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | - : EE_Dependency_Map::not_registered; |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @param string $class_name |
|
348 | - * @return string | Closure |
|
349 | - */ |
|
350 | - public function class_loader($class_name) |
|
351 | - { |
|
352 | - // all legacy models use load_model() |
|
353 | - if (strpos($class_name, 'EEM_') === 0) { |
|
354 | - return 'load_model'; |
|
355 | - } |
|
356 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
357 | - // perform strpos() first to avoid loading regex every time we load a class |
|
358 | - if (strpos($class_name, 'EE_CPT_') === 0 |
|
359 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
360 | - ) { |
|
361 | - return 'load_core'; |
|
362 | - } |
|
363 | - $class_name = $this->getFqnForAlias($class_name); |
|
364 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
365 | - } |
|
366 | - |
|
367 | - |
|
368 | - /** |
|
369 | - * @return array |
|
370 | - */ |
|
371 | - public function class_loaders() |
|
372 | - { |
|
373 | - return $this->_class_loaders; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * adds an alias for a classname |
|
379 | - * |
|
380 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
381 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
382 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
383 | - */ |
|
384 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
385 | - { |
|
386 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
387 | - } |
|
388 | - |
|
389 | - |
|
390 | - /** |
|
391 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
392 | - * WHY? |
|
393 | - * Because if a class is type hinting for a concretion, |
|
394 | - * then why would we need to find another class to supply it? |
|
395 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
396 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
397 | - * Don't go looking for some substitute. |
|
398 | - * Whereas if a class is type hinting for an interface... |
|
399 | - * then we need to find an actual class to use. |
|
400 | - * So the interface IS the alias for some other FQN, |
|
401 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
402 | - * represents some other class. |
|
403 | - * |
|
404 | - * @param string $fqn |
|
405 | - * @param string $for_class |
|
406 | - * @return bool |
|
407 | - */ |
|
408 | - public function isAlias($fqn = '', $for_class = '') |
|
409 | - { |
|
410 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
411 | - } |
|
412 | - |
|
413 | - |
|
414 | - /** |
|
415 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
416 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
417 | - * for example: |
|
418 | - * if the following two entries were added to the _aliases array: |
|
419 | - * array( |
|
420 | - * 'interface_alias' => 'some\namespace\interface' |
|
421 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
422 | - * ) |
|
423 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
424 | - * to load an instance of 'some\namespace\classname' |
|
425 | - * |
|
426 | - * @param string $alias |
|
427 | - * @param string $for_class |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
431 | - { |
|
432 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
433 | - } |
|
434 | - |
|
435 | - |
|
436 | - /** |
|
437 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
438 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
439 | - * This is done by using the following class constants: |
|
440 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
441 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
442 | - */ |
|
443 | - protected function _register_core_dependencies() |
|
444 | - { |
|
445 | - $this->_dependency_map = array( |
|
446 | - 'EE_Request_Handler' => array( |
|
447 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
448 | - ), |
|
449 | - 'EE_System' => array( |
|
450 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
451 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
452 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
454 | - ), |
|
455 | - 'EE_Session' => array( |
|
456 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
457 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
458 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
460 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
461 | - ), |
|
462 | - 'EE_Cart' => array( |
|
463 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
464 | - ), |
|
465 | - 'EE_Front_Controller' => array( |
|
466 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
467 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
469 | - ), |
|
470 | - 'EE_Messenger_Collection_Loader' => array( |
|
471 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
472 | - ), |
|
473 | - 'EE_Message_Type_Collection_Loader' => array( |
|
474 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
475 | - ), |
|
476 | - 'EE_Message_Resource_Manager' => array( |
|
477 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
478 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
479 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
480 | - ), |
|
481 | - 'EE_Message_Factory' => array( |
|
482 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
483 | - ), |
|
484 | - 'EE_messages' => array( |
|
485 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | - ), |
|
487 | - 'EE_Messages_Generator' => array( |
|
488 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
489 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
490 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
491 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
492 | - ), |
|
493 | - 'EE_Messages_Processor' => array( |
|
494 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
495 | - ), |
|
496 | - 'EE_Messages_Queue' => array( |
|
497 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
498 | - ), |
|
499 | - 'EE_Messages_Template_Defaults' => array( |
|
500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
502 | - ), |
|
503 | - 'EE_Message_To_Generate_From_Request' => array( |
|
504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
506 | - ), |
|
507 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
508 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
509 | - ), |
|
510 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
511 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
512 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
513 | - ), |
|
514 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
515 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
516 | - ), |
|
517 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
518 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
519 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
520 | - ), |
|
521 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
522 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | - ), |
|
524 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
525 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
526 | - ), |
|
527 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
528 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
529 | - ), |
|
530 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
531 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
532 | - ), |
|
533 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
534 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
535 | - ), |
|
536 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
537 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | - ), |
|
539 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
540 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | - ), |
|
542 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
543 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | - ), |
|
545 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
546 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | - ), |
|
548 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
549 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | - ), |
|
551 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
552 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
553 | - ), |
|
554 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
555 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | - ), |
|
557 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
558 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
559 | - ), |
|
560 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
561 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
562 | - ), |
|
563 | - 'EE_Data_Migration_Class_Base' => array( |
|
564 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | - ), |
|
567 | - 'EE_DMS_Core_4_1_0' => array( |
|
568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | - ), |
|
571 | - 'EE_DMS_Core_4_2_0' => array( |
|
572 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | - ), |
|
575 | - 'EE_DMS_Core_4_3_0' => array( |
|
576 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | - ), |
|
579 | - 'EE_DMS_Core_4_4_0' => array( |
|
580 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | - ), |
|
583 | - 'EE_DMS_Core_4_5_0' => array( |
|
584 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | - ), |
|
587 | - 'EE_DMS_Core_4_6_0' => array( |
|
588 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | - ), |
|
591 | - 'EE_DMS_Core_4_7_0' => array( |
|
592 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | - ), |
|
595 | - 'EE_DMS_Core_4_8_0' => array( |
|
596 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
597 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
598 | - ), |
|
599 | - 'EE_DMS_Core_4_9_0' => array( |
|
600 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
601 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
602 | - ), |
|
603 | - 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
604 | - array(), |
|
605 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
606 | - ), |
|
607 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
608 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
609 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
610 | - ), |
|
611 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
612 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
613 | - ), |
|
614 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
615 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
616 | - ), |
|
617 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
618 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
619 | - ), |
|
620 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
621 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
622 | - ), |
|
623 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
624 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
625 | - ), |
|
626 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
627 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
628 | - ), |
|
629 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
630 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
631 | - ), |
|
632 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
633 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | - ), |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
636 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | - ), |
|
638 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
639 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | - ), |
|
642 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
643 | - null, |
|
644 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | - ), |
|
646 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
647 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | - ), |
|
649 | - 'LEGACY_MODELS' => array( |
|
650 | - null, |
|
651 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | - ), |
|
653 | - 'EE_Module_Request_Router' => array( |
|
654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | - ), |
|
656 | - 'EE_Registration_Processor' => array( |
|
657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | - ), |
|
659 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
660 | - null, |
|
661 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | - ), |
|
664 | - 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
665 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
666 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
667 | - ), |
|
668 | - 'EE_Admin_Transactions_List_Table' => array( |
|
669 | - null, |
|
670 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
671 | - ), |
|
672 | - 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
673 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
674 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
675 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
676 | - ), |
|
677 | - 'EventEspresso\core\domain\services\pue\Config' => array( |
|
678 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
679 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | - ), |
|
681 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
682 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
683 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
684 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
685 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
686 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
687 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
688 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | - ), |
|
690 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
691 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
692 | - ), |
|
693 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
694 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
695 | - ), |
|
696 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
697 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
698 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | - ), |
|
700 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
701 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | - ), |
|
703 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
704 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
705 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
707 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
708 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
709 | - ), |
|
710 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
711 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
712 | - ), |
|
713 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
714 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
716 | - ), |
|
717 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
718 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
719 | - ), |
|
720 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
721 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
722 | - ), |
|
723 | - 'EE_CPT_Strategy' => array( |
|
724 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
726 | - ), |
|
727 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
728 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
729 | - ), |
|
730 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
731 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
732 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
733 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
735 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
736 | - ), |
|
737 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
738 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
739 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
740 | - ), |
|
741 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
742 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
743 | - ), |
|
744 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
745 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
746 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
747 | - ), |
|
748 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
749 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
750 | - ), |
|
751 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
752 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
753 | - ), |
|
754 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
755 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
756 | - ), |
|
757 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
758 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
759 | - ), |
|
760 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
761 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
762 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
763 | - ), |
|
764 | - 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
765 | - null, |
|
766 | - null, |
|
767 | - null, |
|
768 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
769 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
770 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
771 | - ), |
|
772 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
773 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
774 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
775 | - ), |
|
776 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
777 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
778 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
779 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
780 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
781 | - ), |
|
782 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
783 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
784 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
786 | - ), |
|
787 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
788 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
789 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
790 | - ), |
|
791 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
792 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
793 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
794 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
795 | - ), |
|
796 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
797 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
800 | - ), |
|
801 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
802 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
803 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
804 | - ), |
|
805 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
806 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
807 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
808 | - ), |
|
809 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
810 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
811 | - ), |
|
812 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
813 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
814 | - ), |
|
815 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
816 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
817 | - ), |
|
818 | - 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
819 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
820 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
821 | - ), |
|
822 | - 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
823 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
824 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
825 | - ), |
|
826 | - 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
827 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
828 | - ), |
|
829 | - 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
830 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
831 | - ), |
|
832 | - 'EE_URL_Validation_Strategy' => array( |
|
833 | - null, |
|
834 | - null, |
|
835 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
836 | - ), |
|
837 | - ); |
|
838 | - } |
|
839 | - |
|
840 | - |
|
841 | - /** |
|
842 | - * Registers how core classes are loaded. |
|
843 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
844 | - * 'EE_Request_Handler' => 'load_core' |
|
845 | - * 'EE_Messages_Queue' => 'load_lib' |
|
846 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
847 | - * or, if greater control is required, by providing a custom closure. For example: |
|
848 | - * 'Some_Class' => function () { |
|
849 | - * return new Some_Class(); |
|
850 | - * }, |
|
851 | - * This is required for instantiating dependencies |
|
852 | - * where an interface has been type hinted in a class constructor. For example: |
|
853 | - * 'Required_Interface' => function () { |
|
854 | - * return new A_Class_That_Implements_Required_Interface(); |
|
855 | - * }, |
|
856 | - */ |
|
857 | - protected function _register_core_class_loaders() |
|
858 | - { |
|
859 | - $this->_class_loaders = array( |
|
860 | - // load_core |
|
861 | - 'EE_Dependency_Map' => function () { |
|
862 | - return $this; |
|
863 | - }, |
|
864 | - 'EE_Capabilities' => 'load_core', |
|
865 | - 'EE_Encryption' => 'load_core', |
|
866 | - 'EE_Front_Controller' => 'load_core', |
|
867 | - 'EE_Module_Request_Router' => 'load_core', |
|
868 | - 'EE_Registry' => 'load_core', |
|
869 | - 'EE_Request' => function () { |
|
870 | - return $this->legacy_request; |
|
871 | - }, |
|
872 | - 'EventEspresso\core\services\request\Request' => function () { |
|
873 | - return $this->request; |
|
874 | - }, |
|
875 | - 'EventEspresso\core\services\request\Response' => function () { |
|
876 | - return $this->response; |
|
877 | - }, |
|
878 | - 'EE_Base' => 'load_core', |
|
879 | - 'EE_Request_Handler' => 'load_core', |
|
880 | - 'EE_Session' => 'load_core', |
|
881 | - 'EE_Cron_Tasks' => 'load_core', |
|
882 | - 'EE_System' => 'load_core', |
|
883 | - 'EE_Maintenance_Mode' => 'load_core', |
|
884 | - 'EE_Register_CPTs' => 'load_core', |
|
885 | - 'EE_Admin' => 'load_core', |
|
886 | - 'EE_CPT_Strategy' => 'load_core', |
|
887 | - // load_lib |
|
888 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
889 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
890 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
891 | - 'EE_Messenger_Collection' => 'load_lib', |
|
892 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
893 | - 'EE_Messages_Processor' => 'load_lib', |
|
894 | - 'EE_Message_Repository' => 'load_lib', |
|
895 | - 'EE_Messages_Queue' => 'load_lib', |
|
896 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
897 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
898 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
899 | - 'EE_Messages_Generator' => function () { |
|
900 | - return EE_Registry::instance()->load_lib( |
|
901 | - 'Messages_Generator', |
|
902 | - array(), |
|
903 | - false, |
|
904 | - false |
|
905 | - ); |
|
906 | - }, |
|
907 | - 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
908 | - return EE_Registry::instance()->load_lib( |
|
909 | - 'Messages_Template_Defaults', |
|
910 | - $arguments, |
|
911 | - false, |
|
912 | - false |
|
913 | - ); |
|
914 | - }, |
|
915 | - // load_helper |
|
916 | - 'EEH_Parse_Shortcodes' => function () { |
|
917 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
918 | - return new EEH_Parse_Shortcodes(); |
|
919 | - } |
|
920 | - return null; |
|
921 | - }, |
|
922 | - 'EE_Template_Config' => function () { |
|
923 | - return EE_Config::instance()->template_settings; |
|
924 | - }, |
|
925 | - 'EE_Currency_Config' => function () { |
|
926 | - return EE_Config::instance()->currency; |
|
927 | - }, |
|
928 | - 'EE_Registration_Config' => function () { |
|
929 | - return EE_Config::instance()->registration; |
|
930 | - }, |
|
931 | - 'EE_Core_Config' => function () { |
|
932 | - return EE_Config::instance()->core; |
|
933 | - }, |
|
934 | - 'EventEspresso\core\services\loaders\Loader' => function () { |
|
935 | - return LoaderFactory::getLoader(); |
|
936 | - }, |
|
937 | - 'EE_Network_Config' => function () { |
|
938 | - return EE_Network_Config::instance(); |
|
939 | - }, |
|
940 | - 'EE_Config' => function () { |
|
941 | - return EE_Config::instance(); |
|
942 | - }, |
|
943 | - 'EventEspresso\core\domain\Domain' => function () { |
|
944 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
945 | - }, |
|
946 | - 'EE_Admin_Config' => function () { |
|
947 | - return EE_Config::instance()->admin; |
|
948 | - }, |
|
949 | - ); |
|
950 | - } |
|
951 | - |
|
952 | - |
|
953 | - /** |
|
954 | - * can be used for supplying alternate names for classes, |
|
955 | - * or for connecting interface names to instantiable classes |
|
956 | - */ |
|
957 | - protected function _register_core_aliases() |
|
958 | - { |
|
959 | - $aliases = array( |
|
960 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
961 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
962 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
963 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
964 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
965 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
966 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
967 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
968 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
969 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
970 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
971 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
972 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
973 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
974 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
975 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
976 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
977 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
978 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
979 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
980 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
981 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
982 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
983 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
984 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
985 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
986 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
987 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
988 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
989 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
990 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
991 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
992 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
993 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
994 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
995 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
996 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
997 | - ); |
|
998 | - foreach ($aliases as $alias => $fqn) { |
|
999 | - if (is_array($fqn)) { |
|
1000 | - foreach ($fqn as $class => $for_class) { |
|
1001 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1002 | - } |
|
1003 | - continue; |
|
1004 | - } |
|
1005 | - $this->class_cache->addAlias($fqn, $alias); |
|
1006 | - } |
|
1007 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1008 | - $this->class_cache->addAlias( |
|
1009 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1010 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1011 | - ); |
|
1012 | - } |
|
1013 | - } |
|
1014 | - |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1018 | - * request Primarily used by unit tests. |
|
1019 | - */ |
|
1020 | - public function reset() |
|
1021 | - { |
|
1022 | - $this->_register_core_class_loaders(); |
|
1023 | - $this->_register_core_dependencies(); |
|
1024 | - } |
|
1025 | - |
|
1026 | - |
|
1027 | - /** |
|
1028 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1029 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1030 | - * WHY? |
|
1031 | - * Because if a class is type hinting for a concretion, |
|
1032 | - * then why would we need to find another class to supply it? |
|
1033 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1034 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1035 | - * Don't go looking for some substitute. |
|
1036 | - * Whereas if a class is type hinting for an interface... |
|
1037 | - * then we need to find an actual class to use. |
|
1038 | - * So the interface IS the alias for some other FQN, |
|
1039 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1040 | - * represents some other class. |
|
1041 | - * |
|
1042 | - * @deprecated 4.9.62.p |
|
1043 | - * @param string $fqn |
|
1044 | - * @param string $for_class |
|
1045 | - * @return bool |
|
1046 | - */ |
|
1047 | - public function has_alias($fqn = '', $for_class = '') |
|
1048 | - { |
|
1049 | - return $this->isAlias($fqn, $for_class); |
|
1050 | - } |
|
1051 | - |
|
1052 | - |
|
1053 | - /** |
|
1054 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1055 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1056 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1057 | - * for example: |
|
1058 | - * if the following two entries were added to the _aliases array: |
|
1059 | - * array( |
|
1060 | - * 'interface_alias' => 'some\namespace\interface' |
|
1061 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1062 | - * ) |
|
1063 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1064 | - * to load an instance of 'some\namespace\classname' |
|
1065 | - * |
|
1066 | - * @deprecated 4.9.62.p |
|
1067 | - * @param string $alias |
|
1068 | - * @param string $for_class |
|
1069 | - * @return string |
|
1070 | - */ |
|
1071 | - public function get_alias($alias = '', $for_class = '') |
|
1072 | - { |
|
1073 | - return $this->getFqnForAlias($alias, $for_class); |
|
1074 | - } |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @type EE_Dependency_Map $_instance |
|
55 | + */ |
|
56 | + protected static $_instance; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var ClassInterfaceCache $class_cache |
|
60 | + */ |
|
61 | + private $class_cache; |
|
62 | + |
|
63 | + /** |
|
64 | + * @type RequestInterface $request |
|
65 | + */ |
|
66 | + protected $request; |
|
67 | + |
|
68 | + /** |
|
69 | + * @type LegacyRequestInterface $legacy_request |
|
70 | + */ |
|
71 | + protected $legacy_request; |
|
72 | + |
|
73 | + /** |
|
74 | + * @type ResponseInterface $response |
|
75 | + */ |
|
76 | + protected $response; |
|
77 | + |
|
78 | + /** |
|
79 | + * @type LoaderInterface $loader |
|
80 | + */ |
|
81 | + protected $loader; |
|
82 | + |
|
83 | + /** |
|
84 | + * @type array $_dependency_map |
|
85 | + */ |
|
86 | + protected $_dependency_map = array(); |
|
87 | + |
|
88 | + /** |
|
89 | + * @type array $_class_loaders |
|
90 | + */ |
|
91 | + protected $_class_loaders = array(); |
|
92 | + |
|
93 | + |
|
94 | + /** |
|
95 | + * EE_Dependency_Map constructor. |
|
96 | + * |
|
97 | + * @param ClassInterfaceCache $class_cache |
|
98 | + */ |
|
99 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
100 | + { |
|
101 | + $this->class_cache = $class_cache; |
|
102 | + do_action('EE_Dependency_Map____construct', $this); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * @return void |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if (! self::$_instance instanceof EE_Dependency_Map |
|
126 | + && $class_cache instanceof ClassInterfaceCache |
|
127 | + ) { |
|
128 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
129 | + } |
|
130 | + return self::$_instance; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param RequestInterface $request |
|
136 | + */ |
|
137 | + public function setRequest(RequestInterface $request) |
|
138 | + { |
|
139 | + $this->request = $request; |
|
140 | + } |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @param LegacyRequestInterface $legacy_request |
|
145 | + */ |
|
146 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
147 | + { |
|
148 | + $this->legacy_request = $legacy_request; |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + /** |
|
153 | + * @param ResponseInterface $response |
|
154 | + */ |
|
155 | + public function setResponse(ResponseInterface $response) |
|
156 | + { |
|
157 | + $this->response = $response; |
|
158 | + } |
|
159 | + |
|
160 | + |
|
161 | + /** |
|
162 | + * @param LoaderInterface $loader |
|
163 | + */ |
|
164 | + public function setLoader(LoaderInterface $loader) |
|
165 | + { |
|
166 | + $this->loader = $loader; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param string $class |
|
172 | + * @param array $dependencies |
|
173 | + * @param int $overwrite |
|
174 | + * @return bool |
|
175 | + */ |
|
176 | + public static function register_dependencies( |
|
177 | + $class, |
|
178 | + array $dependencies, |
|
179 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
180 | + ) { |
|
181 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + /** |
|
186 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
187 | + * to the class specified by the first parameter. |
|
188 | + * IMPORTANT !!! |
|
189 | + * The order of elements in the incoming $dependencies array MUST match |
|
190 | + * the order of the constructor parameters for the class in question. |
|
191 | + * This is especially important when overriding any existing dependencies that are registered. |
|
192 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
193 | + * |
|
194 | + * @param string $class |
|
195 | + * @param array $dependencies |
|
196 | + * @param int $overwrite |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function registerDependencies( |
|
200 | + $class, |
|
201 | + array $dependencies, |
|
202 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
203 | + ) { |
|
204 | + $class = trim($class, '\\'); |
|
205 | + $registered = false; |
|
206 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
207 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
208 | + } |
|
209 | + // we need to make sure that any aliases used when registering a dependency |
|
210 | + // get resolved to the correct class name |
|
211 | + foreach ($dependencies as $dependency => $load_source) { |
|
212 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
213 | + if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
214 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
215 | + ) { |
|
216 | + unset($dependencies[ $dependency ]); |
|
217 | + $dependencies[ $alias ] = $load_source; |
|
218 | + $registered = true; |
|
219 | + } |
|
220 | + } |
|
221 | + // now add our two lists of dependencies together. |
|
222 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
223 | + // so $dependencies is NOT overwritten because it is listed first |
|
224 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
225 | + // Union is way faster than array_merge() but should be used with caution... |
|
226 | + // especially with numerically indexed arrays |
|
227 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
228 | + // now we need to ensure that the resulting dependencies |
|
229 | + // array only has the entries that are required for the class |
|
230 | + // so first count how many dependencies were originally registered for the class |
|
231 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
232 | + // if that count is non-zero (meaning dependencies were already registered) |
|
233 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
234 | + // then truncate the final array to match that count |
|
235 | + ? array_slice($dependencies, 0, $dependency_count) |
|
236 | + // otherwise just take the incoming array because nothing previously existed |
|
237 | + : $dependencies; |
|
238 | + return $registered; |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + /** |
|
243 | + * @param string $class_name |
|
244 | + * @param string $loader |
|
245 | + * @return bool |
|
246 | + * @throws DomainException |
|
247 | + */ |
|
248 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
249 | + { |
|
250 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
251 | + throw new DomainException( |
|
252 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
253 | + ); |
|
254 | + } |
|
255 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
256 | + if (! is_callable($loader) |
|
257 | + && ( |
|
258 | + strpos($loader, 'load_') !== 0 |
|
259 | + || ! method_exists('EE_Registry', $loader) |
|
260 | + ) |
|
261 | + ) { |
|
262 | + throw new DomainException( |
|
263 | + sprintf( |
|
264 | + esc_html__( |
|
265 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
266 | + 'event_espresso' |
|
267 | + ), |
|
268 | + $loader |
|
269 | + ) |
|
270 | + ); |
|
271 | + } |
|
272 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
273 | + if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
274 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
275 | + return true; |
|
276 | + } |
|
277 | + return false; |
|
278 | + } |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * @return array |
|
283 | + */ |
|
284 | + public function dependency_map() |
|
285 | + { |
|
286 | + return $this->_dependency_map; |
|
287 | + } |
|
288 | + |
|
289 | + |
|
290 | + /** |
|
291 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
292 | + * |
|
293 | + * @param string $class_name |
|
294 | + * @return boolean |
|
295 | + */ |
|
296 | + public function has($class_name = '') |
|
297 | + { |
|
298 | + // all legacy models have the same dependencies |
|
299 | + if (strpos($class_name, 'EEM_') === 0) { |
|
300 | + $class_name = 'LEGACY_MODELS'; |
|
301 | + } |
|
302 | + return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
303 | + } |
|
304 | + |
|
305 | + |
|
306 | + /** |
|
307 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
308 | + * |
|
309 | + * @param string $class_name |
|
310 | + * @param string $dependency |
|
311 | + * @return bool |
|
312 | + */ |
|
313 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
314 | + { |
|
315 | + // all legacy models have the same dependencies |
|
316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
317 | + $class_name = 'LEGACY_MODELS'; |
|
318 | + } |
|
319 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
320 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
321 | + ? true |
|
322 | + : false; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
328 | + * |
|
329 | + * @param string $class_name |
|
330 | + * @param string $dependency |
|
331 | + * @return int |
|
332 | + */ |
|
333 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
334 | + { |
|
335 | + // all legacy models have the same dependencies |
|
336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
337 | + $class_name = 'LEGACY_MODELS'; |
|
338 | + } |
|
339 | + $dependency = $this->getFqnForAlias($dependency); |
|
340 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
341 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
342 | + : EE_Dependency_Map::not_registered; |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @param string $class_name |
|
348 | + * @return string | Closure |
|
349 | + */ |
|
350 | + public function class_loader($class_name) |
|
351 | + { |
|
352 | + // all legacy models use load_model() |
|
353 | + if (strpos($class_name, 'EEM_') === 0) { |
|
354 | + return 'load_model'; |
|
355 | + } |
|
356 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
357 | + // perform strpos() first to avoid loading regex every time we load a class |
|
358 | + if (strpos($class_name, 'EE_CPT_') === 0 |
|
359 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
360 | + ) { |
|
361 | + return 'load_core'; |
|
362 | + } |
|
363 | + $class_name = $this->getFqnForAlias($class_name); |
|
364 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
365 | + } |
|
366 | + |
|
367 | + |
|
368 | + /** |
|
369 | + * @return array |
|
370 | + */ |
|
371 | + public function class_loaders() |
|
372 | + { |
|
373 | + return $this->_class_loaders; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * adds an alias for a classname |
|
379 | + * |
|
380 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
381 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
382 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
383 | + */ |
|
384 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
385 | + { |
|
386 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
387 | + } |
|
388 | + |
|
389 | + |
|
390 | + /** |
|
391 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
392 | + * WHY? |
|
393 | + * Because if a class is type hinting for a concretion, |
|
394 | + * then why would we need to find another class to supply it? |
|
395 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
396 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
397 | + * Don't go looking for some substitute. |
|
398 | + * Whereas if a class is type hinting for an interface... |
|
399 | + * then we need to find an actual class to use. |
|
400 | + * So the interface IS the alias for some other FQN, |
|
401 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
402 | + * represents some other class. |
|
403 | + * |
|
404 | + * @param string $fqn |
|
405 | + * @param string $for_class |
|
406 | + * @return bool |
|
407 | + */ |
|
408 | + public function isAlias($fqn = '', $for_class = '') |
|
409 | + { |
|
410 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
411 | + } |
|
412 | + |
|
413 | + |
|
414 | + /** |
|
415 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
416 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
417 | + * for example: |
|
418 | + * if the following two entries were added to the _aliases array: |
|
419 | + * array( |
|
420 | + * 'interface_alias' => 'some\namespace\interface' |
|
421 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
422 | + * ) |
|
423 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
424 | + * to load an instance of 'some\namespace\classname' |
|
425 | + * |
|
426 | + * @param string $alias |
|
427 | + * @param string $for_class |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
431 | + { |
|
432 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
433 | + } |
|
434 | + |
|
435 | + |
|
436 | + /** |
|
437 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
438 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
439 | + * This is done by using the following class constants: |
|
440 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
441 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
442 | + */ |
|
443 | + protected function _register_core_dependencies() |
|
444 | + { |
|
445 | + $this->_dependency_map = array( |
|
446 | + 'EE_Request_Handler' => array( |
|
447 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
448 | + ), |
|
449 | + 'EE_System' => array( |
|
450 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
451 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
452 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
453 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
454 | + ), |
|
455 | + 'EE_Session' => array( |
|
456 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
457 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
458 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
459 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
460 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
461 | + ), |
|
462 | + 'EE_Cart' => array( |
|
463 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
464 | + ), |
|
465 | + 'EE_Front_Controller' => array( |
|
466 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
467 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
468 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
469 | + ), |
|
470 | + 'EE_Messenger_Collection_Loader' => array( |
|
471 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
472 | + ), |
|
473 | + 'EE_Message_Type_Collection_Loader' => array( |
|
474 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
475 | + ), |
|
476 | + 'EE_Message_Resource_Manager' => array( |
|
477 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
478 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
479 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
480 | + ), |
|
481 | + 'EE_Message_Factory' => array( |
|
482 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
483 | + ), |
|
484 | + 'EE_messages' => array( |
|
485 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
486 | + ), |
|
487 | + 'EE_Messages_Generator' => array( |
|
488 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
489 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
490 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
491 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
492 | + ), |
|
493 | + 'EE_Messages_Processor' => array( |
|
494 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
495 | + ), |
|
496 | + 'EE_Messages_Queue' => array( |
|
497 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
498 | + ), |
|
499 | + 'EE_Messages_Template_Defaults' => array( |
|
500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
502 | + ), |
|
503 | + 'EE_Message_To_Generate_From_Request' => array( |
|
504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
506 | + ), |
|
507 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
508 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
509 | + ), |
|
510 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
511 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
512 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
513 | + ), |
|
514 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
515 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
516 | + ), |
|
517 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
518 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
519 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
520 | + ), |
|
521 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
522 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
523 | + ), |
|
524 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
525 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
526 | + ), |
|
527 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
528 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
529 | + ), |
|
530 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
531 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
532 | + ), |
|
533 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
534 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
535 | + ), |
|
536 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
537 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
538 | + ), |
|
539 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
540 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
541 | + ), |
|
542 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
543 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
544 | + ), |
|
545 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
546 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
547 | + ), |
|
548 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
549 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
550 | + ), |
|
551 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
552 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
553 | + ), |
|
554 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
555 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
556 | + ), |
|
557 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
558 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
559 | + ), |
|
560 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
561 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
562 | + ), |
|
563 | + 'EE_Data_Migration_Class_Base' => array( |
|
564 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
565 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
566 | + ), |
|
567 | + 'EE_DMS_Core_4_1_0' => array( |
|
568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
569 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
570 | + ), |
|
571 | + 'EE_DMS_Core_4_2_0' => array( |
|
572 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
573 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
574 | + ), |
|
575 | + 'EE_DMS_Core_4_3_0' => array( |
|
576 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
577 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
578 | + ), |
|
579 | + 'EE_DMS_Core_4_4_0' => array( |
|
580 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
581 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
582 | + ), |
|
583 | + 'EE_DMS_Core_4_5_0' => array( |
|
584 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
585 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
586 | + ), |
|
587 | + 'EE_DMS_Core_4_6_0' => array( |
|
588 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
589 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
590 | + ), |
|
591 | + 'EE_DMS_Core_4_7_0' => array( |
|
592 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
593 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
594 | + ), |
|
595 | + 'EE_DMS_Core_4_8_0' => array( |
|
596 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
597 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
598 | + ), |
|
599 | + 'EE_DMS_Core_4_9_0' => array( |
|
600 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
601 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
602 | + ), |
|
603 | + 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
604 | + array(), |
|
605 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
606 | + ), |
|
607 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
608 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
609 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
610 | + ), |
|
611 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
612 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
613 | + ), |
|
614 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
615 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
616 | + ), |
|
617 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
618 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
619 | + ), |
|
620 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
621 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
622 | + ), |
|
623 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
624 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
625 | + ), |
|
626 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
627 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
628 | + ), |
|
629 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
630 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
631 | + ), |
|
632 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
633 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | + ), |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
636 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | + ), |
|
638 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
639 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
640 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
641 | + ), |
|
642 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
643 | + null, |
|
644 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | + ), |
|
646 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
647 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | + ), |
|
649 | + 'LEGACY_MODELS' => array( |
|
650 | + null, |
|
651 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | + ), |
|
653 | + 'EE_Module_Request_Router' => array( |
|
654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | + ), |
|
656 | + 'EE_Registration_Processor' => array( |
|
657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | + ), |
|
659 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
660 | + null, |
|
661 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
662 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
663 | + ), |
|
664 | + 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
665 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
666 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
667 | + ), |
|
668 | + 'EE_Admin_Transactions_List_Table' => array( |
|
669 | + null, |
|
670 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
671 | + ), |
|
672 | + 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
673 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
674 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
675 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
676 | + ), |
|
677 | + 'EventEspresso\core\domain\services\pue\Config' => array( |
|
678 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
679 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
680 | + ), |
|
681 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
682 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
683 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
684 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
685 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
686 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
687 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
688 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
689 | + ), |
|
690 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
691 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
692 | + ), |
|
693 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
694 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
695 | + ), |
|
696 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
697 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
698 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
699 | + ), |
|
700 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
701 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
702 | + ), |
|
703 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
704 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
705 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
707 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
708 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
709 | + ), |
|
710 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
711 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
712 | + ), |
|
713 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
714 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
716 | + ), |
|
717 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
718 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
719 | + ), |
|
720 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
721 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
722 | + ), |
|
723 | + 'EE_CPT_Strategy' => array( |
|
724 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
725 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
726 | + ), |
|
727 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
728 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
729 | + ), |
|
730 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
731 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
732 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
733 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
734 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
735 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
736 | + ), |
|
737 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
738 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
739 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
740 | + ), |
|
741 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
742 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
743 | + ), |
|
744 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
745 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
746 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
747 | + ), |
|
748 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
749 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
750 | + ), |
|
751 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
752 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
753 | + ), |
|
754 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
755 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
756 | + ), |
|
757 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
758 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
759 | + ), |
|
760 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
761 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
762 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
763 | + ), |
|
764 | + 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
765 | + null, |
|
766 | + null, |
|
767 | + null, |
|
768 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
769 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
770 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
771 | + ), |
|
772 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
773 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
774 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
775 | + ), |
|
776 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
777 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
778 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
779 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
780 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
781 | + ), |
|
782 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
783 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
784 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
785 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
786 | + ), |
|
787 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
788 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
789 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
790 | + ), |
|
791 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
792 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
793 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
794 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
795 | + ), |
|
796 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
797 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
800 | + ), |
|
801 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
802 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
803 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
804 | + ), |
|
805 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
806 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
807 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
808 | + ), |
|
809 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
810 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
811 | + ), |
|
812 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
813 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
814 | + ), |
|
815 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
816 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
817 | + ), |
|
818 | + 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
819 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
820 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
821 | + ), |
|
822 | + 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
823 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
824 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
825 | + ), |
|
826 | + 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
827 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
828 | + ), |
|
829 | + 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
830 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
831 | + ), |
|
832 | + 'EE_URL_Validation_Strategy' => array( |
|
833 | + null, |
|
834 | + null, |
|
835 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
836 | + ), |
|
837 | + ); |
|
838 | + } |
|
839 | + |
|
840 | + |
|
841 | + /** |
|
842 | + * Registers how core classes are loaded. |
|
843 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
844 | + * 'EE_Request_Handler' => 'load_core' |
|
845 | + * 'EE_Messages_Queue' => 'load_lib' |
|
846 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
847 | + * or, if greater control is required, by providing a custom closure. For example: |
|
848 | + * 'Some_Class' => function () { |
|
849 | + * return new Some_Class(); |
|
850 | + * }, |
|
851 | + * This is required for instantiating dependencies |
|
852 | + * where an interface has been type hinted in a class constructor. For example: |
|
853 | + * 'Required_Interface' => function () { |
|
854 | + * return new A_Class_That_Implements_Required_Interface(); |
|
855 | + * }, |
|
856 | + */ |
|
857 | + protected function _register_core_class_loaders() |
|
858 | + { |
|
859 | + $this->_class_loaders = array( |
|
860 | + // load_core |
|
861 | + 'EE_Dependency_Map' => function () { |
|
862 | + return $this; |
|
863 | + }, |
|
864 | + 'EE_Capabilities' => 'load_core', |
|
865 | + 'EE_Encryption' => 'load_core', |
|
866 | + 'EE_Front_Controller' => 'load_core', |
|
867 | + 'EE_Module_Request_Router' => 'load_core', |
|
868 | + 'EE_Registry' => 'load_core', |
|
869 | + 'EE_Request' => function () { |
|
870 | + return $this->legacy_request; |
|
871 | + }, |
|
872 | + 'EventEspresso\core\services\request\Request' => function () { |
|
873 | + return $this->request; |
|
874 | + }, |
|
875 | + 'EventEspresso\core\services\request\Response' => function () { |
|
876 | + return $this->response; |
|
877 | + }, |
|
878 | + 'EE_Base' => 'load_core', |
|
879 | + 'EE_Request_Handler' => 'load_core', |
|
880 | + 'EE_Session' => 'load_core', |
|
881 | + 'EE_Cron_Tasks' => 'load_core', |
|
882 | + 'EE_System' => 'load_core', |
|
883 | + 'EE_Maintenance_Mode' => 'load_core', |
|
884 | + 'EE_Register_CPTs' => 'load_core', |
|
885 | + 'EE_Admin' => 'load_core', |
|
886 | + 'EE_CPT_Strategy' => 'load_core', |
|
887 | + // load_lib |
|
888 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
889 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
890 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
891 | + 'EE_Messenger_Collection' => 'load_lib', |
|
892 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
893 | + 'EE_Messages_Processor' => 'load_lib', |
|
894 | + 'EE_Message_Repository' => 'load_lib', |
|
895 | + 'EE_Messages_Queue' => 'load_lib', |
|
896 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
897 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
898 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
899 | + 'EE_Messages_Generator' => function () { |
|
900 | + return EE_Registry::instance()->load_lib( |
|
901 | + 'Messages_Generator', |
|
902 | + array(), |
|
903 | + false, |
|
904 | + false |
|
905 | + ); |
|
906 | + }, |
|
907 | + 'EE_Messages_Template_Defaults' => function ($arguments = array()) { |
|
908 | + return EE_Registry::instance()->load_lib( |
|
909 | + 'Messages_Template_Defaults', |
|
910 | + $arguments, |
|
911 | + false, |
|
912 | + false |
|
913 | + ); |
|
914 | + }, |
|
915 | + // load_helper |
|
916 | + 'EEH_Parse_Shortcodes' => function () { |
|
917 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
918 | + return new EEH_Parse_Shortcodes(); |
|
919 | + } |
|
920 | + return null; |
|
921 | + }, |
|
922 | + 'EE_Template_Config' => function () { |
|
923 | + return EE_Config::instance()->template_settings; |
|
924 | + }, |
|
925 | + 'EE_Currency_Config' => function () { |
|
926 | + return EE_Config::instance()->currency; |
|
927 | + }, |
|
928 | + 'EE_Registration_Config' => function () { |
|
929 | + return EE_Config::instance()->registration; |
|
930 | + }, |
|
931 | + 'EE_Core_Config' => function () { |
|
932 | + return EE_Config::instance()->core; |
|
933 | + }, |
|
934 | + 'EventEspresso\core\services\loaders\Loader' => function () { |
|
935 | + return LoaderFactory::getLoader(); |
|
936 | + }, |
|
937 | + 'EE_Network_Config' => function () { |
|
938 | + return EE_Network_Config::instance(); |
|
939 | + }, |
|
940 | + 'EE_Config' => function () { |
|
941 | + return EE_Config::instance(); |
|
942 | + }, |
|
943 | + 'EventEspresso\core\domain\Domain' => function () { |
|
944 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
945 | + }, |
|
946 | + 'EE_Admin_Config' => function () { |
|
947 | + return EE_Config::instance()->admin; |
|
948 | + }, |
|
949 | + ); |
|
950 | + } |
|
951 | + |
|
952 | + |
|
953 | + /** |
|
954 | + * can be used for supplying alternate names for classes, |
|
955 | + * or for connecting interface names to instantiable classes |
|
956 | + */ |
|
957 | + protected function _register_core_aliases() |
|
958 | + { |
|
959 | + $aliases = array( |
|
960 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
961 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
962 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
963 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
964 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
965 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
966 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
967 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
968 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
969 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
970 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
971 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
972 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
973 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
974 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
975 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
976 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
977 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
978 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
979 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
980 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
981 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
982 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
983 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
984 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
985 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
986 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
987 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
988 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
989 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
990 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
991 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
992 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
993 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
994 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
995 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
996 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
997 | + ); |
|
998 | + foreach ($aliases as $alias => $fqn) { |
|
999 | + if (is_array($fqn)) { |
|
1000 | + foreach ($fqn as $class => $for_class) { |
|
1001 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1002 | + } |
|
1003 | + continue; |
|
1004 | + } |
|
1005 | + $this->class_cache->addAlias($fqn, $alias); |
|
1006 | + } |
|
1007 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1008 | + $this->class_cache->addAlias( |
|
1009 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1010 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1011 | + ); |
|
1012 | + } |
|
1013 | + } |
|
1014 | + |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1018 | + * request Primarily used by unit tests. |
|
1019 | + */ |
|
1020 | + public function reset() |
|
1021 | + { |
|
1022 | + $this->_register_core_class_loaders(); |
|
1023 | + $this->_register_core_dependencies(); |
|
1024 | + } |
|
1025 | + |
|
1026 | + |
|
1027 | + /** |
|
1028 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1029 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1030 | + * WHY? |
|
1031 | + * Because if a class is type hinting for a concretion, |
|
1032 | + * then why would we need to find another class to supply it? |
|
1033 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1034 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1035 | + * Don't go looking for some substitute. |
|
1036 | + * Whereas if a class is type hinting for an interface... |
|
1037 | + * then we need to find an actual class to use. |
|
1038 | + * So the interface IS the alias for some other FQN, |
|
1039 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1040 | + * represents some other class. |
|
1041 | + * |
|
1042 | + * @deprecated 4.9.62.p |
|
1043 | + * @param string $fqn |
|
1044 | + * @param string $for_class |
|
1045 | + * @return bool |
|
1046 | + */ |
|
1047 | + public function has_alias($fqn = '', $for_class = '') |
|
1048 | + { |
|
1049 | + return $this->isAlias($fqn, $for_class); |
|
1050 | + } |
|
1051 | + |
|
1052 | + |
|
1053 | + /** |
|
1054 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1055 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1056 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1057 | + * for example: |
|
1058 | + * if the following two entries were added to the _aliases array: |
|
1059 | + * array( |
|
1060 | + * 'interface_alias' => 'some\namespace\interface' |
|
1061 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1062 | + * ) |
|
1063 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1064 | + * to load an instance of 'some\namespace\classname' |
|
1065 | + * |
|
1066 | + * @deprecated 4.9.62.p |
|
1067 | + * @param string $alias |
|
1068 | + * @param string $for_class |
|
1069 | + * @return string |
|
1070 | + */ |
|
1071 | + public function get_alias($alias = '', $for_class = '') |
|
1072 | + { |
|
1073 | + return $this->getFqnForAlias($alias, $for_class); |
|
1074 | + } |
|
1075 | 1075 | } |
@@ -21,172 +21,172 @@ |
||
21 | 21 | class EventAttendees extends Block |
22 | 22 | { |
23 | 23 | |
24 | - const BLOCK_TYPE = 'event-attendees'; |
|
24 | + const BLOCK_TYPE = 'event-attendees'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @var EventAttendeesBlockRenderer $renderer |
|
28 | - */ |
|
29 | - protected $renderer; |
|
26 | + /** |
|
27 | + * @var EventAttendeesBlockRenderer $renderer |
|
28 | + */ |
|
29 | + protected $renderer; |
|
30 | 30 | |
31 | 31 | |
32 | - /** |
|
33 | - * EventAttendees constructor. |
|
34 | - * |
|
35 | - * @param CoreBlocksAssetManager $block_asset_manager |
|
36 | - * @param RequestInterface $request |
|
37 | - * @param EventAttendeesBlockRenderer $renderer |
|
38 | - */ |
|
39 | - public function __construct( |
|
40 | - CoreBlocksAssetManager $block_asset_manager, |
|
41 | - RequestInterface $request, |
|
42 | - EventAttendeesBlockRenderer $renderer |
|
43 | - ) { |
|
44 | - parent::__construct($block_asset_manager, $request); |
|
45 | - $this->renderer= $renderer; |
|
46 | - } |
|
32 | + /** |
|
33 | + * EventAttendees constructor. |
|
34 | + * |
|
35 | + * @param CoreBlocksAssetManager $block_asset_manager |
|
36 | + * @param RequestInterface $request |
|
37 | + * @param EventAttendeesBlockRenderer $renderer |
|
38 | + */ |
|
39 | + public function __construct( |
|
40 | + CoreBlocksAssetManager $block_asset_manager, |
|
41 | + RequestInterface $request, |
|
42 | + EventAttendeesBlockRenderer $renderer |
|
43 | + ) { |
|
44 | + parent::__construct($block_asset_manager, $request); |
|
45 | + $this->renderer= $renderer; |
|
46 | + } |
|
47 | 47 | |
48 | 48 | |
49 | - /** |
|
50 | - * Perform any early setup required by the block |
|
51 | - * including setting the block type and supported post types |
|
52 | - * |
|
53 | - * @return void |
|
54 | - */ |
|
55 | - public function initialize() |
|
56 | - { |
|
57 | - $this->setBlockType(self::BLOCK_TYPE); |
|
58 | - $this->setSupportedRoutes( |
|
59 | - array( |
|
60 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor', |
|
61 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor', |
|
62 | - 'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer', |
|
63 | - 'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest' |
|
64 | - ) |
|
65 | - ); |
|
66 | - $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
67 | - ? $this->request->getRequestParam('post', 0) |
|
68 | - : 0; |
|
69 | - $this->setAttributes( |
|
70 | - array( |
|
71 | - 'eventId' => array( |
|
72 | - 'type' => 'number', |
|
73 | - 'default' => $EVT_ID, |
|
74 | - ), |
|
75 | - 'datetimeId' => array( |
|
76 | - 'type' => 'number', |
|
77 | - 'default' => 0, |
|
78 | - ), |
|
79 | - 'ticketId' => array( |
|
80 | - 'type' => 'number', |
|
81 | - 'default' => 0, |
|
82 | - ), |
|
83 | - 'status' => array( |
|
84 | - 'type' => 'string', |
|
85 | - 'default' => EEM_Registration::status_id_approved, |
|
86 | - ), |
|
87 | - 'limit' => array( |
|
88 | - 'type' => 'number', |
|
89 | - 'default' => 10, |
|
90 | - ), |
|
91 | - 'order' => array( |
|
92 | - 'type' => 'string', |
|
93 | - 'default' => 'ASC' |
|
94 | - ), |
|
95 | - 'orderBy' => array( |
|
96 | - 'type' => 'string', |
|
97 | - 'default' => 'lastThenFirstName', |
|
98 | - ), |
|
99 | - 'showGravatar' => array( |
|
100 | - 'type' => 'boolean', |
|
101 | - 'default' => false, |
|
102 | - ), |
|
103 | - 'avatarClass' => array( |
|
104 | - 'type' => 'string', |
|
105 | - 'default' => 'contact', |
|
106 | - ), |
|
107 | - 'avatarSize' => array( |
|
108 | - 'type' => 'number', |
|
109 | - 'default' => 24, |
|
110 | - ), |
|
111 | - 'displayOnArchives' => array( |
|
112 | - 'type' => 'boolean', |
|
113 | - 'default' => false, |
|
114 | - ), |
|
115 | - ) |
|
116 | - ); |
|
117 | - $this->setDynamic(); |
|
118 | - } |
|
49 | + /** |
|
50 | + * Perform any early setup required by the block |
|
51 | + * including setting the block type and supported post types |
|
52 | + * |
|
53 | + * @return void |
|
54 | + */ |
|
55 | + public function initialize() |
|
56 | + { |
|
57 | + $this->setBlockType(self::BLOCK_TYPE); |
|
58 | + $this->setSupportedRoutes( |
|
59 | + array( |
|
60 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoStandardPostTypeEditor', |
|
61 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPostTypeEditor', |
|
62 | + 'EventEspresso\core\domain\entities\route_match\specifications\frontend\EspressoBlockRenderer', |
|
63 | + 'EventEspresso\core\domain\entities\route_match\specifications\frontend\AnyFrontendRequest' |
|
64 | + ) |
|
65 | + ); |
|
66 | + $EVT_ID = $this->request->getRequestParam('page') === 'espresso_events' |
|
67 | + ? $this->request->getRequestParam('post', 0) |
|
68 | + : 0; |
|
69 | + $this->setAttributes( |
|
70 | + array( |
|
71 | + 'eventId' => array( |
|
72 | + 'type' => 'number', |
|
73 | + 'default' => $EVT_ID, |
|
74 | + ), |
|
75 | + 'datetimeId' => array( |
|
76 | + 'type' => 'number', |
|
77 | + 'default' => 0, |
|
78 | + ), |
|
79 | + 'ticketId' => array( |
|
80 | + 'type' => 'number', |
|
81 | + 'default' => 0, |
|
82 | + ), |
|
83 | + 'status' => array( |
|
84 | + 'type' => 'string', |
|
85 | + 'default' => EEM_Registration::status_id_approved, |
|
86 | + ), |
|
87 | + 'limit' => array( |
|
88 | + 'type' => 'number', |
|
89 | + 'default' => 10, |
|
90 | + ), |
|
91 | + 'order' => array( |
|
92 | + 'type' => 'string', |
|
93 | + 'default' => 'ASC' |
|
94 | + ), |
|
95 | + 'orderBy' => array( |
|
96 | + 'type' => 'string', |
|
97 | + 'default' => 'lastThenFirstName', |
|
98 | + ), |
|
99 | + 'showGravatar' => array( |
|
100 | + 'type' => 'boolean', |
|
101 | + 'default' => false, |
|
102 | + ), |
|
103 | + 'avatarClass' => array( |
|
104 | + 'type' => 'string', |
|
105 | + 'default' => 'contact', |
|
106 | + ), |
|
107 | + 'avatarSize' => array( |
|
108 | + 'type' => 'number', |
|
109 | + 'default' => 24, |
|
110 | + ), |
|
111 | + 'displayOnArchives' => array( |
|
112 | + 'type' => 'boolean', |
|
113 | + 'default' => false, |
|
114 | + ), |
|
115 | + ) |
|
116 | + ); |
|
117 | + $this->setDynamic(); |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | - /** |
|
122 | - * Returns an array where the key corresponds to the incoming attribute name from the WP block |
|
123 | - * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
124 | - * |
|
125 | - * @since $VID:$ |
|
126 | - * @return array |
|
127 | - */ |
|
128 | - private function getAttributesMap() |
|
129 | - { |
|
130 | - return array( |
|
131 | - 'eventId' => 'absint', |
|
132 | - 'datetimeId' => 'absint', |
|
133 | - 'ticketId' => 'absint', |
|
134 | - 'status' => 'sanitize_text_field', |
|
135 | - 'limit' => 'intval', |
|
136 | - 'showGravatar' => 'bool', |
|
137 | - 'avatarClass' => 'sanitize_text_field', |
|
138 | - 'avatarSize' => 'absint', |
|
139 | - 'displayOnArchives' => 'bool', |
|
140 | - 'order' => 'sanitize_text_field', |
|
141 | - 'orderBy' => 'sanitize_text_field', |
|
142 | - ); |
|
143 | - } |
|
121 | + /** |
|
122 | + * Returns an array where the key corresponds to the incoming attribute name from the WP block |
|
123 | + * and the value corresponds to the attribute name for the existing EspressoEventAttendees shortcode |
|
124 | + * |
|
125 | + * @since $VID:$ |
|
126 | + * @return array |
|
127 | + */ |
|
128 | + private function getAttributesMap() |
|
129 | + { |
|
130 | + return array( |
|
131 | + 'eventId' => 'absint', |
|
132 | + 'datetimeId' => 'absint', |
|
133 | + 'ticketId' => 'absint', |
|
134 | + 'status' => 'sanitize_text_field', |
|
135 | + 'limit' => 'intval', |
|
136 | + 'showGravatar' => 'bool', |
|
137 | + 'avatarClass' => 'sanitize_text_field', |
|
138 | + 'avatarSize' => 'absint', |
|
139 | + 'displayOnArchives' => 'bool', |
|
140 | + 'order' => 'sanitize_text_field', |
|
141 | + 'orderBy' => 'sanitize_text_field', |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | |
145 | 145 | |
146 | - /** |
|
147 | - * Sanitizes attributes. |
|
148 | - * |
|
149 | - * @param array $attributes |
|
150 | - * @return array |
|
151 | - */ |
|
152 | - private function sanitizeAttributes(array $attributes) |
|
153 | - { |
|
154 | - $sanitized_attributes = array(); |
|
155 | - foreach ($attributes as $attribute => $value) { |
|
156 | - $convert = $this->getAttributesMap(); |
|
157 | - if (isset($convert[ $attribute ])) { |
|
158 | - $sanitize = $convert[ $attribute ]; |
|
159 | - if ($sanitize === 'bool') { |
|
160 | - $sanitized_attributes[ $attribute ] = filter_var( |
|
161 | - $value, |
|
162 | - FILTER_VALIDATE_BOOLEAN |
|
163 | - ); |
|
164 | - } else { |
|
165 | - $sanitized_attributes[ $attribute ] = $sanitize($value); |
|
166 | - } |
|
167 | - // don't pass along attributes with a 0 value |
|
168 | - if ($sanitized_attributes[ $attribute ] === 0) { |
|
169 | - unset($sanitized_attributes[ $attribute ]); |
|
170 | - } |
|
171 | - } |
|
172 | - } |
|
173 | - return $attributes; |
|
174 | - } |
|
146 | + /** |
|
147 | + * Sanitizes attributes. |
|
148 | + * |
|
149 | + * @param array $attributes |
|
150 | + * @return array |
|
151 | + */ |
|
152 | + private function sanitizeAttributes(array $attributes) |
|
153 | + { |
|
154 | + $sanitized_attributes = array(); |
|
155 | + foreach ($attributes as $attribute => $value) { |
|
156 | + $convert = $this->getAttributesMap(); |
|
157 | + if (isset($convert[ $attribute ])) { |
|
158 | + $sanitize = $convert[ $attribute ]; |
|
159 | + if ($sanitize === 'bool') { |
|
160 | + $sanitized_attributes[ $attribute ] = filter_var( |
|
161 | + $value, |
|
162 | + FILTER_VALIDATE_BOOLEAN |
|
163 | + ); |
|
164 | + } else { |
|
165 | + $sanitized_attributes[ $attribute ] = $sanitize($value); |
|
166 | + } |
|
167 | + // don't pass along attributes with a 0 value |
|
168 | + if ($sanitized_attributes[ $attribute ] === 0) { |
|
169 | + unset($sanitized_attributes[ $attribute ]); |
|
170 | + } |
|
171 | + } |
|
172 | + } |
|
173 | + return $attributes; |
|
174 | + } |
|
175 | 175 | |
176 | 176 | |
177 | - /** |
|
178 | - * Returns the rendered HTML for the block |
|
179 | - * |
|
180 | - * @param array $attributes |
|
181 | - * @return string |
|
182 | - * @throws DomainException |
|
183 | - * @throws EE_Error |
|
184 | - */ |
|
185 | - public function renderBlock(array $attributes = array()) |
|
186 | - { |
|
187 | - $attributes = $this->sanitizeAttributes($attributes); |
|
188 | - return is_archive() && ! $attributes['displayOnArchives'] |
|
189 | - ? '' |
|
190 | - : $this->renderer->render($attributes); |
|
191 | - } |
|
177 | + /** |
|
178 | + * Returns the rendered HTML for the block |
|
179 | + * |
|
180 | + * @param array $attributes |
|
181 | + * @return string |
|
182 | + * @throws DomainException |
|
183 | + * @throws EE_Error |
|
184 | + */ |
|
185 | + public function renderBlock(array $attributes = array()) |
|
186 | + { |
|
187 | + $attributes = $this->sanitizeAttributes($attributes); |
|
188 | + return is_archive() && ! $attributes['displayOnArchives'] |
|
189 | + ? '' |
|
190 | + : $this->renderer->render($attributes); |
|
191 | + } |
|
192 | 192 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | EventAttendeesBlockRenderer $renderer |
43 | 43 | ) { |
44 | 44 | parent::__construct($block_asset_manager, $request); |
45 | - $this->renderer= $renderer; |
|
45 | + $this->renderer = $renderer; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -154,19 +154,19 @@ discard block |
||
154 | 154 | $sanitized_attributes = array(); |
155 | 155 | foreach ($attributes as $attribute => $value) { |
156 | 156 | $convert = $this->getAttributesMap(); |
157 | - if (isset($convert[ $attribute ])) { |
|
158 | - $sanitize = $convert[ $attribute ]; |
|
157 | + if (isset($convert[$attribute])) { |
|
158 | + $sanitize = $convert[$attribute]; |
|
159 | 159 | if ($sanitize === 'bool') { |
160 | - $sanitized_attributes[ $attribute ] = filter_var( |
|
160 | + $sanitized_attributes[$attribute] = filter_var( |
|
161 | 161 | $value, |
162 | 162 | FILTER_VALIDATE_BOOLEAN |
163 | 163 | ); |
164 | 164 | } else { |
165 | - $sanitized_attributes[ $attribute ] = $sanitize($value); |
|
165 | + $sanitized_attributes[$attribute] = $sanitize($value); |
|
166 | 166 | } |
167 | 167 | // don't pass along attributes with a 0 value |
168 | - if ($sanitized_attributes[ $attribute ] === 0) { |
|
169 | - unset($sanitized_attributes[ $attribute ]); |
|
168 | + if ($sanitized_attributes[$attribute] === 0) { |
|
169 | + unset($sanitized_attributes[$attribute]); |
|
170 | 170 | } |
171 | 171 | } |
172 | 172 | } |
@@ -11,30 +11,30 @@ |
||
11 | 11 | <div id="ee-block-event-attendees" class="ee-core-blocks event-espresso-blocks event-attendees"> |
12 | 12 | <ul> |
13 | 13 | <?php |
14 | - foreach ($attendees as $attendee) { |
|
15 | - $gravatar = $attributes['showGravatar'] |
|
16 | - ? get_avatar_url( |
|
17 | - $attendee->email(), |
|
18 | - array( |
|
19 | - 'default' => 'mm', |
|
20 | - 'width' => $attributes['avatarSize'], |
|
21 | - 'height' => $attributes['avatarSize'] |
|
22 | - ) |
|
23 | - ) |
|
24 | - : ''; |
|
25 | - $gravatar_class = $attributes['avatarClass'] |
|
26 | - ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
27 | - : 'contact-avatar-img avatar'; |
|
28 | - $gravatar = $gravatar !== '' |
|
29 | - ? '<div class="contact-image-wrap-div">' |
|
30 | - . '<img class="' . $gravatar_class . '"' |
|
31 | - . ' width="' . $attributes['avatarSize'] . '"' |
|
32 | - . ' height="' . $attributes['avatarSize'] . '"' |
|
33 | - . ' src="' . $gravatar . '" alt="contact avatar">' |
|
34 | - . '</div>' |
|
35 | - : ''; |
|
36 | - echo "<li>{$gravatar}<span>{$attendee->full_name()}</span>"; |
|
37 | - } |
|
38 | - ?> |
|
14 | + foreach ($attendees as $attendee) { |
|
15 | + $gravatar = $attributes['showGravatar'] |
|
16 | + ? get_avatar_url( |
|
17 | + $attendee->email(), |
|
18 | + array( |
|
19 | + 'default' => 'mm', |
|
20 | + 'width' => $attributes['avatarSize'], |
|
21 | + 'height' => $attributes['avatarSize'] |
|
22 | + ) |
|
23 | + ) |
|
24 | + : ''; |
|
25 | + $gravatar_class = $attributes['avatarClass'] |
|
26 | + ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
27 | + : 'contact-avatar-img avatar'; |
|
28 | + $gravatar = $gravatar !== '' |
|
29 | + ? '<div class="contact-image-wrap-div">' |
|
30 | + . '<img class="' . $gravatar_class . '"' |
|
31 | + . ' width="' . $attributes['avatarSize'] . '"' |
|
32 | + . ' height="' . $attributes['avatarSize'] . '"' |
|
33 | + . ' src="' . $gravatar . '" alt="contact avatar">' |
|
34 | + . '</div>' |
|
35 | + : ''; |
|
36 | + echo "<li>{$gravatar}<span>{$attendee->full_name()}</span>"; |
|
37 | + } |
|
38 | + ?> |
|
39 | 39 | </ul> |
40 | 40 | </div> |
@@ -23,14 +23,14 @@ |
||
23 | 23 | ) |
24 | 24 | : ''; |
25 | 25 | $gravatar_class = $attributes['avatarClass'] |
26 | - ? $attributes['avatarClass'] . ' contact-avatar-img avatar' |
|
26 | + ? $attributes['avatarClass'].' contact-avatar-img avatar' |
|
27 | 27 | : 'contact-avatar-img avatar'; |
28 | 28 | $gravatar = $gravatar !== '' |
29 | 29 | ? '<div class="contact-image-wrap-div">' |
30 | - . '<img class="' . $gravatar_class . '"' |
|
31 | - . ' width="' . $attributes['avatarSize'] . '"' |
|
32 | - . ' height="' . $attributes['avatarSize'] . '"' |
|
33 | - . ' src="' . $gravatar . '" alt="contact avatar">' |
|
30 | + . '<img class="'.$gravatar_class.'"' |
|
31 | + . ' width="'.$attributes['avatarSize'].'"' |
|
32 | + . ' height="'.$attributes['avatarSize'].'"' |
|
33 | + . ' src="'.$gravatar.'" alt="contact avatar">' |
|
34 | 34 | . '</div>' |
35 | 35 | : ''; |
36 | 36 | echo "<li>{$gravatar}<span>{$attendee->full_name()}</span>"; |
@@ -20,104 +20,104 @@ |
||
20 | 20 | class EventAttendeesBlockRenderer extends BlockRenderer |
21 | 21 | { |
22 | 22 | |
23 | - /** |
|
24 | - * @var EEM_Attendee |
|
25 | - */ |
|
26 | - private $attendee_model; |
|
23 | + /** |
|
24 | + * @var EEM_Attendee |
|
25 | + */ |
|
26 | + private $attendee_model; |
|
27 | 27 | |
28 | - public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | - { |
|
30 | - $this->attendee_model = $attendee_model; |
|
31 | - parent::__construct($domain); |
|
32 | - } |
|
28 | + public function __construct(DomainInterface $domain, EEM_Attendee $attendee_model) |
|
29 | + { |
|
30 | + $this->attendee_model = $attendee_model; |
|
31 | + parent::__construct($domain); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | |
35 | - /** |
|
36 | - * Renders the block. |
|
37 | - * |
|
38 | - * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | - * query and the template output. |
|
40 | - * @return string |
|
41 | - * @throws DomainException |
|
42 | - * @throws EE_Error |
|
43 | - */ |
|
44 | - public function render(array $attributes) |
|
45 | - { |
|
46 | - $template_args['attributes'] = $attributes; |
|
47 | - $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | - return EEH_Template::display_template( |
|
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
50 | - $template_args, |
|
51 | - true |
|
52 | - ); |
|
53 | - } |
|
35 | + /** |
|
36 | + * Renders the block. |
|
37 | + * |
|
38 | + * @param array $attributes Expect already validated and sanitized array of attributes for use in generating the |
|
39 | + * query and the template output. |
|
40 | + * @return string |
|
41 | + * @throws DomainException |
|
42 | + * @throws EE_Error |
|
43 | + */ |
|
44 | + public function render(array $attributes) |
|
45 | + { |
|
46 | + $template_args['attributes'] = $attributes; |
|
47 | + $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
|
48 | + return EEH_Template::display_template( |
|
49 | + $this->templateRootPath() . 'event-attendees.php', |
|
50 | + $template_args, |
|
51 | + true |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - /** |
|
57 | - * Get query parameters for model query. |
|
58 | - * |
|
59 | - * @param array $attributes |
|
60 | - * @return array |
|
61 | - */ |
|
62 | - private function getQueryParams(array $attributes) |
|
63 | - { |
|
64 | - return array( |
|
65 | - 0 => $this->getWhereQueryPart($attributes), |
|
66 | - 'default_where_conditions' => 'this_model_only', |
|
67 | - 'limit' => $attributes['limit'], |
|
68 | - 'group_by' => array('ATT_ID'), |
|
69 | - 'order_by' => $this->getOrderByQueryPart($attributes) |
|
70 | - ); |
|
71 | - } |
|
56 | + /** |
|
57 | + * Get query parameters for model query. |
|
58 | + * |
|
59 | + * @param array $attributes |
|
60 | + * @return array |
|
61 | + */ |
|
62 | + private function getQueryParams(array $attributes) |
|
63 | + { |
|
64 | + return array( |
|
65 | + 0 => $this->getWhereQueryPart($attributes), |
|
66 | + 'default_where_conditions' => 'this_model_only', |
|
67 | + 'limit' => $attributes['limit'], |
|
68 | + 'group_by' => array('ATT_ID'), |
|
69 | + 'order_by' => $this->getOrderByQueryPart($attributes) |
|
70 | + ); |
|
71 | + } |
|
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * Get where query part for query parameters for model query. |
|
76 | - * |
|
77 | - * @param array $attributes |
|
78 | - * @return array |
|
79 | - */ |
|
80 | - private function getWhereQueryPart(array $attributes) |
|
81 | - { |
|
82 | - $where = array(); |
|
83 | - if ($attributes['ticketId'] > 0) { |
|
84 | - $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
85 | - } elseif ($attributes['datetimeId'] > 0) { |
|
86 | - $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
87 | - } else { |
|
88 | - $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
89 | - } |
|
90 | - $where['Registration.STS_ID'] = $attributes['status']; |
|
91 | - return $where; |
|
92 | - } |
|
74 | + /** |
|
75 | + * Get where query part for query parameters for model query. |
|
76 | + * |
|
77 | + * @param array $attributes |
|
78 | + * @return array |
|
79 | + */ |
|
80 | + private function getWhereQueryPart(array $attributes) |
|
81 | + { |
|
82 | + $where = array(); |
|
83 | + if ($attributes['ticketId'] > 0) { |
|
84 | + $where['Registration.TKT_ID'] = $attributes['ticketId']; |
|
85 | + } elseif ($attributes['datetimeId'] > 0) { |
|
86 | + $where['Registration.Ticket.Datetime.DTT_ID'] = $attributes['datetimeId']; |
|
87 | + } else { |
|
88 | + $where['Registration.EVT_ID'] = $attributes['eventId']; |
|
89 | + } |
|
90 | + $where['Registration.STS_ID'] = $attributes['status']; |
|
91 | + return $where; |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * Get order by query part for query parameters for model query. |
|
97 | - * |
|
98 | - * @param array $attributes |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - private function getOrderByQueryPart(array $attributes) |
|
102 | - { |
|
103 | - $order = $attributes['order']; |
|
104 | - switch ($attributes['orderBy']) { |
|
105 | - case 'id': |
|
106 | - $order_by = array('ATT_ID' => $order); |
|
107 | - break; |
|
108 | - case 'lastNameOnly': |
|
109 | - $order_by = array('ATT_lname' => $order); |
|
110 | - break; |
|
111 | - case 'firstNameOnly': |
|
112 | - $order_by = array('ATT_fname' => $order); |
|
113 | - break; |
|
114 | - case 'firstThenLastName': |
|
115 | - $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
116 | - break; |
|
117 | - default: |
|
118 | - $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
119 | - break; |
|
120 | - } |
|
121 | - return $order_by; |
|
122 | - } |
|
95 | + /** |
|
96 | + * Get order by query part for query parameters for model query. |
|
97 | + * |
|
98 | + * @param array $attributes |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + private function getOrderByQueryPart(array $attributes) |
|
102 | + { |
|
103 | + $order = $attributes['order']; |
|
104 | + switch ($attributes['orderBy']) { |
|
105 | + case 'id': |
|
106 | + $order_by = array('ATT_ID' => $order); |
|
107 | + break; |
|
108 | + case 'lastNameOnly': |
|
109 | + $order_by = array('ATT_lname' => $order); |
|
110 | + break; |
|
111 | + case 'firstNameOnly': |
|
112 | + $order_by = array('ATT_fname' => $order); |
|
113 | + break; |
|
114 | + case 'firstThenLastName': |
|
115 | + $order_by = array('ATT_fname' => $order, 'ATT_lname' => $order); |
|
116 | + break; |
|
117 | + default: |
|
118 | + $order_by = array('ATT_lname' => $order, 'ATT_fname' => $order); |
|
119 | + break; |
|
120 | + } |
|
121 | + return $order_by; |
|
122 | + } |
|
123 | 123 | } |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $template_args['attributes'] = $attributes; |
47 | 47 | $template_args['attendees'] = $this->attendee_model->get_all($this->getQueryParams($attributes)); |
48 | 48 | return EEH_Template::display_template( |
49 | - $this->templateRootPath() . 'event-attendees.php', |
|
49 | + $this->templateRootPath().'event-attendees.php', |
|
50 | 50 | $template_args, |
51 | 51 | true |
52 | 52 | ); |
@@ -14,11 +14,11 @@ |
||
14 | 14 | interface BlockRendererInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | - * |
|
20 | - * @param array $attributes |
|
21 | - * @return string Rendered Content |
|
22 | - */ |
|
23 | - public function render(array $attributes); |
|
17 | + /** |
|
18 | + * This receives an array of attributes and returns rendered content for the block using those attributes. |
|
19 | + * |
|
20 | + * @param array $attributes |
|
21 | + * @return string Rendered Content |
|
22 | + */ |
|
23 | + public function render(array $attributes); |
|
24 | 24 | } |
@@ -14,44 +14,44 @@ |
||
14 | 14 | abstract class BlockRenderer implements BlockRendererInterface |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var DomainInterface |
|
19 | - */ |
|
20 | - protected $domain; |
|
21 | - |
|
22 | - /** |
|
23 | - * @var string |
|
24 | - */ |
|
25 | - private $template_root_path; |
|
26 | - |
|
27 | - |
|
28 | - /** |
|
29 | - * BlockRenderer constructor. |
|
30 | - * |
|
31 | - * @param DomainInterface $domain |
|
32 | - */ |
|
33 | - public function __construct(DomainInterface $domain) |
|
34 | - { |
|
35 | - $this->domain = $domain; |
|
36 | - $this->setTemplateRootPath(); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * Sets the root path to the main block template. |
|
42 | - */ |
|
43 | - private function setTemplateRootPath() |
|
44 | - { |
|
45 | - $this->template_root_path = $this->domain->pluginPath() . 'core/domain/ui/blocks/'; |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - * Exposes the root path for the main block template. |
|
51 | - * @return string |
|
52 | - */ |
|
53 | - public function templateRootPath() |
|
54 | - { |
|
55 | - return $this->template_root_path; |
|
56 | - } |
|
17 | + /** |
|
18 | + * @var DomainInterface |
|
19 | + */ |
|
20 | + protected $domain; |
|
21 | + |
|
22 | + /** |
|
23 | + * @var string |
|
24 | + */ |
|
25 | + private $template_root_path; |
|
26 | + |
|
27 | + |
|
28 | + /** |
|
29 | + * BlockRenderer constructor. |
|
30 | + * |
|
31 | + * @param DomainInterface $domain |
|
32 | + */ |
|
33 | + public function __construct(DomainInterface $domain) |
|
34 | + { |
|
35 | + $this->domain = $domain; |
|
36 | + $this->setTemplateRootPath(); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * Sets the root path to the main block template. |
|
42 | + */ |
|
43 | + private function setTemplateRootPath() |
|
44 | + { |
|
45 | + $this->template_root_path = $this->domain->pluginPath() . 'core/domain/ui/blocks/'; |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + * Exposes the root path for the main block template. |
|
51 | + * @return string |
|
52 | + */ |
|
53 | + public function templateRootPath() |
|
54 | + { |
|
55 | + return $this->template_root_path; |
|
56 | + } |
|
57 | 57 | } |
@@ -42,7 +42,7 @@ |
||
42 | 42 | */ |
43 | 43 | private function setTemplateRootPath() |
44 | 44 | { |
45 | - $this->template_root_path = $this->domain->pluginPath() . 'core/domain/ui/blocks/'; |
|
45 | + $this->template_root_path = $this->domain->pluginPath().'core/domain/ui/blocks/'; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 |