1
|
|
|
<?php namespace Limoncello\Application\Packages\Session; |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2015-2017 [email protected] |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
use Limoncello\Application\Contracts\Session\SessionFunctionsInterface; |
20
|
|
|
use Limoncello\Application\Session\Session; |
21
|
|
|
use Limoncello\Application\Session\SessionFunctions; |
22
|
|
|
use Limoncello\Contracts\Application\ContainerConfiguratorInterface; |
23
|
|
|
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface; |
24
|
|
|
use Limoncello\Contracts\Session\SessionInterface; |
25
|
|
|
use Psr\Container\ContainerInterface as PsrContainerInterface; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @package Limoncello\Application |
29
|
|
|
*/ |
30
|
|
|
class SessionContainerConfigurator implements ContainerConfiguratorInterface |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @inheritdoc |
34
|
|
|
*/ |
35
|
|
|
public static function configureContainer(LimoncelloContainerInterface $container): void |
36
|
|
|
{ |
37
|
|
|
$container[SessionInterface::class] = function (PsrContainerInterface $container): SessionInterface { |
38
|
|
|
/** @var SessionFunctionsInterface $functions */ |
39
|
|
|
$functions = $container->get(SessionFunctionsInterface::class); |
40
|
|
|
$session = new Session($functions); |
41
|
|
|
|
42
|
|
|
return $session; |
43
|
|
|
}; |
44
|
|
|
|
45
|
|
|
$container[SessionFunctionsInterface::class] = function (): SessionFunctionsInterface { |
46
|
|
|
$functions = new SessionFunctions(); |
47
|
|
|
|
48
|
|
|
return $functions; |
49
|
|
|
}; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|