PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / bootstrap / CoreServiceRegistration.php

CoreServiceRegistration.php in 404 Solution trunk, at includes/bootstrap/CoreServiceRegistration.php

95 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Registers low-level infrastructure services used by all later bootstrap layers.
9 */
10 class ABJ_404_Solution_CoreServiceRegistration {
11
12 /**
13 * @param ABJ_404_Solution_ServiceContainer $container
14 * @return void
15 */
16 public static function register($container): void {
17 $container->set('mb_string_adapter', function($c) {
18 if (extension_loaded('mbstring')) {
19 return ABJ_404_Solution_MbStringAdapterMb::getInstance();
20 }
21 return ABJ_404_Solution_MbStringAdapterPreg::getInstance();
22 });
23
24 $container->set('regex_helper', function($c) {
25 if (extension_loaded('mbstring')) {
26 return ABJ_404_Solution_RegexHelperMb::getInstance();
27 }
28 return ABJ_404_Solution_RegexHelperPreg::getInstance();
29 });
30
31 $container->set('functions', function($c) {
32 return new ABJ_404_Solution_Functions(
33 $c->get('logging'),
34 $c->get('request_context'),
35 $c->get('mb_string_adapter'),
36 $c->get('regex_helper')
37 );
38 });
39
40 $container->set('request_input_normalizer', function($c) {
41 return new ABJ_404_Solution_RequestInputNormalizer();
42 });
43
44 $container->set('pii_redactor', function($c) {
45 return new ABJ_404_Solution_PiiRedactor($c->get('functions'));
46 });
47
48 $container->set('url_encoder', function($c) {
49 return new ABJ_404_Solution_UrlEncoder($c->get('mb_string_adapter'), $c->get('regex_helper'));
50 });
51
52 $container->set('sanitizer', function($c) {
53 return new ABJ_404_Solution_Sanitizer($c->get('mb_string_adapter'));
54 });
55
56 $container->set('query_string_helper', function($c) {
57 return new ABJ_404_Solution_QueryStringHelper($c->get('sanitizer'), $c->get('logging'));
58 });
59
60 $container->set('logging', function($c) {
61 return ABJ_404_Solution_Logging::createForContainer();
62 });
63
64 $container->set('clock', function($c) {
65 return new ABJ_404_Solution_SystemClock();
66 });
67
68 $container->set('cron_scheduler', function($c) {
69 return new ABJ_404_Solution_CronScheduler(
70 $c->get('clock'),
71 $c->get('logging')
72 );
73 });
74
75 $container->set('cron_recurrence_migration', function($c) {
76 return new ABJ_404_Solution_CronRecurrenceMigration(
77 $c->get('cron_scheduler'),
78 new ABJ_404_Solution_ScheduledEventInspector(),
79 $c->get('logging')
80 );
81 });
82
83 $container->set('rebuild_health', function($c) {
84 return new ABJ_404_Solution_RebuildHealthState(
85 $c->get('clock'),
86 $c->get('logging')
87 );
88 });
89
90 $container->set('error_handler', function($c) {
91 return 'ABJ_404_Solution_ErrorHandler';
92 });
93 }
94 }
95