PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 1.2.5
Booking for Appointments and Events Calendar – Amelia v1.2.5
2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / src / Infrastructure / ContainerConfig / container.php
ameliabooking / src / Infrastructure / ContainerConfig Last commit date
application.services.php 1 year ago command.bus.php 1 year ago container.php 1 year ago domain.event.bus.php 1 year ago domain.services.php 1 year ago infrastructure.services.php 1 year ago infrastructure.user.php 1 year ago repositories.php 1 year ago request.php 1 year ago
container.php
146 lines
1 <?php
2
3 use AmeliaBooking\Domain\Services\Settings\SettingsService;
4 use AmeliaBooking\Infrastructure\Common\Container;
5 use AmeliaBooking\Infrastructure\WP\SettingsService\SettingsStorage;
6
7 // Handle the 404 API calls
8 $entries['notFoundHandler'] = function () {
9 return function ($request, \Slim\Http\Response $response) {
10 return $response->withStatus(404);
11 };
12 };
13
14 // Handle the Method Not Allowed API calls
15 $entries['notAllowedHandler'] = function () {
16 return function ($request, \Slim\Http\Response $response) {
17 return $response->withStatus(405);
18 };
19 };
20
21 // Handle the errors
22 $entries['errorHandler'] = function (Container $c) {
23 return function ($request, \Slim\Http\Response $response, $exception) use ($c) {
24 /** @var Exception $exception */
25
26 switch (get_class($exception)) {
27 case \AmeliaBooking\Application\Common\Exceptions\AccessDeniedException::class:
28 $status = \AmeliaBooking\Application\Controller\Controller::STATUS_FORBIDDEN;
29 break;
30 default:
31 $status = \AmeliaBooking\Application\Controller\Controller::STATUS_INTERNAL_SERVER_ERROR;
32 }
33
34 $responseMessage = ['message' => $exception->getMessage()];
35
36 if (method_exists($request, 'getParam') && $request->getParam('showAmeliaSqlExceptions')) {
37 $responseMessage['exception'] = $exception->getPrevious() ? $exception->getPrevious()->getMessage() : '';
38 }
39
40 return $response->withStatus($status)
41 ->withHeader('Content-Type', 'text/html')
42 ->write(json_encode($responseMessage));
43 };
44 };
45
46
47 // Disabled for now for easier debug
48 //// Handle PHP errors
49 //$entries['phpErrorHandler'] = function (Container $c) {
50 // return function ($request, \Slim\Http\Response $response, $exception) use ($c) {
51 // /** @var Exception $exception */
52 //
53 // return $response->withStatus(500)
54 // ->withHeader('Content-Type', 'text/html')
55 // ->write($exception->getMessage());
56 // };
57 //};
58
59 ##########################################################################
60 ##########################################################################
61 # App common
62 ##########################################################################
63 ##########################################################################
64
65 //
66 $entries['app.connection'] = function () {
67 $config = new \AmeliaBooking\Infrastructure\WP\config\Database();
68
69 $settingsService = new SettingsService(new SettingsStorage());
70
71 $mysqliEnabled = $settingsService->getSetting('db', 'mysqliEnabled');
72
73 $dbSettingsPort = $settingsService->getSetting('db', 'port');
74
75 $port = !empty($dbSettingsPort) ? $dbSettingsPort : 3306;
76
77 if (!extension_loaded('pdo_mysql') || $mysqliEnabled) {
78 return new \AmeliaBooking\Infrastructure\DB\MySQLi\Connection(
79 $config('host'),
80 $config('database'),
81 $config('username'),
82 $config('password'),
83 $config('charset'),
84 $port
85 );
86 }
87
88 return new \AmeliaBooking\Infrastructure\DB\PDO\Connection(
89 $config('host'),
90 $config('database'),
91 $config('username'),
92 $config('password'),
93 $config('charset'),
94 $port
95 );
96 };
97
98 ################
99 # Repositories #
100 ################
101 require 'repositories.php';
102
103 ############################
104 # Currently logged in user #
105 ############################
106 require 'infrastructure.user.php';
107
108 ###################
109 # Domain Services #
110 ###################
111 require 'domain.services.php';
112
113 ########################
114 # Application Services #
115 ########################
116 require 'application.services.php';
117
118 ########################
119 # Infrastructure Services #
120 ########################
121 require 'infrastructure.services.php';
122
123 ###############
124 # Command bus #
125 ###############
126 require 'command.bus.php';
127
128 ####################
129 # Domain event bus #
130 ####################
131 require 'domain.event.bus.php';
132
133 $entries['settings'] = [
134 // Slim Settings
135 'determineRouteBeforeAppMiddleware' => true,
136 'displayErrorDetails' => true,
137 'addContentLengthHeader' => false, //added due to error on dev server (check the cause)
138 ];
139
140 ######################
141 # Request overriding #
142 ######################
143 require 'request.php';
144
145 return new Container($entries);
146