1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yokai\SecurityTokenBundle\DependencyInjection; |
4
|
|
|
|
5
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
6
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
7
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
8
|
|
|
use Symfony\Component\HttpKernel\Kernel; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @author Yann Eugoné <[email protected]> |
12
|
|
|
*/ |
13
|
|
|
class Configuration implements ConfigurationInterface |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @inheritdoc |
17
|
|
|
*/ |
18
|
4 |
|
public function getConfigTreeBuilder() |
19
|
|
|
{ |
20
|
4 |
|
if (version_compare(Kernel::VERSION, '4.2') >= 0) { |
21
|
|
|
$builder = new TreeBuilder('yokai_security_token'); |
22
|
|
|
$root = $builder->getRootNode(); |
23
|
|
|
} else { |
24
|
4 |
|
$builder = new TreeBuilder(); |
25
|
4 |
|
$root = $builder->root('yokai_security_token'); |
26
|
|
|
} |
27
|
|
|
|
28
|
4 |
|
$root->addDefaultsIfNotSet(); |
29
|
|
|
$root |
30
|
4 |
|
->children() |
31
|
4 |
|
->append($this->getTokensNode()) |
32
|
4 |
|
->append($this->getServicesNode()) |
33
|
4 |
|
->end() |
34
|
|
|
; |
35
|
|
|
|
36
|
4 |
|
return $builder; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return NodeDefinition |
|
|
|
|
41
|
|
|
*/ |
42
|
4 |
|
private function getTokensNode() |
43
|
|
|
{ |
44
|
4 |
|
$builder = new TreeBuilder(); |
45
|
4 |
|
$node = $builder->root('tokens'); |
46
|
|
|
|
47
|
|
|
$node |
|
|
|
|
48
|
4 |
|
->useAttributeAsKey('purpose') |
49
|
4 |
|
->prototype('array') |
50
|
4 |
|
->children() |
51
|
4 |
|
->scalarNode('generator') |
52
|
4 |
|
->defaultValue('yokai_security_token.open_ssl_token_generator') |
53
|
4 |
|
->end() |
54
|
4 |
|
->scalarNode('duration') |
55
|
4 |
|
->defaultValue('+2 days') |
56
|
4 |
|
->end() |
57
|
4 |
|
->integerNode('usages') |
58
|
4 |
|
->defaultValue(1) |
59
|
4 |
|
->end() |
60
|
4 |
|
->scalarNode('keep') |
61
|
4 |
|
->defaultValue('+1 month') |
62
|
4 |
|
->end() |
63
|
4 |
|
->booleanNode('unique') |
64
|
4 |
|
->defaultValue(false) |
65
|
4 |
|
->end() |
66
|
4 |
|
->end() |
67
|
4 |
|
->end() |
68
|
|
|
; |
69
|
|
|
|
70
|
4 |
|
return $node; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return NodeDefinition |
|
|
|
|
75
|
|
|
*/ |
76
|
4 |
|
private function getServicesNode() |
77
|
|
|
{ |
78
|
4 |
|
$builder = new TreeBuilder(); |
79
|
4 |
|
$node = $builder->root('services'); |
80
|
|
|
|
81
|
4 |
|
$node->addDefaultsIfNotSet(); |
82
|
|
|
$node |
83
|
4 |
|
->children() |
84
|
4 |
|
->scalarNode('information_guesser') |
85
|
4 |
|
->defaultValue('yokai_security_token.default_information_guesser') |
86
|
4 |
|
->end() |
87
|
4 |
|
->scalarNode('token_factory') |
88
|
4 |
|
->defaultValue('yokai_security_token.default_token_factory') |
89
|
4 |
|
->end() |
90
|
4 |
|
->scalarNode('token_repository') |
91
|
4 |
|
->defaultValue('yokai_security_token.default_token_repository') |
92
|
4 |
|
->end() |
93
|
4 |
|
->scalarNode('token_manager') |
94
|
4 |
|
->defaultValue('yokai_security_token.default_token_manager') |
95
|
4 |
|
->end() |
96
|
4 |
|
->scalarNode('archivist') |
97
|
4 |
|
->defaultValue('yokai_security_token.delete_archivist') |
98
|
4 |
|
->end() |
99
|
4 |
|
->end() |
100
|
|
|
; |
101
|
|
|
|
102
|
4 |
|
return $node; |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
|
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.