1 | <?php |
||
15 | class HttpServiceProvider implements ServiceProviderInterface |
||
16 | { |
||
17 | /** |
||
18 | * {@inheritdoc} |
||
19 | */ |
||
20 | 1 | public function register(ContainerInterface $app) |
|
21 | { |
||
22 | $app->closure(ResponseFactory::class, function () { |
||
23 | return response(); // singleton |
||
24 | 1 | }); |
|
25 | $app->closure(Configuration::class, function (Config $config) { |
||
26 | return new Configuration([ |
||
27 | 'timeout' => $config->get('session.timeout', 3600), |
||
28 | 'name' => $config->get('session.name', ini_get('session.name') ?: 'WdSessId'), |
||
29 | 'gc_frequency' => $config->get('session.gc_frequency', 100), |
||
30 | ]); |
||
31 | 1 | }); |
|
32 | 1 | $app->closure(SessionHandlerInterface::class, function (Config $config, ContainerInterface $app) { |
|
33 | switch ($config->get('session.type')) { |
||
34 | case 'file': |
||
35 | return new FileHandler($config->get('session.path', 'cache/sessions')); |
||
36 | case 'redis': |
||
37 | return new RedisHandler($app[Client::class], $config->get('session.timeout', 3600)); |
||
38 | default: |
||
39 | return new GlobalHandler(); |
||
40 | } |
||
41 | 1 | }); |
|
42 | 1 | } |
|
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | 1 | public function boot(ContainerInterface $app) |
|
50 | } |
||
51 |