ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
DefaultServicesProvider.php
Go to the documentation of this file.
1<?php
9namespace Slim;
10
26
31{
37 public function register($container)
38 {
39 if (!isset($container['environment'])) {
46 $container['environment'] = function () {
47 return new Environment($_SERVER);
48 };
49 }
50
51 if (!isset($container['request'])) {
59 $container['request'] = function ($container) {
60 return Request::createFromEnvironment($container->get('environment'));
61 };
62 }
63
64 if (!isset($container['response'])) {
72 $container['response'] = function ($container) {
73 $headers = new Headers(['Content-Type' => 'text/html; charset=UTF-8']);
74 $response = new Response(200, $headers);
75
76 return $response->withProtocolVersion($container->get('settings')['httpVersion']);
77 };
78 }
79
80 if (!isset($container['router'])) {
89 $container['router'] = function ($container) {
90 $routerCacheFile = false;
91 if (isset($container->get('settings')['routerCacheFile'])) {
92 $routerCacheFile = $container->get('settings')['routerCacheFile'];
93 }
94
95
96 $router = (new Router)->setCacheFile($routerCacheFile);
97 if (method_exists($router, 'setContainer')) {
98 $router->setContainer($container);
99 }
100
101 return $router;
102 };
103 }
104
105 if (!isset($container['foundHandler'])) {
112 $container['foundHandler'] = function () {
113 return new RequestResponse;
114 };
115 }
116
117 if (!isset($container['phpErrorHandler'])) {
133 $container['phpErrorHandler'] = function ($container) {
134 return new PhpError($container->get('settings')['displayErrorDetails']);
135 };
136 }
137
138 if (!isset($container['errorHandler'])) {
154 $container['errorHandler'] = function ($container) {
155 return new Error(
156 $container->get('settings')['displayErrorDetails']
157 );
158 };
159 }
160
161 if (!isset($container['notFoundHandler'])) {
174 $container['notFoundHandler'] = function () {
175 return new NotFound;
176 };
177 }
178
179 if (!isset($container['notAllowedHandler'])) {
193 $container['notAllowedHandler'] = function () {
194 return new NotAllowed;
195 };
196 }
197
198 if (!isset($container['callableResolver'])) {
206 $container['callableResolver'] = function ($container) {
207 return new CallableResolver($container);
208 };
209 }
210 }
211}
An exception for terminatinating execution or to throw for unit testing.
This class resolves a string of the format 'class:method' into a closure that can be dispatched.
Slim's default Service Provider.
Default Slim application error handler.
Definition: Error.php:23
Default Slim application not allowed handler.
Definition: NotAllowed.php:23
Default Slim application not found handler.
Definition: NotFound.php:23
Default Slim application error handler for PHP 7+ Throwables.
Definition: PhpError.php:23
Default route callback strategy with route parameters as an array of arguments.
Router.
Definition: Router.php:32
Representation of an outgoing, server-side response.
Representation of an incoming, server-side HTTP request.
Defines a contract for invoking a route callable.
Slim Framework (https://slimframework.com)
Definition: App.php:9
$response
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$container
Definition: wac.php:13