1
|
|
|
<?php namespace Limoncello\Application\Packages\Cookies; |
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\Cookies\CookieJar; |
20
|
|
|
use Limoncello\Contracts\Application\ContainerConfiguratorInterface; |
21
|
|
|
use Limoncello\Contracts\Container\ContainerInterface as LimoncelloContainerInterface; |
22
|
|
|
use Limoncello\Contracts\Cookies\CookieJarInterface; |
23
|
|
|
use Limoncello\Contracts\Settings\SettingsProviderInterface; |
24
|
|
|
use Psr\Container\ContainerInterface as PsrContainerInterface; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @package Limoncello\Application |
28
|
|
|
*/ |
29
|
|
|
class CookieContainerConfigurator implements ContainerConfiguratorInterface |
30
|
|
|
{ |
31
|
|
|
/** |
32
|
|
|
* @inheritdoc |
33
|
|
|
* |
34
|
|
|
* @SuppressWarnings(PHPMD.StaticAccess) |
35
|
|
|
*/ |
36
|
|
|
public static function configureContainer(LimoncelloContainerInterface $container): void |
37
|
|
|
{ |
38
|
|
|
$container[CookieJarInterface::class] = |
39
|
|
|
function (PsrContainerInterface $container): CookieJarInterface { |
40
|
|
|
$settings = $container->get(SettingsProviderInterface::class)->get(CookieSettings::class); |
41
|
|
|
|
42
|
|
|
return new CookieJar( |
43
|
|
|
$settings[CookieSettings::KEY_DEFAULT_PATH], |
44
|
|
|
$settings[CookieSettings::KEY_DEFAULT_DOMAIN], |
45
|
|
|
$settings[CookieSettings::KEY_DEFAULT_IS_SEND_ONLY_OVER_SECURE_CONNECTION], |
46
|
|
|
$settings[CookieSettings::KEY_DEFAULT_IS_ACCESSIBLE_ONLY_THROUGH_HTTP], |
47
|
|
|
$settings[CookieSettings::KEY_DEFAULT_IS_RAW] |
48
|
|
|
); |
49
|
|
|
}; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|