Conditions | 3 |
Paths | 1 |
Total Lines | 32 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public function getConfigTreeBuilder() |
||
20 | { |
||
21 | $treeBuilder = new TreeBuilder('webnet_fr_database_anonymizer'); |
||
22 | |||
23 | $connectionsRootNode = (new TreeBuilder('connections'))->getRootNode(); |
||
24 | $node = $connectionsRootNode |
||
25 | ->requiresAtLeastOneElement() |
||
|
|||
26 | ->useAttributeAsKey('name') |
||
27 | ->prototype('array'); |
||
28 | |||
29 | $this->configureAnonymizer($node); |
||
30 | |||
31 | $treeBuilder->getRootNode() |
||
32 | ->beforeNormalization() |
||
33 | ->ifTrue(static function ($v) { |
||
34 | return is_array($v) && !array_key_exists('connections', $v); |
||
35 | }) |
||
36 | ->then(static function ($v) { |
||
37 | $connection = []; |
||
38 | foreach ($v as $key => $value) { |
||
39 | $connection[$key] = $v[$key]; |
||
40 | unset($v[$key]); |
||
41 | } |
||
42 | |||
43 | $v['connections'] = ['default' => $connection]; |
||
44 | |||
45 | return $v; |
||
46 | }) |
||
47 | ->end() |
||
48 | ->append($connectionsRootNode); |
||
49 | |||
50 | return $treeBuilder; |
||
51 | } |
||
53 |