forked from suncat2000/MobileDetectBundle
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathConfiguration.php
101 lines (94 loc) · 4.4 KB
/
Configuration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/*
* This file is part of the MobileDetectBundle.
*
* (c) Nikolay Ivlev <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace MobileDetectBundle\DependencyInjection;
use MobileDetectBundle\DeviceDetector\MobileDetector;
use MobileDetectBundle\EventListener\RequestResponseListener;
use MobileDetectBundle\Helper\DeviceView;
use MobileDetectBundle\Twig\Extension\MobileDetectExtension;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\HttpFoundation\Response;
/**
* @author suncat2000 <[email protected]>
* @author HenriVesala <[email protected]>
*/
class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder('mobile_detect');
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->arrayNode('redirect')
->addDefaultsIfNotSet()
->children()
->arrayNode('mobile')
->addDefaultsIfNotSet()
->children()
->booleanNode('is_enabled')->defaultFalse()->end()
->scalarNode('host')->defaultNull()->end()
->scalarNode('status_code')->defaultValue(Response::HTTP_FOUND)->cannotBeEmpty()->end()
->scalarNode('action')->defaultValue(RequestResponseListener::REDIRECT)->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('tablet')
->addDefaultsIfNotSet()
->children()
->booleanNode('is_enabled')->defaultFalse()->end()
->scalarNode('host')->defaultNull()->end()
->scalarNode('status_code')->defaultValue(Response::HTTP_FOUND)->cannotBeEmpty()->end()
->scalarNode('action')->defaultValue(RequestResponseListener::REDIRECT)->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('full')
->addDefaultsIfNotSet()
->children()
->booleanNode('is_enabled')->defaultFalse()->end()
->scalarNode('host')->defaultNull()->end()
->scalarNode('status_code')->defaultValue(Response::HTTP_FOUND)->cannotBeEmpty()->end()
->scalarNode('action')->defaultValue(RequestResponseListener::REDIRECT)->cannotBeEmpty()->end()
->end()
->end()
->booleanNode('detect_tablet_as_mobile')->defaultFalse()->end()
->end()
->end()
->arrayNode('switch_device_view')
->addDefaultsIfNotSet()
->children()
->booleanNode('save_referer_path')->defaultTrue()->end()
->end()
->end()
->arrayNode('service')
->addDefaultsIfNotSet()
->children()
->scalarNode('mobile_detector')->defaultValue('mobile_detect.mobile_detector.default')->cannotBeEmpty()->end()
->end()
->end()
->scalarNode('cookie_key')->defaultValue(DeviceView::COOKIE_KEY_DEFAULT)->cannotBeEmpty()->end()
->scalarNode('cookie_path')->defaultValue(DeviceView::COOKIE_PATH_DEFAULT)->cannotBeEmpty()->end()
->scalarNode('cookie_domain')->defaultValue(DeviceView::COOKIE_DOMAIN_DEFAULT)->cannotBeEmpty()->end()
->booleanNode('cookie_secure')->defaultValue(DeviceView::COOKIE_SECURE_DEFAULT)->end()
->booleanNode('cookie_httponly')->defaultValue(DeviceView::COOKIE_HTTP_ONLY_DEFAULT)->end()
->scalarNode('cookie_expire_datetime_modifier')->defaultValue(DeviceView::COOKIE_EXPIRE_DATETIME_MODIFIER_DEFAULT)->cannotBeEmpty()->end()
->scalarNode('switch_param')->defaultValue(DeviceView::SWITCH_PARAM_DEFAULT)->cannotBeEmpty()->end()
->scalarNode('mobile_detector_class')->defaultValue(MobileDetector::class)->cannotBeEmpty()->end()
->scalarNode('device_view_class')->defaultValue(DeviceView::class)->cannotBeEmpty()->end()
->scalarNode('request_response_listener_class')->defaultValue(RequestResponseListener::class)->cannotBeEmpty()->end()
->scalarNode('twig_extension_class')->defaultValue(MobileDetectExtension::class)->cannotBeEmpty()->end()
->end()
;
return $treeBuilder;
}
}