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