PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4
Booking for Appointments and Events Calendar – Amelia v2.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 month ago command.bus.php 2 years ago container.php 6 months ago domain.event.bus.php 1 year ago domain.services.php 1 year ago infrastructure.services.php 4 months ago infrastructure.user.php 1 year ago repositories.php 6 months ago request.php 6 months ago
container.php
119 lines
1 <?php
2
3 use AmeliaBooking\Domain\Services\Settings\SettingsService;
4 use AmeliaBooking\Infrastructure\Common\Container;
5 use AmeliaBooking\Infrastructure\Connection;
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) {
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 $entries['app.connection'] = function () {
65 global $wpdb;
66
67 return new Connection($wpdb);
68 };
69
70
71 ################
72 # Repositories #
73 ################
74 require 'repositories.php';
75
76 ############################
77 # Currently logged in user #
78 ############################
79 require 'infrastructure.user.php';
80
81 ###################
82 # Domain Services #
83 ###################
84 require 'domain.services.php';
85
86 ########################
87 # Application Services #
88 ########################
89 require 'application.services.php';
90
91 ########################
92 # Infrastructure Services #
93 ########################
94 require 'infrastructure.services.php';
95
96 ###############
97 # Command bus #
98 ###############
99 require 'command.bus.php';
100
101 ####################
102 # Domain event bus #
103 ####################
104 require 'domain.event.bus.php';
105
106 $entries['settings'] = [
107 // Slim Settings
108 'determineRouteBeforeAppMiddleware' => true,
109 'displayErrorDetails' => true,
110 'addContentLengthHeader' => false, //added due to error on dev server (check the cause)
111 ];
112
113 ######################
114 # Request overriding #
115 ######################
116 require 'request.php';
117
118 return new Container($entries);
119