ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Slim\DefaultServicesProvider Class Reference

Slim's default Service Provider. More...

+ Collaboration diagram for Slim\DefaultServicesProvider:

Public Member Functions

 register ($container)
 Register Slim's default services. More...
 

Detailed Description

Slim's default Service Provider.

Definition at line 30 of file DefaultServicesProvider.php.

Member Function Documentation

◆ register()

Slim\DefaultServicesProvider::register (   $container)

Register Slim's default services.

Parameters
Container$containerA DI container implementing ArrayAccess and container-interop.

This service MUST return a shared instance of \Slim\Interfaces\Http\EnvironmentInterface.

Returns
EnvironmentInterface

PSR-7 Request object

Parameters
Container$container
Returns
ServerRequestInterface

PSR-7 Response object

Parameters
Container$container
Returns
ResponseInterface

This service MUST return a SHARED instance of \Slim\Interfaces\RouterInterface.

Parameters
Container$container
Returns
RouterInterface

This service MUST return a SHARED instance of \Slim\Interfaces\InvocationStrategyInterface.

Returns
InvocationStrategyInterface

This service MUST return a callable that accepts three arguments:

  1. Instance of \Psr\Http\Message\ServerRequestInterface
  2. Instance of \Psr\Http\Message\ResponseInterface
  3. Instance of \Error

The callable MUST return an instance of \Psr\Http\Message\ResponseInterface.

Parameters
Container$container
Returns
callable

This service MUST return a callable that accepts three arguments:

  1. Instance of \Psr\Http\Message\ServerRequestInterface
  2. Instance of \Psr\Http\Message\ResponseInterface
  3. Instance of \Exception

The callable MUST return an instance of \Psr\Http\Message\ResponseInterface.

Parameters
Container$container
Returns
callable

This service MUST return a callable that accepts two arguments:

  1. Instance of \Psr\Http\Message\ServerRequestInterface
  2. Instance of \Psr\Http\Message\ResponseInterface

The callable MUST return an instance of \Psr\Http\Message\ResponseInterface.

Returns
callable

This service MUST return a callable that accepts three arguments:

  1. Instance of \Psr\Http\Message\ServerRequestInterface
  2. Instance of \Psr\Http\Message\ResponseInterface
  3. Array of allowed HTTP methods

The callable MUST return an instance of \Psr\Http\Message\ResponseInterface.

Returns
callable

Instance of \Slim\Interfaces\CallableResolverInterface

Parameters
Container$container
Returns
CallableResolverInterface

Definition at line 37 of file DefaultServicesProvider.php.

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 }
static createFromEnvironment(Environment $environment)
Create new HTTP request with data extracted from the application Environment object.
Definition: Request.php:138
$response
if((!isset($_SERVER['DOCUMENT_ROOT'])) OR(empty($_SERVER['DOCUMENT_ROOT']))) $_SERVER['DOCUMENT_ROOT']
$container
Definition: wac.php:13

References $_SERVER, $container, and $response.


The documentation for this class was generated from the following file: