Complex classes like EE_Dependency_Map often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_Dependency_Map, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
21 | class EE_Dependency_Map |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * This means that the requested class dependency is not present in the dependency map |
||
26 | */ |
||
27 | const not_registered = 0; |
||
28 | |||
29 | /** |
||
30 | * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
||
31 | */ |
||
32 | const load_new_object = 1; |
||
33 | |||
34 | /** |
||
35 | * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
||
36 | * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
||
37 | */ |
||
38 | const load_from_cache = 2; |
||
39 | |||
40 | /** |
||
41 | * When registering a dependency, |
||
42 | * this indicates to keep any existing dependencies that already exist, |
||
43 | * and simply discard any new dependencies declared in the incoming data |
||
44 | */ |
||
45 | const KEEP_EXISTING_DEPENDENCIES = 0; |
||
46 | |||
47 | /** |
||
48 | * When registering a dependency, |
||
49 | * this indicates to overwrite any existing dependencies that already exist using the incoming data |
||
50 | */ |
||
51 | const OVERWRITE_DEPENDENCIES = 1; |
||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * @type EE_Dependency_Map $_instance |
||
57 | */ |
||
58 | protected static $_instance; |
||
59 | |||
60 | /** |
||
61 | * @type EE_Request $request |
||
62 | */ |
||
63 | protected $_request; |
||
64 | |||
65 | /** |
||
66 | * @type EE_Response $response |
||
67 | */ |
||
68 | protected $_response; |
||
69 | |||
70 | /** |
||
71 | * @type LoaderInterface $loader |
||
72 | */ |
||
73 | protected $loader; |
||
74 | |||
75 | /** |
||
76 | * @type array $_dependency_map |
||
77 | */ |
||
78 | protected $_dependency_map = array(); |
||
79 | |||
80 | /** |
||
81 | * @type array $_class_loaders |
||
82 | */ |
||
83 | protected $_class_loaders = array(); |
||
84 | |||
85 | /** |
||
86 | * @type array $_aliases |
||
87 | */ |
||
88 | protected $_aliases = array(); |
||
89 | |||
90 | |||
91 | |||
92 | /** |
||
93 | * EE_Dependency_Map constructor. |
||
94 | * |
||
95 | * @param EE_Request $request |
||
96 | * @param EE_Response $response |
||
97 | */ |
||
98 | protected function __construct(EE_Request $request, EE_Response $response) |
||
105 | |||
106 | |||
107 | |||
108 | /** |
||
109 | * @throws InvalidDataTypeException |
||
110 | * @throws InvalidInterfaceException |
||
111 | * @throws InvalidArgumentException |
||
112 | */ |
||
113 | public function initialize() |
||
119 | |||
120 | |||
121 | |||
122 | /** |
||
123 | * @singleton method used to instantiate class object |
||
124 | * @access public |
||
125 | * @param EE_Request $request |
||
126 | * @param EE_Response $response |
||
127 | * @return EE_Dependency_Map |
||
128 | */ |
||
129 | public static function instance(EE_Request $request = null, EE_Response $response = null) |
||
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * @param LoaderInterface $loader |
||
142 | */ |
||
143 | public function setLoader(LoaderInterface $loader) |
||
147 | |||
148 | |||
149 | |||
150 | /** |
||
151 | * @param string $class |
||
152 | * @param array $dependencies |
||
153 | * @param int $overwrite |
||
154 | * @return bool |
||
155 | */ |
||
156 | public static function register_dependencies( |
||
163 | |||
164 | |||
165 | |||
166 | /** |
||
167 | * Assigns an array of class names and corresponding load sources (new or cached) |
||
168 | * to the class specified by the first parameter. |
||
169 | * IMPORTANT !!! |
||
170 | * The order of elements in the incoming $dependencies array MUST match |
||
171 | * the order of the constructor parameters for the class in question. |
||
172 | * This is especially important when overriding any existing dependencies that are registered. |
||
173 | * the third parameter controls whether any duplicate dependencies are overwritten or not. |
||
174 | * |
||
175 | * @param string $class |
||
176 | * @param array $dependencies |
||
177 | * @param int $overwrite |
||
178 | * @return bool |
||
179 | */ |
||
180 | public function registerDependencies( |
||
222 | |||
223 | |||
224 | |||
225 | /** |
||
226 | * @param string $class_name |
||
227 | * @param string $loader |
||
228 | * @return bool |
||
229 | * @throws DomainException |
||
230 | */ |
||
231 | public static function register_class_loader($class_name, $loader = 'load_core') |
||
232 | { |
||
233 | if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
||
234 | throw new DomainException( |
||
235 | esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
||
236 | ); |
||
237 | } |
||
238 | // check that loader is callable or method starts with "load_" and exists in EE_Registry |
||
239 | if ( |
||
240 | ! is_callable($loader) |
||
241 | && ( |
||
242 | strpos($loader, 'load_') !== 0 |
||
243 | || ! method_exists('EE_Registry', $loader) |
||
244 | ) |
||
245 | ) { |
||
246 | throw new DomainException( |
||
247 | sprintf( |
||
248 | esc_html__( |
||
249 | '"%1$s" is not a valid loader method on EE_Registry.', |
||
250 | 'event_espresso' |
||
251 | ), |
||
252 | $loader |
||
253 | ) |
||
254 | ); |
||
255 | } |
||
256 | $class_name = self::$_instance->get_alias($class_name); |
||
257 | if (! isset(self::$_instance->_class_loaders[$class_name])) { |
||
258 | self::$_instance->_class_loaders[$class_name] = $loader; |
||
259 | return true; |
||
260 | } |
||
261 | return false; |
||
262 | } |
||
263 | |||
264 | |||
265 | |||
266 | /** |
||
267 | * @return array |
||
268 | */ |
||
269 | public function dependency_map() |
||
273 | |||
274 | |||
275 | |||
276 | /** |
||
277 | * returns TRUE if dependency map contains a listing for the provided class name |
||
278 | * |
||
279 | * @param string $class_name |
||
280 | * @return boolean |
||
281 | */ |
||
282 | public function has($class_name = '') |
||
286 | |||
287 | |||
288 | |||
289 | /** |
||
290 | * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
||
291 | * |
||
292 | * @param string $class_name |
||
293 | * @param string $dependency |
||
294 | * @return bool |
||
295 | */ |
||
296 | public function has_dependency_for_class($class_name = '', $dependency = '') |
||
297 | { |
||
298 | $dependency = $this->get_alias($dependency); |
||
299 | return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency]) |
||
300 | ? true |
||
301 | : false; |
||
302 | } |
||
303 | |||
304 | |||
305 | |||
306 | /** |
||
307 | * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
||
308 | * |
||
309 | * @param string $class_name |
||
310 | * @param string $dependency |
||
311 | * @return int |
||
312 | */ |
||
313 | public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
||
320 | |||
321 | |||
322 | |||
323 | /** |
||
324 | * @param string $class_name |
||
325 | * @return string | Closure |
||
326 | */ |
||
327 | public function class_loader($class_name) |
||
328 | { |
||
329 | $class_name = $this->get_alias($class_name); |
||
330 | return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : ''; |
||
331 | } |
||
332 | |||
333 | |||
334 | |||
335 | /** |
||
336 | * @return array |
||
337 | */ |
||
338 | public function class_loaders() |
||
339 | { |
||
340 | return $this->_class_loaders; |
||
341 | } |
||
342 | |||
343 | |||
344 | |||
345 | /** |
||
346 | * adds an alias for a classname |
||
347 | * |
||
348 | * @param string $class_name the class name that should be used (concrete class to replace interface) |
||
349 | * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
||
350 | * @param string $for_class the class that has the dependency (is type hinting for the interface) |
||
351 | */ |
||
352 | public function add_alias($class_name, $alias, $for_class = '') |
||
353 | { |
||
354 | if ($for_class !== '') { |
||
355 | if (! isset($this->_aliases[$for_class])) { |
||
356 | $this->_aliases[$for_class] = array(); |
||
357 | } |
||
358 | $this->_aliases[$for_class][$class_name] = $alias; |
||
359 | } |
||
360 | $this->_aliases[$class_name] = $alias; |
||
361 | } |
||
362 | |||
363 | |||
364 | |||
365 | /** |
||
366 | * returns TRUE if the provided class name has an alias |
||
367 | * |
||
368 | * @param string $class_name |
||
369 | * @param string $for_class |
||
370 | * @return bool |
||
371 | */ |
||
372 | public function has_alias($class_name = '', $for_class = '') |
||
373 | { |
||
374 | return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name]) |
||
375 | || ( |
||
376 | isset($this->_aliases[$class_name]) |
||
377 | && ! is_array($this->_aliases[$class_name]) |
||
378 | ); |
||
379 | } |
||
380 | |||
381 | |||
382 | |||
383 | /** |
||
384 | * returns alias for class name if one exists, otherwise returns the original classname |
||
385 | * functions recursively, so that multiple aliases can be used to drill down to a classname |
||
386 | * for example: |
||
387 | * if the following two entries were added to the _aliases array: |
||
388 | * array( |
||
389 | * 'interface_alias' => 'some\namespace\interface' |
||
390 | * 'some\namespace\interface' => 'some\namespace\classname' |
||
391 | * ) |
||
392 | * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
||
393 | * to load an instance of 'some\namespace\classname' |
||
394 | * |
||
395 | * @param string $class_name |
||
396 | * @param string $for_class |
||
397 | * @return string |
||
398 | */ |
||
399 | public function get_alias($class_name = '', $for_class = '') |
||
400 | { |
||
401 | if (! $this->has_alias($class_name, $for_class)) { |
||
402 | return $class_name; |
||
403 | } |
||
404 | if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) { |
||
405 | return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class); |
||
406 | } |
||
407 | return $this->get_alias($this->_aliases[$class_name]); |
||
408 | } |
||
409 | |||
410 | |||
411 | |||
412 | /** |
||
413 | * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
||
414 | * if one exists, or whether a new object should be generated every time the requested class is loaded. |
||
415 | * This is done by using the following class constants: |
||
416 | * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
||
417 | * EE_Dependency_Map::load_new_object - generates a new object every time |
||
418 | */ |
||
419 | protected function _register_core_dependencies() |
||
420 | { |
||
421 | $this->_dependency_map = array( |
||
422 | 'EE_Request_Handler' => array( |
||
423 | 'EE_Request' => EE_Dependency_Map::load_from_cache, |
||
424 | ), |
||
425 | 'EE_System' => array( |
||
426 | 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
||
427 | ), |
||
428 | 'EE_Session' => array( |
||
429 | 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
||
430 | 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
||
431 | ), |
||
432 | 'EE_Cart' => array( |
||
433 | 'EE_Session' => EE_Dependency_Map::load_from_cache, |
||
434 | ), |
||
435 | 'EE_Front_Controller' => array( |
||
436 | 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
||
437 | 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
||
438 | 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
||
439 | ), |
||
440 | 'EE_Messenger_Collection_Loader' => array( |
||
441 | 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
||
442 | ), |
||
443 | 'EE_Message_Type_Collection_Loader' => array( |
||
444 | 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
||
445 | ), |
||
446 | 'EE_Message_Resource_Manager' => array( |
||
447 | 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
||
448 | 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
||
449 | 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
||
450 | ), |
||
451 | 'EE_Message_Factory' => array( |
||
452 | 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
||
453 | ), |
||
454 | 'EE_messages' => array( |
||
455 | 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
||
456 | ), |
||
457 | 'EE_Messages_Generator' => array( |
||
458 | 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
||
459 | 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
||
460 | 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
||
461 | 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
||
462 | ), |
||
463 | 'EE_Messages_Processor' => array( |
||
464 | 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
||
465 | ), |
||
466 | 'EE_Messages_Queue' => array( |
||
467 | 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
||
468 | ), |
||
469 | 'EE_Messages_Template_Defaults' => array( |
||
470 | 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
||
471 | 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
||
472 | ), |
||
473 | 'EE_Message_To_Generate_From_Request' => array( |
||
474 | 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
||
475 | 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
||
476 | ), |
||
477 | 'EventEspresso\core\services\commands\CommandBus' => array( |
||
478 | 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
||
479 | ), |
||
480 | 'EventEspresso\services\commands\CommandHandler' => array( |
||
481 | 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
||
482 | 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
||
483 | ), |
||
484 | 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
||
485 | 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
||
486 | ), |
||
487 | 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
||
488 | 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
||
489 | 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
||
490 | ), |
||
491 | 'EventEspresso\core\services\commands\CommandFactory' => array( |
||
492 | 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
||
493 | ), |
||
494 | 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
||
495 | 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
||
496 | ), |
||
497 | 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
||
498 | 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
||
499 | ), |
||
500 | 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
||
501 | 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
||
502 | ), |
||
503 | 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
||
504 | 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
||
505 | ), |
||
506 | 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
||
507 | 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
||
508 | ), |
||
509 | 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
||
510 | 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
||
511 | ), |
||
512 | 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
||
513 | 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
||
514 | ), |
||
515 | 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
||
516 | 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
||
517 | ), |
||
518 | 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
||
519 | 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
||
520 | ), |
||
521 | 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
||
522 | 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
||
523 | ), |
||
524 | 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
||
525 | 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
||
526 | ), |
||
527 | 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
||
528 | 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
||
529 | ), |
||
530 | 'EventEspresso\core\services\database\TableManager' => array( |
||
531 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
532 | ), |
||
533 | 'EE_Data_Migration_Class_Base' => array( |
||
534 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
535 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
536 | ), |
||
537 | 'EE_DMS_Core_4_1_0' => array( |
||
538 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
539 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
540 | ), |
||
541 | 'EE_DMS_Core_4_2_0' => array( |
||
542 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
543 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
544 | ), |
||
545 | 'EE_DMS_Core_4_3_0' => array( |
||
546 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
547 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
548 | ), |
||
549 | 'EE_DMS_Core_4_4_0' => array( |
||
550 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
551 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
552 | ), |
||
553 | 'EE_DMS_Core_4_5_0' => array( |
||
554 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
555 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
556 | ), |
||
557 | 'EE_DMS_Core_4_6_0' => array( |
||
558 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
559 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
560 | ), |
||
561 | 'EE_DMS_Core_4_7_0' => array( |
||
562 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
563 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
564 | ), |
||
565 | 'EE_DMS_Core_4_8_0' => array( |
||
566 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
567 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
568 | ), |
||
569 | 'EE_DMS_Core_4_9_0' => array( |
||
570 | 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
||
571 | 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
||
572 | ), |
||
573 | 'EventEspresso\core\services\assets\Registry' => array( |
||
574 | 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
||
575 | 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
||
576 | ), |
||
577 | 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
||
578 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
579 | ), |
||
580 | 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
||
581 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
582 | ), |
||
583 | 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
||
584 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
585 | ), |
||
586 | 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
||
587 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
588 | ), |
||
589 | 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
||
590 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
591 | ), |
||
592 | 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
||
593 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
594 | ), |
||
595 | 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
||
596 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
||
597 | ), |
||
598 | 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
||
599 | 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
||
600 | ), |
||
601 | 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
||
602 | 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
||
603 | ), |
||
604 | ); |
||
605 | } |
||
606 | |||
607 | |||
608 | |||
609 | /** |
||
610 | * Registers how core classes are loaded. |
||
611 | * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
||
612 | * 'EE_Request_Handler' => 'load_core' |
||
613 | * 'EE_Messages_Queue' => 'load_lib' |
||
614 | * 'EEH_Debug_Tools' => 'load_helper' |
||
615 | * or, if greater control is required, by providing a custom closure. For example: |
||
616 | * 'Some_Class' => function () { |
||
617 | * return new Some_Class(); |
||
618 | * }, |
||
619 | * This is required for instantiating dependencies |
||
620 | * where an interface has been type hinted in a class constructor. For example: |
||
621 | * 'Required_Interface' => function () { |
||
622 | * return new A_Class_That_Implements_Required_Interface(); |
||
623 | * }, |
||
624 | */ |
||
625 | protected function _register_core_class_loaders() |
||
696 | |||
697 | |||
698 | |||
699 | /** |
||
700 | * can be used for supplying alternate names for classes, |
||
701 | * or for connecting interface names to instantiable classes |
||
702 | */ |
||
703 | protected function _register_core_aliases() |
||
704 | { |
||
743 | |||
744 | |||
745 | |||
746 | /** |
||
747 | * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
||
748 | * request Primarily used by unit tests. |
||
749 | */ |
||
750 | public function reset() |
||
755 | |||
756 | |||
757 | } |
||
758 | // End of file EE_Dependency_Map.core.php |
||
760 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):