1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the EoHoneypotBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Eymen Gunay <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Eo\HoneypotBundle\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
15
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* This is the class that validates and merges configuration from your app/config files |
19
|
|
|
* |
20
|
|
|
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
21
|
|
|
*/ |
22
|
|
|
class Configuration implements ConfigurationInterface |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritDoc} |
26
|
|
|
*/ |
27
|
|
|
public function getConfigTreeBuilder() |
28
|
|
|
{ |
29
|
|
|
if (\method_exists(TreeBuilder::class, 'getRootNode')) { |
30
|
|
|
// Symfony 4.1+ |
31
|
|
|
$treeBuilder = new TreeBuilder('eo_honeypot'); |
32
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
33
|
|
|
} else { |
34
|
|
|
// Symfony <= 4.0 |
35
|
|
|
$treeBuilder = new TreeBuilder(); |
36
|
|
|
$rootNode = $treeBuilder->root('eo_honeypot'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
$rootNode |
40
|
|
|
->children() |
41
|
|
|
->arrayNode('redirect') |
42
|
|
|
->canBeEnabled() |
43
|
|
|
->addDefaultsIfNotSet() |
44
|
|
|
->children() |
45
|
|
|
->scalarNode('url')->defaultNull()->end() |
46
|
|
|
->scalarNode('route')->defaultNull()->end() |
47
|
|
|
->arrayNode('route_parameters') |
48
|
|
|
->useAttributeAsKey('name') |
49
|
|
|
->prototype('scalar')->end() |
50
|
|
|
->end() |
51
|
|
|
->end() |
52
|
|
|
->end() |
53
|
|
|
->arrayNode('storage') |
54
|
|
|
->addDefaultsIfNotSet() |
55
|
|
|
->children() |
56
|
|
|
->arrayNode('database') |
57
|
|
|
->canBeEnabled() |
58
|
|
|
->children() |
59
|
|
|
->scalarNode('class')->defaultValue('ApplicationEoHoneypotBundle:HoneypotPrey')->end() |
60
|
|
|
->scalarNode('driver') |
61
|
|
|
->defaultValue('mongodb') |
62
|
|
|
->validate() |
63
|
|
|
->ifNotInArray(array('orm', 'mongodb')) |
64
|
|
|
->thenInvalid('Invalid database driver "%s"') |
65
|
|
|
->end() |
66
|
|
|
->end() |
67
|
|
|
->end() |
68
|
|
|
->end() |
69
|
|
|
->arrayNode('file') |
70
|
|
|
->canBeEnabled() |
71
|
|
|
->children() |
72
|
|
|
->scalarNode('output')->defaultValue('/var/log/honeypot.log')->end() |
73
|
|
|
->end() |
74
|
|
|
->end() |
75
|
|
|
->end() |
76
|
|
|
->end() |
77
|
|
|
->end() |
78
|
|
|
; |
79
|
|
|
|
80
|
|
|
return $treeBuilder; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|