@@ -22,1061 +22,1061 @@ |
||
22 | 22 | class EE_Dependency_Map |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * This means that the requested class dependency is not present in the dependency map |
|
27 | - */ |
|
28 | - const not_registered = 0; |
|
29 | - |
|
30 | - /** |
|
31 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | - */ |
|
33 | - const load_new_object = 1; |
|
34 | - |
|
35 | - /** |
|
36 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | - */ |
|
39 | - const load_from_cache = 2; |
|
40 | - |
|
41 | - /** |
|
42 | - * When registering a dependency, |
|
43 | - * this indicates to keep any existing dependencies that already exist, |
|
44 | - * and simply discard any new dependencies declared in the incoming data |
|
45 | - */ |
|
46 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | - |
|
48 | - /** |
|
49 | - * When registering a dependency, |
|
50 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | - */ |
|
52 | - const OVERWRITE_DEPENDENCIES = 1; |
|
53 | - |
|
54 | - /** |
|
55 | - * @type EE_Dependency_Map $_instance |
|
56 | - */ |
|
57 | - protected static $_instance; |
|
58 | - |
|
59 | - /** |
|
60 | - * @var ClassInterfaceCache $class_cache |
|
61 | - */ |
|
62 | - private $class_cache; |
|
63 | - |
|
64 | - /** |
|
65 | - * @type RequestInterface $request |
|
66 | - */ |
|
67 | - protected $request; |
|
68 | - |
|
69 | - /** |
|
70 | - * @type LegacyRequestInterface $legacy_request |
|
71 | - */ |
|
72 | - protected $legacy_request; |
|
73 | - |
|
74 | - /** |
|
75 | - * @type ResponseInterface $response |
|
76 | - */ |
|
77 | - protected $response; |
|
78 | - |
|
79 | - /** |
|
80 | - * @type LoaderInterface $loader |
|
81 | - */ |
|
82 | - protected $loader; |
|
83 | - |
|
84 | - /** |
|
85 | - * @type array $_dependency_map |
|
86 | - */ |
|
87 | - protected $_dependency_map = []; |
|
88 | - |
|
89 | - /** |
|
90 | - * @type array $_class_loaders |
|
91 | - */ |
|
92 | - protected $_class_loaders = []; |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * EE_Dependency_Map constructor. |
|
97 | - * |
|
98 | - * @param ClassInterfaceCache $class_cache |
|
99 | - */ |
|
100 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
101 | - { |
|
102 | - $this->class_cache = $class_cache; |
|
103 | - do_action('EE_Dependency_Map____construct', $this); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return void |
|
109 | - * @throws InvalidAliasException |
|
110 | - */ |
|
111 | - public function initialize() |
|
112 | - { |
|
113 | - $this->_register_core_dependencies(); |
|
114 | - $this->_register_core_class_loaders(); |
|
115 | - $this->_register_core_aliases(); |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - /** |
|
120 | - * @singleton method used to instantiate class object |
|
121 | - * @param ClassInterfaceCache|null $class_cache |
|
122 | - * @return EE_Dependency_Map |
|
123 | - */ |
|
124 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
125 | - { |
|
126 | - // check if class object is instantiated, and instantiated properly |
|
127 | - if ( |
|
128 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
129 | - && $class_cache instanceof ClassInterfaceCache |
|
130 | - ) { |
|
131 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
132 | - } |
|
133 | - return EE_Dependency_Map::$_instance; |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @param RequestInterface $request |
|
139 | - */ |
|
140 | - public function setRequest(RequestInterface $request) |
|
141 | - { |
|
142 | - $this->request = $request; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @param LegacyRequestInterface $legacy_request |
|
148 | - */ |
|
149 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
150 | - { |
|
151 | - $this->legacy_request = $legacy_request; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @param ResponseInterface $response |
|
157 | - */ |
|
158 | - public function setResponse(ResponseInterface $response) |
|
159 | - { |
|
160 | - $this->response = $response; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param LoaderInterface $loader |
|
166 | - */ |
|
167 | - public function setLoader(LoaderInterface $loader) |
|
168 | - { |
|
169 | - $this->loader = $loader; |
|
170 | - } |
|
171 | - |
|
172 | - |
|
173 | - /** |
|
174 | - * @param string $class |
|
175 | - * @param array $dependencies |
|
176 | - * @param int $overwrite |
|
177 | - * @return bool |
|
178 | - */ |
|
179 | - public static function register_dependencies( |
|
180 | - $class, |
|
181 | - array $dependencies, |
|
182 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
183 | - ) { |
|
184 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
190 | - * to the class specified by the first parameter. |
|
191 | - * IMPORTANT !!! |
|
192 | - * The order of elements in the incoming $dependencies array MUST match |
|
193 | - * the order of the constructor parameters for the class in question. |
|
194 | - * This is especially important when overriding any existing dependencies that are registered. |
|
195 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
196 | - * |
|
197 | - * @param string $class |
|
198 | - * @param array $dependencies |
|
199 | - * @param int $overwrite |
|
200 | - * @return bool |
|
201 | - */ |
|
202 | - public function registerDependencies( |
|
203 | - $class, |
|
204 | - array $dependencies, |
|
205 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
206 | - ) { |
|
207 | - $class = trim($class, '\\'); |
|
208 | - $registered = false; |
|
209 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
210 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
211 | - } |
|
212 | - // we need to make sure that any aliases used when registering a dependency |
|
213 | - // get resolved to the correct class name |
|
214 | - foreach ($dependencies as $dependency => $load_source) { |
|
215 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
216 | - if ( |
|
217 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
218 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
219 | - ) { |
|
220 | - unset($dependencies[ $dependency ]); |
|
221 | - $dependencies[ $alias ] = $load_source; |
|
222 | - $registered = true; |
|
223 | - } |
|
224 | - } |
|
225 | - // now add our two lists of dependencies together. |
|
226 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
227 | - // so $dependencies is NOT overwritten because it is listed first |
|
228 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
229 | - // Union is way faster than array_merge() but should be used with caution... |
|
230 | - // especially with numerically indexed arrays |
|
231 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
232 | - // now we need to ensure that the resulting dependencies |
|
233 | - // array only has the entries that are required for the class |
|
234 | - // so first count how many dependencies were originally registered for the class |
|
235 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
236 | - // if that count is non-zero (meaning dependencies were already registered) |
|
237 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
238 | - // then truncate the final array to match that count |
|
239 | - ? array_slice($dependencies, 0, $dependency_count) |
|
240 | - // otherwise just take the incoming array because nothing previously existed |
|
241 | - : $dependencies; |
|
242 | - return $registered; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @param string $class_name |
|
248 | - * @param string $loader |
|
249 | - * @return bool |
|
250 | - * @throws DomainException |
|
251 | - */ |
|
252 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
253 | - { |
|
254 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
255 | - } |
|
256 | - |
|
257 | - |
|
258 | - /** |
|
259 | - * @param string $class_name |
|
260 | - * @param string $loader |
|
261 | - * @return bool |
|
262 | - * @throws DomainException |
|
263 | - */ |
|
264 | - public function registerClassLoader($class_name, $loader = 'load_core') |
|
265 | - { |
|
266 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
267 | - throw new DomainException( |
|
268 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
269 | - ); |
|
270 | - } |
|
271 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
272 | - if ( |
|
273 | - ! is_callable($loader) |
|
274 | - && ( |
|
275 | - strpos($loader, 'load_') !== 0 |
|
276 | - || ! method_exists('EE_Registry', $loader) |
|
277 | - ) |
|
278 | - ) { |
|
279 | - throw new DomainException( |
|
280 | - sprintf( |
|
281 | - esc_html__( |
|
282 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
283 | - 'event_espresso' |
|
284 | - ), |
|
285 | - $loader |
|
286 | - ) |
|
287 | - ); |
|
288 | - } |
|
289 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
290 | - if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
291 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
292 | - return true; |
|
293 | - } |
|
294 | - return false; |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - /** |
|
299 | - * @return array |
|
300 | - */ |
|
301 | - public function dependency_map() |
|
302 | - { |
|
303 | - return $this->_dependency_map; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - /** |
|
308 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
309 | - * |
|
310 | - * @param string $class_name |
|
311 | - * @return boolean |
|
312 | - */ |
|
313 | - public function has($class_name = '') |
|
314 | - { |
|
315 | - // all legacy models have the same dependencies |
|
316 | - if (strpos($class_name, 'EEM_') === 0) { |
|
317 | - $class_name = 'LEGACY_MODELS'; |
|
318 | - } |
|
319 | - return isset($this->_dependency_map[ $class_name ]); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
325 | - * |
|
326 | - * @param string $class_name |
|
327 | - * @param string $dependency |
|
328 | - * @return bool |
|
329 | - */ |
|
330 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
331 | - { |
|
332 | - // all legacy models have the same dependencies |
|
333 | - if (strpos($class_name, 'EEM_') === 0) { |
|
334 | - $class_name = 'LEGACY_MODELS'; |
|
335 | - } |
|
336 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
337 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | - * |
|
344 | - * @param string $class_name |
|
345 | - * @param string $dependency |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | - { |
|
350 | - // all legacy models have the same dependencies |
|
351 | - if (strpos($class_name, 'EEM_') === 0) { |
|
352 | - $class_name = 'LEGACY_MODELS'; |
|
353 | - } |
|
354 | - $dependency = $this->getFqnForAlias($dependency); |
|
355 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
357 | - : EE_Dependency_Map::not_registered; |
|
358 | - } |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * @param string $class_name |
|
363 | - * @return string | Closure |
|
364 | - */ |
|
365 | - public function class_loader($class_name) |
|
366 | - { |
|
367 | - // all legacy models use load_model() |
|
368 | - if (strpos($class_name, 'EEM_') === 0) { |
|
369 | - return 'load_model'; |
|
370 | - } |
|
371 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
372 | - // perform strpos() first to avoid loading regex every time we load a class |
|
373 | - if ( |
|
374 | - strpos($class_name, 'EE_CPT_') === 0 |
|
375 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
376 | - ) { |
|
377 | - return 'load_core'; |
|
378 | - } |
|
379 | - $class_name = $this->getFqnForAlias($class_name); |
|
380 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * @return array |
|
386 | - */ |
|
387 | - public function class_loaders() |
|
388 | - { |
|
389 | - return $this->_class_loaders; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * adds an alias for a classname |
|
395 | - * |
|
396 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
397 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
398 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
399 | - * @throws InvalidAliasException |
|
400 | - */ |
|
401 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
402 | - { |
|
403 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
409 | - * WHY? |
|
410 | - * Because if a class is type hinting for a concretion, |
|
411 | - * then why would we need to find another class to supply it? |
|
412 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
413 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
414 | - * Don't go looking for some substitute. |
|
415 | - * Whereas if a class is type hinting for an interface... |
|
416 | - * then we need to find an actual class to use. |
|
417 | - * So the interface IS the alias for some other FQN, |
|
418 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
419 | - * represents some other class. |
|
420 | - * |
|
421 | - * @param string $fqn |
|
422 | - * @param string $for_class |
|
423 | - * @return bool |
|
424 | - */ |
|
425 | - public function isAlias($fqn = '', $for_class = '') |
|
426 | - { |
|
427 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - /** |
|
432 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
433 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
434 | - * for example: |
|
435 | - * if the following two entries were added to the _aliases array: |
|
436 | - * array( |
|
437 | - * 'interface_alias' => 'some\namespace\interface' |
|
438 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
439 | - * ) |
|
440 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
441 | - * to load an instance of 'some\namespace\classname' |
|
442 | - * |
|
443 | - * @param string $alias |
|
444 | - * @param string $for_class |
|
445 | - * @return string |
|
446 | - */ |
|
447 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
448 | - { |
|
449 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
450 | - } |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
455 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
456 | - * This is done by using the following class constants: |
|
457 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
458 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
459 | - */ |
|
460 | - protected function _register_core_dependencies() |
|
461 | - { |
|
462 | - $this->_dependency_map = [ |
|
463 | - 'EE_Request_Handler' => [ |
|
464 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
465 | - ], |
|
466 | - 'EE_System' => [ |
|
467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
469 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
471 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
472 | - ], |
|
473 | - 'EE_Admin' => [ |
|
474 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
475 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
476 | - ], |
|
477 | - 'EE_Cart' => [ |
|
478 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
479 | - ], |
|
480 | - 'EE_Messenger_Collection_Loader' => [ |
|
481 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | - ], |
|
483 | - 'EE_Message_Type_Collection_Loader' => [ |
|
484 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
485 | - ], |
|
486 | - 'EE_Message_Resource_Manager' => [ |
|
487 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
488 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
489 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
490 | - ], |
|
491 | - 'EE_Message_Factory' => [ |
|
492 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | - ], |
|
494 | - 'EE_messages' => [ |
|
495 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | - ], |
|
497 | - 'EE_Messages_Generator' => [ |
|
498 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
499 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
500 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
501 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
502 | - ], |
|
503 | - 'EE_Messages_Processor' => [ |
|
504 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | - ], |
|
506 | - 'EE_Messages_Queue' => [ |
|
507 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
508 | - ], |
|
509 | - 'EE_Messages_Template_Defaults' => [ |
|
510 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
511 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
512 | - ], |
|
513 | - 'EE_Message_To_Generate_From_Request' => [ |
|
514 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
515 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
516 | - ], |
|
517 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
518 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
519 | - ], |
|
520 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
521 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
523 | - ], |
|
524 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
525 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
526 | - ], |
|
527 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
528 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
529 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
530 | - ], |
|
531 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
532 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | - ], |
|
534 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
535 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
536 | - ], |
|
537 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
538 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | - ], |
|
540 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
541 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
542 | - ], |
|
543 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
544 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | - ], |
|
546 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
547 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | - ], |
|
549 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
550 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
551 | - ], |
|
552 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
553 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
554 | - ], |
|
555 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
556 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
557 | - ], |
|
558 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
559 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | - ], |
|
561 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
562 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | - ], |
|
564 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
565 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
566 | - ], |
|
567 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
568 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
569 | - ], |
|
570 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
571 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | - ], |
|
573 | - 'EE_Data_Migration_Class_Base' => [ |
|
574 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | - ], |
|
577 | - 'EE_DMS_Core_4_1_0' => [ |
|
578 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | - ], |
|
581 | - 'EE_DMS_Core_4_2_0' => [ |
|
582 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | - ], |
|
585 | - 'EE_DMS_Core_4_3_0' => [ |
|
586 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | - ], |
|
589 | - 'EE_DMS_Core_4_4_0' => [ |
|
590 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | - ], |
|
593 | - 'EE_DMS_Core_4_5_0' => [ |
|
594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | - ], |
|
597 | - 'EE_DMS_Core_4_6_0' => [ |
|
598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | - ], |
|
601 | - 'EE_DMS_Core_4_7_0' => [ |
|
602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | - ], |
|
605 | - 'EE_DMS_Core_4_8_0' => [ |
|
606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | - ], |
|
609 | - 'EE_DMS_Core_4_9_0' => [ |
|
610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | - ], |
|
613 | - 'EE_DMS_Core_4_10_0' => [ |
|
614 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
617 | - ], |
|
618 | - 'EE_DMS_Core_4_11_0' => [ |
|
619 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
620 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
621 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
622 | - ], |
|
623 | - 'EE_DMS_Core_4_12_0' => [ |
|
624 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
625 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | - ], |
|
628 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
629 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
630 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
631 | - ], |
|
632 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
633 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | - ], |
|
635 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
636 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | - ], |
|
638 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
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' => [ |
|
643 | - null, |
|
644 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | - ], |
|
646 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
647 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | - ], |
|
649 | - 'LEGACY_MODELS' => [ |
|
650 | - null, |
|
651 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | - ], |
|
653 | - 'EE_Module_Request_Router' => [ |
|
654 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | - ], |
|
656 | - 'EE_Registration_Processor' => [ |
|
657 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | - ], |
|
659 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
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\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
665 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
666 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
667 | - ], |
|
668 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
669 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
670 | - ], |
|
671 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
672 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
673 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
674 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
675 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
676 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
677 | - ], |
|
678 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
679 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
680 | - ], |
|
681 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
682 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
683 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | - ], |
|
685 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
686 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
687 | - ], |
|
688 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
689 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
690 | - ], |
|
691 | - 'EE_CPT_Strategy' => [ |
|
692 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
693 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
694 | - ], |
|
695 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
696 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
697 | - ], |
|
698 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
699 | - null, |
|
700 | - null, |
|
701 | - null, |
|
702 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
703 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
704 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
705 | - ], |
|
706 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
707 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
708 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
709 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
710 | - ], |
|
711 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
712 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
713 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
714 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
715 | - ], |
|
716 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
717 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
718 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
719 | - ], |
|
720 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
721 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
722 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
723 | - ], |
|
724 | - 'EE_URL_Validation_Strategy' => [ |
|
725 | - null, |
|
726 | - null, |
|
727 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
728 | - ], |
|
729 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
730 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
731 | - ], |
|
732 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
733 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
734 | - ], |
|
735 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
736 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
737 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
738 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
739 | - null, |
|
740 | - ], |
|
741 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
742 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
743 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
744 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
745 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | - ], |
|
747 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
748 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
749 | - ], |
|
750 | - 'EventEspresso\core\services\routing\Router' => [ |
|
751 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
752 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
753 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
754 | - ], |
|
755 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
756 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
757 | - ], |
|
758 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
759 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
760 | - ], |
|
761 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
762 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
763 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | - ], |
|
765 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
766 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
767 | - ], |
|
768 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
769 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
771 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
772 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
773 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
774 | - ], |
|
775 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
776 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
777 | - ], |
|
778 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
779 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
780 | - ], |
|
781 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
782 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
783 | - ], |
|
784 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
785 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
786 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
787 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
788 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
789 | - ], |
|
790 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
791 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
792 | - ], |
|
793 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
794 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
795 | - ], |
|
796 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
797 | - 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
798 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
800 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
801 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
802 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
803 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
804 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
805 | - ], |
|
806 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
807 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
808 | - ], |
|
809 | - ]; |
|
810 | - } |
|
811 | - |
|
812 | - |
|
813 | - /** |
|
814 | - * Registers how core classes are loaded. |
|
815 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
816 | - * 'EE_Request_Handler' => 'load_core' |
|
817 | - * 'EE_Messages_Queue' => 'load_lib' |
|
818 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
819 | - * or, if greater control is required, by providing a custom closure. For example: |
|
820 | - * 'Some_Class' => function () { |
|
821 | - * return new Some_Class(); |
|
822 | - * }, |
|
823 | - * This is required for instantiating dependencies |
|
824 | - * where an interface has been type hinted in a class constructor. For example: |
|
825 | - * 'Required_Interface' => function () { |
|
826 | - * return new A_Class_That_Implements_Required_Interface(); |
|
827 | - * }, |
|
828 | - */ |
|
829 | - protected function _register_core_class_loaders() |
|
830 | - { |
|
831 | - $this->_class_loaders = [ |
|
832 | - // load_core |
|
833 | - 'EE_Dependency_Map' => function () { |
|
834 | - return $this; |
|
835 | - }, |
|
836 | - 'EE_Capabilities' => 'load_core', |
|
837 | - 'EE_Encryption' => 'load_core', |
|
838 | - 'EE_Front_Controller' => 'load_core', |
|
839 | - 'EE_Module_Request_Router' => 'load_core', |
|
840 | - 'EE_Registry' => 'load_core', |
|
841 | - 'EE_Request' => function () { |
|
842 | - return $this->legacy_request; |
|
843 | - }, |
|
844 | - 'EventEspresso\core\services\request\Request' => function () { |
|
845 | - return $this->request; |
|
846 | - }, |
|
847 | - 'EventEspresso\core\services\request\Response' => function () { |
|
848 | - return $this->response; |
|
849 | - }, |
|
850 | - 'EE_Base' => 'load_core', |
|
851 | - 'EE_Request_Handler' => 'load_core', |
|
852 | - 'EE_Session' => 'load_core', |
|
853 | - 'EE_Cron_Tasks' => 'load_core', |
|
854 | - 'EE_System' => 'load_core', |
|
855 | - 'EE_Maintenance_Mode' => 'load_core', |
|
856 | - 'EE_Register_CPTs' => 'load_core', |
|
857 | - 'EE_Admin' => 'load_core', |
|
858 | - 'EE_CPT_Strategy' => 'load_core', |
|
859 | - // load_class |
|
860 | - 'EE_Registration_Processor' => 'load_class', |
|
861 | - // load_lib |
|
862 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
863 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
864 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
865 | - 'EE_Messenger_Collection' => 'load_lib', |
|
866 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
867 | - 'EE_Messages_Processor' => 'load_lib', |
|
868 | - 'EE_Message_Repository' => 'load_lib', |
|
869 | - 'EE_Messages_Queue' => 'load_lib', |
|
870 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
871 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
872 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
873 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
874 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
875 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
876 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
877 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
878 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
879 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
880 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
881 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
882 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
883 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
884 | - 'EE_Messages_Generator' => static function () { |
|
885 | - return EE_Registry::instance()->load_lib( |
|
886 | - 'Messages_Generator', |
|
887 | - [], |
|
888 | - false, |
|
889 | - false |
|
890 | - ); |
|
891 | - }, |
|
892 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
893 | - return EE_Registry::instance()->load_lib( |
|
894 | - 'Messages_Template_Defaults', |
|
895 | - $arguments, |
|
896 | - false, |
|
897 | - false |
|
898 | - ); |
|
899 | - }, |
|
900 | - // load_helper |
|
901 | - 'EEH_Parse_Shortcodes' => static function () { |
|
902 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
903 | - return new EEH_Parse_Shortcodes(); |
|
904 | - } |
|
905 | - return null; |
|
906 | - }, |
|
907 | - 'EE_Template_Config' => static function () { |
|
908 | - return EE_Config::instance()->template_settings; |
|
909 | - }, |
|
910 | - 'EE_Currency_Config' => static function () { |
|
911 | - return EE_Config::instance()->currency; |
|
912 | - }, |
|
913 | - 'EE_Registration_Config' => static function () { |
|
914 | - return EE_Config::instance()->registration; |
|
915 | - }, |
|
916 | - 'EE_Core_Config' => static function () { |
|
917 | - return EE_Config::instance()->core; |
|
918 | - }, |
|
919 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
920 | - return LoaderFactory::getLoader(); |
|
921 | - }, |
|
922 | - 'EE_Network_Config' => static function () { |
|
923 | - return EE_Network_Config::instance(); |
|
924 | - }, |
|
925 | - 'EE_Config' => static function () { |
|
926 | - return EE_Config::instance(); |
|
927 | - }, |
|
928 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
929 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
930 | - }, |
|
931 | - 'EE_Admin_Config' => static function () { |
|
932 | - return EE_Config::instance()->admin; |
|
933 | - }, |
|
934 | - 'EE_Organization_Config' => static function () { |
|
935 | - return EE_Config::instance()->organization; |
|
936 | - }, |
|
937 | - 'EE_Network_Core_Config' => static function () { |
|
938 | - return EE_Network_Config::instance()->core; |
|
939 | - }, |
|
940 | - 'EE_Environment_Config' => static function () { |
|
941 | - return EE_Config::instance()->environment; |
|
942 | - }, |
|
943 | - 'EED_Core_Rest_Api' => static function () { |
|
944 | - return EED_Core_Rest_Api::instance(); |
|
945 | - }, |
|
946 | - 'WP_REST_Server' => static function () { |
|
947 | - return rest_get_server(); |
|
948 | - }, |
|
949 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
950 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
951 | - }, |
|
952 | - ]; |
|
953 | - } |
|
954 | - |
|
955 | - |
|
956 | - /** |
|
957 | - * can be used for supplying alternate names for classes, |
|
958 | - * or for connecting interface names to instantiable classes |
|
959 | - * |
|
960 | - * @throws InvalidAliasException |
|
961 | - */ |
|
962 | - protected function _register_core_aliases() |
|
963 | - { |
|
964 | - $aliases = [ |
|
965 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
966 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
967 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
968 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
969 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
970 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
971 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
972 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
973 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
974 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
975 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
976 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
977 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
978 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
979 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
980 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
981 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
982 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
983 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
984 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
985 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
986 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
987 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
988 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
989 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
990 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
991 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
992 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
993 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
994 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
995 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
996 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
997 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
998 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
999 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1000 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1001 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1002 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1003 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1004 | - ]; |
|
1005 | - foreach ($aliases as $alias => $fqn) { |
|
1006 | - if (is_array($fqn)) { |
|
1007 | - foreach ($fqn as $class => $for_class) { |
|
1008 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1009 | - } |
|
1010 | - continue; |
|
1011 | - } |
|
1012 | - $this->class_cache->addAlias($fqn, $alias); |
|
1013 | - } |
|
1014 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1015 | - $this->class_cache->addAlias( |
|
1016 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1017 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1018 | - ); |
|
1019 | - } |
|
1020 | - } |
|
1021 | - |
|
1022 | - |
|
1023 | - /** |
|
1024 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1025 | - * request Primarily used by unit tests. |
|
1026 | - */ |
|
1027 | - public function reset() |
|
1028 | - { |
|
1029 | - $this->_register_core_class_loaders(); |
|
1030 | - $this->_register_core_dependencies(); |
|
1031 | - } |
|
1032 | - |
|
1033 | - |
|
1034 | - /** |
|
1035 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1036 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1037 | - * WHY? |
|
1038 | - * Because if a class is type hinting for a concretion, |
|
1039 | - * then why would we need to find another class to supply it? |
|
1040 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1041 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1042 | - * Don't go looking for some substitute. |
|
1043 | - * Whereas if a class is type hinting for an interface... |
|
1044 | - * then we need to find an actual class to use. |
|
1045 | - * So the interface IS the alias for some other FQN, |
|
1046 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1047 | - * represents some other class. |
|
1048 | - * |
|
1049 | - * @param string $fqn |
|
1050 | - * @param string $for_class |
|
1051 | - * @return bool |
|
1052 | - * @deprecated 4.9.62.p |
|
1053 | - */ |
|
1054 | - public function has_alias($fqn = '', $for_class = '') |
|
1055 | - { |
|
1056 | - return $this->isAlias($fqn, $for_class); |
|
1057 | - } |
|
1058 | - |
|
1059 | - |
|
1060 | - /** |
|
1061 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1062 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1063 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1064 | - * for example: |
|
1065 | - * if the following two entries were added to the _aliases array: |
|
1066 | - * array( |
|
1067 | - * 'interface_alias' => 'some\namespace\interface' |
|
1068 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1069 | - * ) |
|
1070 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1071 | - * to load an instance of 'some\namespace\classname' |
|
1072 | - * |
|
1073 | - * @param string $alias |
|
1074 | - * @param string $for_class |
|
1075 | - * @return string |
|
1076 | - * @deprecated 4.9.62.p |
|
1077 | - */ |
|
1078 | - public function get_alias($alias = '', $for_class = '') |
|
1079 | - { |
|
1080 | - return $this->getFqnForAlias($alias, $for_class); |
|
1081 | - } |
|
25 | + /** |
|
26 | + * This means that the requested class dependency is not present in the dependency map |
|
27 | + */ |
|
28 | + const not_registered = 0; |
|
29 | + |
|
30 | + /** |
|
31 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
32 | + */ |
|
33 | + const load_new_object = 1; |
|
34 | + |
|
35 | + /** |
|
36 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
37 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
38 | + */ |
|
39 | + const load_from_cache = 2; |
|
40 | + |
|
41 | + /** |
|
42 | + * When registering a dependency, |
|
43 | + * this indicates to keep any existing dependencies that already exist, |
|
44 | + * and simply discard any new dependencies declared in the incoming data |
|
45 | + */ |
|
46 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
47 | + |
|
48 | + /** |
|
49 | + * When registering a dependency, |
|
50 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
51 | + */ |
|
52 | + const OVERWRITE_DEPENDENCIES = 1; |
|
53 | + |
|
54 | + /** |
|
55 | + * @type EE_Dependency_Map $_instance |
|
56 | + */ |
|
57 | + protected static $_instance; |
|
58 | + |
|
59 | + /** |
|
60 | + * @var ClassInterfaceCache $class_cache |
|
61 | + */ |
|
62 | + private $class_cache; |
|
63 | + |
|
64 | + /** |
|
65 | + * @type RequestInterface $request |
|
66 | + */ |
|
67 | + protected $request; |
|
68 | + |
|
69 | + /** |
|
70 | + * @type LegacyRequestInterface $legacy_request |
|
71 | + */ |
|
72 | + protected $legacy_request; |
|
73 | + |
|
74 | + /** |
|
75 | + * @type ResponseInterface $response |
|
76 | + */ |
|
77 | + protected $response; |
|
78 | + |
|
79 | + /** |
|
80 | + * @type LoaderInterface $loader |
|
81 | + */ |
|
82 | + protected $loader; |
|
83 | + |
|
84 | + /** |
|
85 | + * @type array $_dependency_map |
|
86 | + */ |
|
87 | + protected $_dependency_map = []; |
|
88 | + |
|
89 | + /** |
|
90 | + * @type array $_class_loaders |
|
91 | + */ |
|
92 | + protected $_class_loaders = []; |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * EE_Dependency_Map constructor. |
|
97 | + * |
|
98 | + * @param ClassInterfaceCache $class_cache |
|
99 | + */ |
|
100 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
101 | + { |
|
102 | + $this->class_cache = $class_cache; |
|
103 | + do_action('EE_Dependency_Map____construct', $this); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return void |
|
109 | + * @throws InvalidAliasException |
|
110 | + */ |
|
111 | + public function initialize() |
|
112 | + { |
|
113 | + $this->_register_core_dependencies(); |
|
114 | + $this->_register_core_class_loaders(); |
|
115 | + $this->_register_core_aliases(); |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + /** |
|
120 | + * @singleton method used to instantiate class object |
|
121 | + * @param ClassInterfaceCache|null $class_cache |
|
122 | + * @return EE_Dependency_Map |
|
123 | + */ |
|
124 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
125 | + { |
|
126 | + // check if class object is instantiated, and instantiated properly |
|
127 | + if ( |
|
128 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
129 | + && $class_cache instanceof ClassInterfaceCache |
|
130 | + ) { |
|
131 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
132 | + } |
|
133 | + return EE_Dependency_Map::$_instance; |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @param RequestInterface $request |
|
139 | + */ |
|
140 | + public function setRequest(RequestInterface $request) |
|
141 | + { |
|
142 | + $this->request = $request; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @param LegacyRequestInterface $legacy_request |
|
148 | + */ |
|
149 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
150 | + { |
|
151 | + $this->legacy_request = $legacy_request; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @param ResponseInterface $response |
|
157 | + */ |
|
158 | + public function setResponse(ResponseInterface $response) |
|
159 | + { |
|
160 | + $this->response = $response; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param LoaderInterface $loader |
|
166 | + */ |
|
167 | + public function setLoader(LoaderInterface $loader) |
|
168 | + { |
|
169 | + $this->loader = $loader; |
|
170 | + } |
|
171 | + |
|
172 | + |
|
173 | + /** |
|
174 | + * @param string $class |
|
175 | + * @param array $dependencies |
|
176 | + * @param int $overwrite |
|
177 | + * @return bool |
|
178 | + */ |
|
179 | + public static function register_dependencies( |
|
180 | + $class, |
|
181 | + array $dependencies, |
|
182 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
183 | + ) { |
|
184 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
190 | + * to the class specified by the first parameter. |
|
191 | + * IMPORTANT !!! |
|
192 | + * The order of elements in the incoming $dependencies array MUST match |
|
193 | + * the order of the constructor parameters for the class in question. |
|
194 | + * This is especially important when overriding any existing dependencies that are registered. |
|
195 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
196 | + * |
|
197 | + * @param string $class |
|
198 | + * @param array $dependencies |
|
199 | + * @param int $overwrite |
|
200 | + * @return bool |
|
201 | + */ |
|
202 | + public function registerDependencies( |
|
203 | + $class, |
|
204 | + array $dependencies, |
|
205 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
206 | + ) { |
|
207 | + $class = trim($class, '\\'); |
|
208 | + $registered = false; |
|
209 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
210 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
211 | + } |
|
212 | + // we need to make sure that any aliases used when registering a dependency |
|
213 | + // get resolved to the correct class name |
|
214 | + foreach ($dependencies as $dependency => $load_source) { |
|
215 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
216 | + if ( |
|
217 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
218 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
219 | + ) { |
|
220 | + unset($dependencies[ $dependency ]); |
|
221 | + $dependencies[ $alias ] = $load_source; |
|
222 | + $registered = true; |
|
223 | + } |
|
224 | + } |
|
225 | + // now add our two lists of dependencies together. |
|
226 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
227 | + // so $dependencies is NOT overwritten because it is listed first |
|
228 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
229 | + // Union is way faster than array_merge() but should be used with caution... |
|
230 | + // especially with numerically indexed arrays |
|
231 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
232 | + // now we need to ensure that the resulting dependencies |
|
233 | + // array only has the entries that are required for the class |
|
234 | + // so first count how many dependencies were originally registered for the class |
|
235 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
236 | + // if that count is non-zero (meaning dependencies were already registered) |
|
237 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
238 | + // then truncate the final array to match that count |
|
239 | + ? array_slice($dependencies, 0, $dependency_count) |
|
240 | + // otherwise just take the incoming array because nothing previously existed |
|
241 | + : $dependencies; |
|
242 | + return $registered; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @param string $class_name |
|
248 | + * @param string $loader |
|
249 | + * @return bool |
|
250 | + * @throws DomainException |
|
251 | + */ |
|
252 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
253 | + { |
|
254 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader); |
|
255 | + } |
|
256 | + |
|
257 | + |
|
258 | + /** |
|
259 | + * @param string $class_name |
|
260 | + * @param string $loader |
|
261 | + * @return bool |
|
262 | + * @throws DomainException |
|
263 | + */ |
|
264 | + public function registerClassLoader($class_name, $loader = 'load_core') |
|
265 | + { |
|
266 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
267 | + throw new DomainException( |
|
268 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
269 | + ); |
|
270 | + } |
|
271 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
272 | + if ( |
|
273 | + ! is_callable($loader) |
|
274 | + && ( |
|
275 | + strpos($loader, 'load_') !== 0 |
|
276 | + || ! method_exists('EE_Registry', $loader) |
|
277 | + ) |
|
278 | + ) { |
|
279 | + throw new DomainException( |
|
280 | + sprintf( |
|
281 | + esc_html__( |
|
282 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
283 | + 'event_espresso' |
|
284 | + ), |
|
285 | + $loader |
|
286 | + ) |
|
287 | + ); |
|
288 | + } |
|
289 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
290 | + if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
291 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
292 | + return true; |
|
293 | + } |
|
294 | + return false; |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + /** |
|
299 | + * @return array |
|
300 | + */ |
|
301 | + public function dependency_map() |
|
302 | + { |
|
303 | + return $this->_dependency_map; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + /** |
|
308 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
309 | + * |
|
310 | + * @param string $class_name |
|
311 | + * @return boolean |
|
312 | + */ |
|
313 | + public function has($class_name = '') |
|
314 | + { |
|
315 | + // all legacy models have the same dependencies |
|
316 | + if (strpos($class_name, 'EEM_') === 0) { |
|
317 | + $class_name = 'LEGACY_MODELS'; |
|
318 | + } |
|
319 | + return isset($this->_dependency_map[ $class_name ]); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
325 | + * |
|
326 | + * @param string $class_name |
|
327 | + * @param string $dependency |
|
328 | + * @return bool |
|
329 | + */ |
|
330 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
331 | + { |
|
332 | + // all legacy models have the same dependencies |
|
333 | + if (strpos($class_name, 'EEM_') === 0) { |
|
334 | + $class_name = 'LEGACY_MODELS'; |
|
335 | + } |
|
336 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
337 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
343 | + * |
|
344 | + * @param string $class_name |
|
345 | + * @param string $dependency |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
349 | + { |
|
350 | + // all legacy models have the same dependencies |
|
351 | + if (strpos($class_name, 'EEM_') === 0) { |
|
352 | + $class_name = 'LEGACY_MODELS'; |
|
353 | + } |
|
354 | + $dependency = $this->getFqnForAlias($dependency); |
|
355 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
356 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
357 | + : EE_Dependency_Map::not_registered; |
|
358 | + } |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * @param string $class_name |
|
363 | + * @return string | Closure |
|
364 | + */ |
|
365 | + public function class_loader($class_name) |
|
366 | + { |
|
367 | + // all legacy models use load_model() |
|
368 | + if (strpos($class_name, 'EEM_') === 0) { |
|
369 | + return 'load_model'; |
|
370 | + } |
|
371 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
372 | + // perform strpos() first to avoid loading regex every time we load a class |
|
373 | + if ( |
|
374 | + strpos($class_name, 'EE_CPT_') === 0 |
|
375 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
376 | + ) { |
|
377 | + return 'load_core'; |
|
378 | + } |
|
379 | + $class_name = $this->getFqnForAlias($class_name); |
|
380 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * @return array |
|
386 | + */ |
|
387 | + public function class_loaders() |
|
388 | + { |
|
389 | + return $this->_class_loaders; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * adds an alias for a classname |
|
395 | + * |
|
396 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
397 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
398 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
399 | + * @throws InvalidAliasException |
|
400 | + */ |
|
401 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
402 | + { |
|
403 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
409 | + * WHY? |
|
410 | + * Because if a class is type hinting for a concretion, |
|
411 | + * then why would we need to find another class to supply it? |
|
412 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
413 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
414 | + * Don't go looking for some substitute. |
|
415 | + * Whereas if a class is type hinting for an interface... |
|
416 | + * then we need to find an actual class to use. |
|
417 | + * So the interface IS the alias for some other FQN, |
|
418 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
419 | + * represents some other class. |
|
420 | + * |
|
421 | + * @param string $fqn |
|
422 | + * @param string $for_class |
|
423 | + * @return bool |
|
424 | + */ |
|
425 | + public function isAlias($fqn = '', $for_class = '') |
|
426 | + { |
|
427 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + /** |
|
432 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
433 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
434 | + * for example: |
|
435 | + * if the following two entries were added to the _aliases array: |
|
436 | + * array( |
|
437 | + * 'interface_alias' => 'some\namespace\interface' |
|
438 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
439 | + * ) |
|
440 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
441 | + * to load an instance of 'some\namespace\classname' |
|
442 | + * |
|
443 | + * @param string $alias |
|
444 | + * @param string $for_class |
|
445 | + * @return string |
|
446 | + */ |
|
447 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
448 | + { |
|
449 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
450 | + } |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
455 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
456 | + * This is done by using the following class constants: |
|
457 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
458 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
459 | + */ |
|
460 | + protected function _register_core_dependencies() |
|
461 | + { |
|
462 | + $this->_dependency_map = [ |
|
463 | + 'EE_Request_Handler' => [ |
|
464 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
465 | + ], |
|
466 | + 'EE_System' => [ |
|
467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
469 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
470 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
471 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
472 | + ], |
|
473 | + 'EE_Admin' => [ |
|
474 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
475 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
476 | + ], |
|
477 | + 'EE_Cart' => [ |
|
478 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
479 | + ], |
|
480 | + 'EE_Messenger_Collection_Loader' => [ |
|
481 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
482 | + ], |
|
483 | + 'EE_Message_Type_Collection_Loader' => [ |
|
484 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
485 | + ], |
|
486 | + 'EE_Message_Resource_Manager' => [ |
|
487 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
488 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
489 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
490 | + ], |
|
491 | + 'EE_Message_Factory' => [ |
|
492 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
493 | + ], |
|
494 | + 'EE_messages' => [ |
|
495 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
496 | + ], |
|
497 | + 'EE_Messages_Generator' => [ |
|
498 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
499 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
500 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
501 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
502 | + ], |
|
503 | + 'EE_Messages_Processor' => [ |
|
504 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
505 | + ], |
|
506 | + 'EE_Messages_Queue' => [ |
|
507 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
508 | + ], |
|
509 | + 'EE_Messages_Template_Defaults' => [ |
|
510 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
511 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
512 | + ], |
|
513 | + 'EE_Message_To_Generate_From_Request' => [ |
|
514 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
515 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
516 | + ], |
|
517 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
518 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
519 | + ], |
|
520 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
521 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
523 | + ], |
|
524 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
525 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
526 | + ], |
|
527 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
528 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
529 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
530 | + ], |
|
531 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
532 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
533 | + ], |
|
534 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
535 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
536 | + ], |
|
537 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
538 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
539 | + ], |
|
540 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
541 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
542 | + ], |
|
543 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
544 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
545 | + ], |
|
546 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
547 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
548 | + ], |
|
549 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
550 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
551 | + ], |
|
552 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
553 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
554 | + ], |
|
555 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
556 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
557 | + ], |
|
558 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
559 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
560 | + ], |
|
561 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
562 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
563 | + ], |
|
564 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
565 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
566 | + ], |
|
567 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
568 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
569 | + ], |
|
570 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
571 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
572 | + ], |
|
573 | + 'EE_Data_Migration_Class_Base' => [ |
|
574 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
575 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
576 | + ], |
|
577 | + 'EE_DMS_Core_4_1_0' => [ |
|
578 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
579 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
580 | + ], |
|
581 | + 'EE_DMS_Core_4_2_0' => [ |
|
582 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
583 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
584 | + ], |
|
585 | + 'EE_DMS_Core_4_3_0' => [ |
|
586 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
587 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
588 | + ], |
|
589 | + 'EE_DMS_Core_4_4_0' => [ |
|
590 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
591 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
592 | + ], |
|
593 | + 'EE_DMS_Core_4_5_0' => [ |
|
594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | + ], |
|
597 | + 'EE_DMS_Core_4_6_0' => [ |
|
598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | + ], |
|
601 | + 'EE_DMS_Core_4_7_0' => [ |
|
602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | + ], |
|
605 | + 'EE_DMS_Core_4_8_0' => [ |
|
606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | + ], |
|
609 | + 'EE_DMS_Core_4_9_0' => [ |
|
610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | + ], |
|
613 | + 'EE_DMS_Core_4_10_0' => [ |
|
614 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
617 | + ], |
|
618 | + 'EE_DMS_Core_4_11_0' => [ |
|
619 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
620 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
621 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
622 | + ], |
|
623 | + 'EE_DMS_Core_4_12_0' => [ |
|
624 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
625 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
626 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
627 | + ], |
|
628 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
629 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_new_object, |
|
630 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
631 | + ], |
|
632 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
633 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
634 | + ], |
|
635 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
636 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
637 | + ], |
|
638 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
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' => [ |
|
643 | + null, |
|
644 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
645 | + ], |
|
646 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
647 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
648 | + ], |
|
649 | + 'LEGACY_MODELS' => [ |
|
650 | + null, |
|
651 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
652 | + ], |
|
653 | + 'EE_Module_Request_Router' => [ |
|
654 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
655 | + ], |
|
656 | + 'EE_Registration_Processor' => [ |
|
657 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
658 | + ], |
|
659 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
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\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
665 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
666 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
667 | + ], |
|
668 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
669 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
670 | + ], |
|
671 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
672 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
673 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
674 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
675 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
676 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
677 | + ], |
|
678 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
679 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
680 | + ], |
|
681 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
682 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
683 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
684 | + ], |
|
685 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
686 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
687 | + ], |
|
688 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
689 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
690 | + ], |
|
691 | + 'EE_CPT_Strategy' => [ |
|
692 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
693 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
694 | + ], |
|
695 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
696 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
697 | + ], |
|
698 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
699 | + null, |
|
700 | + null, |
|
701 | + null, |
|
702 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
703 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
704 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
705 | + ], |
|
706 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
707 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
708 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
709 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
710 | + ], |
|
711 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
712 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
713 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
714 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
715 | + ], |
|
716 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
717 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
718 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
719 | + ], |
|
720 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
721 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
722 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
723 | + ], |
|
724 | + 'EE_URL_Validation_Strategy' => [ |
|
725 | + null, |
|
726 | + null, |
|
727 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
728 | + ], |
|
729 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
730 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
731 | + ], |
|
732 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
733 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
734 | + ], |
|
735 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
736 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
737 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
738 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
739 | + null, |
|
740 | + ], |
|
741 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
742 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
743 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
744 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
745 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
746 | + ], |
|
747 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
748 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
749 | + ], |
|
750 | + 'EventEspresso\core\services\routing\Router' => [ |
|
751 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
752 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
753 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
754 | + ], |
|
755 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
756 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
757 | + ], |
|
758 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
759 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
760 | + ], |
|
761 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
762 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
763 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | + ], |
|
765 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
766 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
767 | + ], |
|
768 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
769 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
770 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
771 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
772 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
773 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
774 | + ], |
|
775 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
776 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
777 | + ], |
|
778 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
779 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
780 | + ], |
|
781 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
782 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache |
|
783 | + ], |
|
784 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
785 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
786 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
787 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
788 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
789 | + ], |
|
790 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
791 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
792 | + ], |
|
793 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
794 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
795 | + ], |
|
796 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
797 | + 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
798 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
800 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
801 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
802 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
803 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
804 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
805 | + ], |
|
806 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
807 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
808 | + ], |
|
809 | + ]; |
|
810 | + } |
|
811 | + |
|
812 | + |
|
813 | + /** |
|
814 | + * Registers how core classes are loaded. |
|
815 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
816 | + * 'EE_Request_Handler' => 'load_core' |
|
817 | + * 'EE_Messages_Queue' => 'load_lib' |
|
818 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
819 | + * or, if greater control is required, by providing a custom closure. For example: |
|
820 | + * 'Some_Class' => function () { |
|
821 | + * return new Some_Class(); |
|
822 | + * }, |
|
823 | + * This is required for instantiating dependencies |
|
824 | + * where an interface has been type hinted in a class constructor. For example: |
|
825 | + * 'Required_Interface' => function () { |
|
826 | + * return new A_Class_That_Implements_Required_Interface(); |
|
827 | + * }, |
|
828 | + */ |
|
829 | + protected function _register_core_class_loaders() |
|
830 | + { |
|
831 | + $this->_class_loaders = [ |
|
832 | + // load_core |
|
833 | + 'EE_Dependency_Map' => function () { |
|
834 | + return $this; |
|
835 | + }, |
|
836 | + 'EE_Capabilities' => 'load_core', |
|
837 | + 'EE_Encryption' => 'load_core', |
|
838 | + 'EE_Front_Controller' => 'load_core', |
|
839 | + 'EE_Module_Request_Router' => 'load_core', |
|
840 | + 'EE_Registry' => 'load_core', |
|
841 | + 'EE_Request' => function () { |
|
842 | + return $this->legacy_request; |
|
843 | + }, |
|
844 | + 'EventEspresso\core\services\request\Request' => function () { |
|
845 | + return $this->request; |
|
846 | + }, |
|
847 | + 'EventEspresso\core\services\request\Response' => function () { |
|
848 | + return $this->response; |
|
849 | + }, |
|
850 | + 'EE_Base' => 'load_core', |
|
851 | + 'EE_Request_Handler' => 'load_core', |
|
852 | + 'EE_Session' => 'load_core', |
|
853 | + 'EE_Cron_Tasks' => 'load_core', |
|
854 | + 'EE_System' => 'load_core', |
|
855 | + 'EE_Maintenance_Mode' => 'load_core', |
|
856 | + 'EE_Register_CPTs' => 'load_core', |
|
857 | + 'EE_Admin' => 'load_core', |
|
858 | + 'EE_CPT_Strategy' => 'load_core', |
|
859 | + // load_class |
|
860 | + 'EE_Registration_Processor' => 'load_class', |
|
861 | + // load_lib |
|
862 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
863 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
864 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
865 | + 'EE_Messenger_Collection' => 'load_lib', |
|
866 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
867 | + 'EE_Messages_Processor' => 'load_lib', |
|
868 | + 'EE_Message_Repository' => 'load_lib', |
|
869 | + 'EE_Messages_Queue' => 'load_lib', |
|
870 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
871 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
872 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
873 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
874 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
875 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
876 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
877 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
878 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
879 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
880 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
881 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
882 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
883 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
884 | + 'EE_Messages_Generator' => static function () { |
|
885 | + return EE_Registry::instance()->load_lib( |
|
886 | + 'Messages_Generator', |
|
887 | + [], |
|
888 | + false, |
|
889 | + false |
|
890 | + ); |
|
891 | + }, |
|
892 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
893 | + return EE_Registry::instance()->load_lib( |
|
894 | + 'Messages_Template_Defaults', |
|
895 | + $arguments, |
|
896 | + false, |
|
897 | + false |
|
898 | + ); |
|
899 | + }, |
|
900 | + // load_helper |
|
901 | + 'EEH_Parse_Shortcodes' => static function () { |
|
902 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
903 | + return new EEH_Parse_Shortcodes(); |
|
904 | + } |
|
905 | + return null; |
|
906 | + }, |
|
907 | + 'EE_Template_Config' => static function () { |
|
908 | + return EE_Config::instance()->template_settings; |
|
909 | + }, |
|
910 | + 'EE_Currency_Config' => static function () { |
|
911 | + return EE_Config::instance()->currency; |
|
912 | + }, |
|
913 | + 'EE_Registration_Config' => static function () { |
|
914 | + return EE_Config::instance()->registration; |
|
915 | + }, |
|
916 | + 'EE_Core_Config' => static function () { |
|
917 | + return EE_Config::instance()->core; |
|
918 | + }, |
|
919 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
920 | + return LoaderFactory::getLoader(); |
|
921 | + }, |
|
922 | + 'EE_Network_Config' => static function () { |
|
923 | + return EE_Network_Config::instance(); |
|
924 | + }, |
|
925 | + 'EE_Config' => static function () { |
|
926 | + return EE_Config::instance(); |
|
927 | + }, |
|
928 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
929 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
930 | + }, |
|
931 | + 'EE_Admin_Config' => static function () { |
|
932 | + return EE_Config::instance()->admin; |
|
933 | + }, |
|
934 | + 'EE_Organization_Config' => static function () { |
|
935 | + return EE_Config::instance()->organization; |
|
936 | + }, |
|
937 | + 'EE_Network_Core_Config' => static function () { |
|
938 | + return EE_Network_Config::instance()->core; |
|
939 | + }, |
|
940 | + 'EE_Environment_Config' => static function () { |
|
941 | + return EE_Config::instance()->environment; |
|
942 | + }, |
|
943 | + 'EED_Core_Rest_Api' => static function () { |
|
944 | + return EED_Core_Rest_Api::instance(); |
|
945 | + }, |
|
946 | + 'WP_REST_Server' => static function () { |
|
947 | + return rest_get_server(); |
|
948 | + }, |
|
949 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
950 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
951 | + }, |
|
952 | + ]; |
|
953 | + } |
|
954 | + |
|
955 | + |
|
956 | + /** |
|
957 | + * can be used for supplying alternate names for classes, |
|
958 | + * or for connecting interface names to instantiable classes |
|
959 | + * |
|
960 | + * @throws InvalidAliasException |
|
961 | + */ |
|
962 | + protected function _register_core_aliases() |
|
963 | + { |
|
964 | + $aliases = [ |
|
965 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
966 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
967 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
968 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
969 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
970 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
971 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
972 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
973 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
974 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
975 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
976 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
977 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
978 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
979 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
980 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
981 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
982 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
983 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
984 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
985 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
986 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
987 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
988 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
989 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
990 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
991 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
992 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
993 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
994 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
995 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
996 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
997 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
998 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
999 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1000 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1001 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1002 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1003 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1004 | + ]; |
|
1005 | + foreach ($aliases as $alias => $fqn) { |
|
1006 | + if (is_array($fqn)) { |
|
1007 | + foreach ($fqn as $class => $for_class) { |
|
1008 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1009 | + } |
|
1010 | + continue; |
|
1011 | + } |
|
1012 | + $this->class_cache->addAlias($fqn, $alias); |
|
1013 | + } |
|
1014 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1015 | + $this->class_cache->addAlias( |
|
1016 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1017 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1018 | + ); |
|
1019 | + } |
|
1020 | + } |
|
1021 | + |
|
1022 | + |
|
1023 | + /** |
|
1024 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1025 | + * request Primarily used by unit tests. |
|
1026 | + */ |
|
1027 | + public function reset() |
|
1028 | + { |
|
1029 | + $this->_register_core_class_loaders(); |
|
1030 | + $this->_register_core_dependencies(); |
|
1031 | + } |
|
1032 | + |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1036 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1037 | + * WHY? |
|
1038 | + * Because if a class is type hinting for a concretion, |
|
1039 | + * then why would we need to find another class to supply it? |
|
1040 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1041 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1042 | + * Don't go looking for some substitute. |
|
1043 | + * Whereas if a class is type hinting for an interface... |
|
1044 | + * then we need to find an actual class to use. |
|
1045 | + * So the interface IS the alias for some other FQN, |
|
1046 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1047 | + * represents some other class. |
|
1048 | + * |
|
1049 | + * @param string $fqn |
|
1050 | + * @param string $for_class |
|
1051 | + * @return bool |
|
1052 | + * @deprecated 4.9.62.p |
|
1053 | + */ |
|
1054 | + public function has_alias($fqn = '', $for_class = '') |
|
1055 | + { |
|
1056 | + return $this->isAlias($fqn, $for_class); |
|
1057 | + } |
|
1058 | + |
|
1059 | + |
|
1060 | + /** |
|
1061 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1062 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1063 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1064 | + * for example: |
|
1065 | + * if the following two entries were added to the _aliases array: |
|
1066 | + * array( |
|
1067 | + * 'interface_alias' => 'some\namespace\interface' |
|
1068 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1069 | + * ) |
|
1070 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1071 | + * to load an instance of 'some\namespace\classname' |
|
1072 | + * |
|
1073 | + * @param string $alias |
|
1074 | + * @param string $for_class |
|
1075 | + * @return string |
|
1076 | + * @deprecated 4.9.62.p |
|
1077 | + */ |
|
1078 | + public function get_alias($alias = '', $for_class = '') |
|
1079 | + { |
|
1080 | + return $this->getFqnForAlias($alias, $for_class); |
|
1081 | + } |
|
1082 | 1082 | } |
@@ -17,73 +17,73 @@ |
||
17 | 17 | class FormSectionDelete extends EntityMutator |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * Defines the mutation data modification closure. |
|
22 | - * |
|
23 | - * @param EEM_Form_Section $model |
|
24 | - * @return callable |
|
25 | - */ |
|
26 | - public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
27 | - { |
|
28 | - /** |
|
29 | - * Deletes an entity. |
|
30 | - * |
|
31 | - * @param array $input The input for the mutation |
|
32 | - * @param AppContext $context The AppContext passed down to all resolvers |
|
33 | - * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | - try { |
|
38 | - /** @var EE_Form_Section $entity */ |
|
39 | - $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
20 | + /** |
|
21 | + * Defines the mutation data modification closure. |
|
22 | + * |
|
23 | + * @param EEM_Form_Section $model |
|
24 | + * @return callable |
|
25 | + */ |
|
26 | + public static function mutateAndGetPayload(EEM_Form_Section $model) |
|
27 | + { |
|
28 | + /** |
|
29 | + * Deletes an entity. |
|
30 | + * |
|
31 | + * @param array $input The input for the mutation |
|
32 | + * @param AppContext $context The AppContext passed down to all resolvers |
|
33 | + * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | + try { |
|
38 | + /** @var EE_Form_Section $entity */ |
|
39 | + $entity = EntityMutator::getEntityFromInputData($model, $input); |
|
40 | 40 | |
41 | - $result = FormSectionDelete::deleteSectionAndRelations($entity); |
|
41 | + $result = FormSectionDelete::deleteSectionAndRelations($entity); |
|
42 | 42 | |
43 | - EntityMutator::validateResults($result); |
|
43 | + EntityMutator::validateResults($result); |
|
44 | 44 | |
45 | - do_action( |
|
46 | - 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete', |
|
47 | - $entity, |
|
48 | - $input |
|
49 | - ); |
|
50 | - } catch (Exception $exception) { |
|
51 | - EntityMutator::handleExceptions( |
|
52 | - $exception, |
|
53 | - esc_html__( |
|
54 | - 'The form section could not be deleted because of the following error(s)', |
|
55 | - 'event_espresso' |
|
56 | - ) |
|
57 | - ); |
|
58 | - } |
|
45 | + do_action( |
|
46 | + 'AHEE__EventEspresso_core_domain_services_graphql_mutators_form_section_delete', |
|
47 | + $entity, |
|
48 | + $input |
|
49 | + ); |
|
50 | + } catch (Exception $exception) { |
|
51 | + EntityMutator::handleExceptions( |
|
52 | + $exception, |
|
53 | + esc_html__( |
|
54 | + 'The form section could not be deleted because of the following error(s)', |
|
55 | + 'event_espresso' |
|
56 | + ) |
|
57 | + ); |
|
58 | + } |
|
59 | 59 | |
60 | - return [ |
|
61 | - 'deleted' => $entity, |
|
62 | - ]; |
|
63 | - }; |
|
64 | - } |
|
60 | + return [ |
|
61 | + 'deleted' => $entity, |
|
62 | + ]; |
|
63 | + }; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * Deletes a form section along with its related form elements. |
|
68 | - * |
|
69 | - * @param EE_Form_Section $entity |
|
70 | - * @return bool | int |
|
71 | - * @throws ReflectionException |
|
72 | - * @throws InvalidArgumentException |
|
73 | - * @throws InvalidInterfaceException |
|
74 | - * @throws InvalidDataTypeException |
|
75 | - * @throws EE_Error |
|
76 | - */ |
|
77 | - public static function deleteSectionAndRelations(EE_Form_Section $entity) |
|
78 | - { |
|
79 | - // Remove related non-default form elements |
|
80 | - $entity->delete_related('Form_Element', [ |
|
81 | - [ |
|
82 | - 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
83 | - ] |
|
84 | - ]); |
|
66 | + /** |
|
67 | + * Deletes a form section along with its related form elements. |
|
68 | + * |
|
69 | + * @param EE_Form_Section $entity |
|
70 | + * @return bool | int |
|
71 | + * @throws ReflectionException |
|
72 | + * @throws InvalidArgumentException |
|
73 | + * @throws InvalidInterfaceException |
|
74 | + * @throws InvalidDataTypeException |
|
75 | + * @throws EE_Error |
|
76 | + */ |
|
77 | + public static function deleteSectionAndRelations(EE_Form_Section $entity) |
|
78 | + { |
|
79 | + // Remove related non-default form elements |
|
80 | + $entity->delete_related('Form_Element', [ |
|
81 | + [ |
|
82 | + 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
83 | + ] |
|
84 | + ]); |
|
85 | 85 | |
86 | - // Now delete the form section |
|
87 | - return $entity->delete(); |
|
88 | - } |
|
86 | + // Now delete the form section |
|
87 | + return $entity->delete(); |
|
88 | + } |
|
89 | 89 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param ResolveInfo $info The ResolveInfo passed down to all resolvers |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - return static function (array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
36 | + return static function(array $input, AppContext $context, ResolveInfo $info) use ($model): array { |
|
37 | 37 | try { |
38 | 38 | /** @var EE_Form_Section $entity */ |
39 | 39 | $entity = EntityMutator::getEntityFromInputData($model, $input); |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // Remove related non-default form elements |
80 | 80 | $entity->delete_related('Form_Element', [ |
81 | 81 | [ |
82 | - 'FIN_status' => ['NOT IN', [ FormStatus::SHARED, FormStatus::DEFAULT] ] |
|
82 | + 'FIN_status' => ['NOT IN', [FormStatus::SHARED, FormStatus::DEFAULT]] |
|
83 | 83 | ] |
84 | 84 | ]); |
85 | 85 |
@@ -5,84 +5,84 @@ |
||
5 | 5 | class Input |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * indicates that the HTML input type is 'checkbox' |
|
10 | - */ |
|
11 | - public const TYPE_CHECKBOX = 'checkbox'; |
|
12 | - |
|
13 | - /** |
|
14 | - * indicates that the HTML input type is 'multi checkbox' |
|
15 | - */ |
|
16 | - public const TYPE_CHECKBOX_MULTI = 'checkbox-multi'; |
|
17 | - |
|
18 | - /** |
|
19 | - * indicates that the HTML input type is 'color' |
|
20 | - */ |
|
21 | - public const TYPE_COLOR = 'color'; |
|
22 | - |
|
23 | - /** |
|
24 | - * indicates that the HTML input type is 'file' |
|
25 | - */ |
|
26 | - public const TYPE_FILE = 'file'; |
|
27 | - |
|
28 | - /** |
|
29 | - * indicates that the HTML input type is 'hidden' |
|
30 | - */ |
|
31 | - public const TYPE_HIDDEN = 'hidden'; |
|
32 | - |
|
33 | - /** |
|
34 | - * indicates that the HTML input type is 'image' |
|
35 | - */ |
|
36 | - public const TYPE_IMAGE = 'image'; |
|
37 | - |
|
38 | - /** |
|
39 | - * indicates that the HTML input type is 'password' |
|
40 | - */ |
|
41 | - public const TYPE_PASSWORD = 'password'; |
|
42 | - |
|
43 | - /** |
|
44 | - * indicates that the HTML input type is 'radio' |
|
45 | - */ |
|
46 | - public const TYPE_RADIO = 'radio'; |
|
47 | - |
|
48 | - /** |
|
49 | - * indicates that the HTML input type is 'url' |
|
50 | - */ |
|
51 | - public const TYPE_URL = 'url'; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var array |
|
55 | - */ |
|
56 | - private $valid_type_options; |
|
57 | - |
|
58 | - |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->valid_type_options = apply_filters( |
|
62 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options', |
|
63 | - [ |
|
64 | - Input::TYPE_CHECKBOX => esc_html__('Checkbox', 'event_espresso'), |
|
65 | - Input::TYPE_CHECKBOX_MULTI => esc_html__('Multi Checkbox', 'event_espresso'), |
|
66 | - Input::TYPE_COLOR => esc_html__('Color Picker', 'event_espresso'), |
|
67 | - Input::TYPE_FILE => esc_html__('File Upload', 'event_espresso'), |
|
68 | - Input::TYPE_HIDDEN => esc_html__('Hidden', 'event_espresso'), |
|
69 | - Input::TYPE_IMAGE => esc_html__('Image Upload', 'event_espresso'), |
|
70 | - Input::TYPE_PASSWORD => esc_html__('Password', 'event_espresso'), |
|
71 | - Input::TYPE_RADIO => esc_html__('Radio Button', 'event_espresso'), |
|
72 | - Input::TYPE_URL => esc_html__('URL', 'event_espresso'), |
|
73 | - ] |
|
74 | - ); |
|
75 | - } |
|
76 | - |
|
77 | - |
|
78 | - /** |
|
79 | - * @param bool $constants_only |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - public function validTypeOptions(bool $constants_only = false): array |
|
83 | - { |
|
84 | - return $constants_only |
|
85 | - ? array_keys($this->valid_type_options) |
|
86 | - : $this->valid_type_options; |
|
87 | - } |
|
8 | + /** |
|
9 | + * indicates that the HTML input type is 'checkbox' |
|
10 | + */ |
|
11 | + public const TYPE_CHECKBOX = 'checkbox'; |
|
12 | + |
|
13 | + /** |
|
14 | + * indicates that the HTML input type is 'multi checkbox' |
|
15 | + */ |
|
16 | + public const TYPE_CHECKBOX_MULTI = 'checkbox-multi'; |
|
17 | + |
|
18 | + /** |
|
19 | + * indicates that the HTML input type is 'color' |
|
20 | + */ |
|
21 | + public const TYPE_COLOR = 'color'; |
|
22 | + |
|
23 | + /** |
|
24 | + * indicates that the HTML input type is 'file' |
|
25 | + */ |
|
26 | + public const TYPE_FILE = 'file'; |
|
27 | + |
|
28 | + /** |
|
29 | + * indicates that the HTML input type is 'hidden' |
|
30 | + */ |
|
31 | + public const TYPE_HIDDEN = 'hidden'; |
|
32 | + |
|
33 | + /** |
|
34 | + * indicates that the HTML input type is 'image' |
|
35 | + */ |
|
36 | + public const TYPE_IMAGE = 'image'; |
|
37 | + |
|
38 | + /** |
|
39 | + * indicates that the HTML input type is 'password' |
|
40 | + */ |
|
41 | + public const TYPE_PASSWORD = 'password'; |
|
42 | + |
|
43 | + /** |
|
44 | + * indicates that the HTML input type is 'radio' |
|
45 | + */ |
|
46 | + public const TYPE_RADIO = 'radio'; |
|
47 | + |
|
48 | + /** |
|
49 | + * indicates that the HTML input type is 'url' |
|
50 | + */ |
|
51 | + public const TYPE_URL = 'url'; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var array |
|
55 | + */ |
|
56 | + private $valid_type_options; |
|
57 | + |
|
58 | + |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->valid_type_options = apply_filters( |
|
62 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Input__valid_type_options', |
|
63 | + [ |
|
64 | + Input::TYPE_CHECKBOX => esc_html__('Checkbox', 'event_espresso'), |
|
65 | + Input::TYPE_CHECKBOX_MULTI => esc_html__('Multi Checkbox', 'event_espresso'), |
|
66 | + Input::TYPE_COLOR => esc_html__('Color Picker', 'event_espresso'), |
|
67 | + Input::TYPE_FILE => esc_html__('File Upload', 'event_espresso'), |
|
68 | + Input::TYPE_HIDDEN => esc_html__('Hidden', 'event_espresso'), |
|
69 | + Input::TYPE_IMAGE => esc_html__('Image Upload', 'event_espresso'), |
|
70 | + Input::TYPE_PASSWORD => esc_html__('Password', 'event_espresso'), |
|
71 | + Input::TYPE_RADIO => esc_html__('Radio Button', 'event_espresso'), |
|
72 | + Input::TYPE_URL => esc_html__('URL', 'event_espresso'), |
|
73 | + ] |
|
74 | + ); |
|
75 | + } |
|
76 | + |
|
77 | + |
|
78 | + /** |
|
79 | + * @param bool $constants_only |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + public function validTypeOptions(bool $constants_only = false): array |
|
83 | + { |
|
84 | + return $constants_only |
|
85 | + ? array_keys($this->valid_type_options) |
|
86 | + : $this->valid_type_options; |
|
87 | + } |
|
88 | 88 | } |
@@ -4,36 +4,36 @@ |
||
4 | 4 | |
5 | 5 | class Block |
6 | 6 | { |
7 | - /** |
|
8 | - * indicates that the element is a general HTML block |
|
9 | - */ |
|
10 | - public const TYPE_HTML = 'html'; |
|
7 | + /** |
|
8 | + * indicates that the element is a general HTML block |
|
9 | + */ |
|
10 | + public const TYPE_HTML = 'html'; |
|
11 | 11 | |
12 | - /** |
|
13 | - * @var array |
|
14 | - */ |
|
15 | - private $valid_type_options; |
|
12 | + /** |
|
13 | + * @var array |
|
14 | + */ |
|
15 | + private $valid_type_options; |
|
16 | 16 | |
17 | 17 | |
18 | - public function __construct() |
|
19 | - { |
|
20 | - $this->valid_type_options = apply_filters( |
|
21 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options', |
|
22 | - [ |
|
23 | - Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'), |
|
24 | - ] |
|
25 | - ); |
|
26 | - } |
|
18 | + public function __construct() |
|
19 | + { |
|
20 | + $this->valid_type_options = apply_filters( |
|
21 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Block__valid_type_options', |
|
22 | + [ |
|
23 | + Block::TYPE_HTML => esc_html__('HTML Block', 'event_espresso'), |
|
24 | + ] |
|
25 | + ); |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - /** |
|
30 | - * @param bool $constants_only |
|
31 | - * @return array |
|
32 | - */ |
|
33 | - public function validTypeOptions(bool $constants_only = false): array |
|
34 | - { |
|
35 | - return $constants_only |
|
36 | - ? array_keys($this->valid_type_options) |
|
37 | - : $this->valid_type_options; |
|
38 | - } |
|
29 | + /** |
|
30 | + * @param bool $constants_only |
|
31 | + * @return array |
|
32 | + */ |
|
33 | + public function validTypeOptions(bool $constants_only = false): array |
|
34 | + { |
|
35 | + return $constants_only |
|
36 | + ? array_keys($this->valid_type_options) |
|
37 | + : $this->valid_type_options; |
|
38 | + } |
|
39 | 39 | } |
@@ -22,124 +22,124 @@ |
||
22 | 22 | */ |
23 | 23 | class InputTypes |
24 | 24 | { |
25 | - /** |
|
26 | - * @var Block |
|
27 | - */ |
|
28 | - private $block; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Button |
|
32 | - */ |
|
33 | - private $button; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var DateTime |
|
37 | - */ |
|
38 | - private $datetime; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var Input |
|
42 | - */ |
|
43 | - private $input; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var Number |
|
47 | - */ |
|
48 | - private $number; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var Phone |
|
52 | - */ |
|
53 | - private $phone; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var Select |
|
57 | - */ |
|
58 | - private $select; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var Text |
|
62 | - */ |
|
63 | - private $text; |
|
64 | - |
|
65 | - /** |
|
66 | - * @var array |
|
67 | - */ |
|
68 | - private $valid_type_options; |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * InputTypes constructor. |
|
73 | - * |
|
74 | - * @param Block $block |
|
75 | - * @param Button $button |
|
76 | - * @param DateTime $datetime |
|
77 | - * @param Input $input |
|
78 | - * @param Number $number |
|
79 | - * @param Phone $phone |
|
80 | - * @param Select $select |
|
81 | - * @param Text $text |
|
82 | - */ |
|
83 | - public function __construct( |
|
84 | - Block $block, |
|
85 | - Button $button, |
|
86 | - DateTime $datetime, |
|
87 | - Input $input, |
|
88 | - Number $number, |
|
89 | - Phone $phone, |
|
90 | - Select $select, |
|
91 | - Text $text |
|
92 | - ) { |
|
93 | - $this->block = $block; |
|
94 | - $this->button = $button; |
|
95 | - $this->datetime = $datetime; |
|
96 | - $this->input = $input; |
|
97 | - $this->number = $number; |
|
98 | - $this->phone = $phone; |
|
99 | - $this->select = $select; |
|
100 | - $this->text = $text; |
|
101 | - $this->assembleValidTypeOptions(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - private function assembleValidTypeOptions() |
|
106 | - { |
|
107 | - $block = $this->block->validTypeOptions(); |
|
108 | - $button = $this->button->validTypeOptions(); |
|
109 | - $datetime = $this->datetime->validTypeOptions(); |
|
110 | - $input = $this->input->validTypeOptions(); |
|
111 | - $number = $this->number->validTypeOptions(); |
|
112 | - $phone = $this->phone->validTypeOptions(); |
|
113 | - $select = $this->select->validTypeOptions(); |
|
114 | - $text = $this->text->validTypeOptions(); |
|
115 | - $this->valid_type_options = apply_filters( |
|
116 | - 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | - array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - /** |
|
123 | - * @return array |
|
124 | - */ |
|
125 | - public function getInputTypesValues(): array |
|
126 | - { |
|
127 | - $values = []; |
|
128 | - foreach ($this->valid_type_options as $value => $description) { |
|
129 | - $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | - } |
|
131 | - return $values; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param bool $constants_only |
|
137 | - * @return array |
|
138 | - */ |
|
139 | - public function validTypeOptions(bool $constants_only = false): array |
|
140 | - { |
|
141 | - return $constants_only |
|
142 | - ? array_keys($this->valid_type_options) |
|
143 | - : $this->valid_type_options; |
|
144 | - } |
|
25 | + /** |
|
26 | + * @var Block |
|
27 | + */ |
|
28 | + private $block; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Button |
|
32 | + */ |
|
33 | + private $button; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var DateTime |
|
37 | + */ |
|
38 | + private $datetime; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var Input |
|
42 | + */ |
|
43 | + private $input; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var Number |
|
47 | + */ |
|
48 | + private $number; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var Phone |
|
52 | + */ |
|
53 | + private $phone; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var Select |
|
57 | + */ |
|
58 | + private $select; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var Text |
|
62 | + */ |
|
63 | + private $text; |
|
64 | + |
|
65 | + /** |
|
66 | + * @var array |
|
67 | + */ |
|
68 | + private $valid_type_options; |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * InputTypes constructor. |
|
73 | + * |
|
74 | + * @param Block $block |
|
75 | + * @param Button $button |
|
76 | + * @param DateTime $datetime |
|
77 | + * @param Input $input |
|
78 | + * @param Number $number |
|
79 | + * @param Phone $phone |
|
80 | + * @param Select $select |
|
81 | + * @param Text $text |
|
82 | + */ |
|
83 | + public function __construct( |
|
84 | + Block $block, |
|
85 | + Button $button, |
|
86 | + DateTime $datetime, |
|
87 | + Input $input, |
|
88 | + Number $number, |
|
89 | + Phone $phone, |
|
90 | + Select $select, |
|
91 | + Text $text |
|
92 | + ) { |
|
93 | + $this->block = $block; |
|
94 | + $this->button = $button; |
|
95 | + $this->datetime = $datetime; |
|
96 | + $this->input = $input; |
|
97 | + $this->number = $number; |
|
98 | + $this->phone = $phone; |
|
99 | + $this->select = $select; |
|
100 | + $this->text = $text; |
|
101 | + $this->assembleValidTypeOptions(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + private function assembleValidTypeOptions() |
|
106 | + { |
|
107 | + $block = $this->block->validTypeOptions(); |
|
108 | + $button = $this->button->validTypeOptions(); |
|
109 | + $datetime = $this->datetime->validTypeOptions(); |
|
110 | + $input = $this->input->validTypeOptions(); |
|
111 | + $number = $this->number->validTypeOptions(); |
|
112 | + $phone = $this->phone->validTypeOptions(); |
|
113 | + $select = $this->select->validTypeOptions(); |
|
114 | + $text = $this->text->validTypeOptions(); |
|
115 | + $this->valid_type_options = apply_filters( |
|
116 | + 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
117 | + array_merge($block, $button, $datetime, $input, $number, $phone, $select, $text) |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + /** |
|
123 | + * @return array |
|
124 | + */ |
|
125 | + public function getInputTypesValues(): array |
|
126 | + { |
|
127 | + $values = []; |
|
128 | + foreach ($this->valid_type_options as $value => $description) { |
|
129 | + $values[ GQLUtils::formatEnumKey($value) ] = compact('value', 'description'); |
|
130 | + } |
|
131 | + return $values; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param bool $constants_only |
|
137 | + * @return array |
|
138 | + */ |
|
139 | + public function validTypeOptions(bool $constants_only = false): array |
|
140 | + { |
|
141 | + return $constants_only |
|
142 | + ? array_keys($this->valid_type_options) |
|
143 | + : $this->valid_type_options; |
|
144 | + } |
|
145 | 145 | } |