Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 64
c 3
b 0
f 0
dl 0
loc 79
ccs 59
cts 59
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 74 1
1
<?php
2
/**
3
 * @author Gerard van Helden <[email protected]>
4
 * @copyright Zicht Online <http://zicht.nl>
5
 */
6
7
namespace Zicht\Bundle\UrlBundle\DependencyInjection;
8
9
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
10
use Symfony\Component\Config\Definition\ConfigurationInterface;
11
12
/**
13
 * Configuration schema for the url bundle
14
 */
15
class Configuration implements ConfigurationInterface
16
{
17
    /**
18
     * {@inheritDoc}
19
     */
20 9
    public function getConfigTreeBuilder()
21
    {
22 9
        $treeBuilder = new TreeBuilder();
23 9
        $rootNode = $treeBuilder->root('zicht_url');
24
25
        $isBool = function ($v) {
26 3
            return is_bool($v);
27 9
        };
28 9
        $convertToEnabledKey = function ($v) {
29 2
            return array('enabled' => $v);
30 9
        };
31
32
        $rootNode
33 9
            ->children()
34 9
                ->booleanNode('strict_public_url')->defaultValue(true)->end()
35 9
                ->arrayNode('static_ref')
36 9
                    ->useAttributeAsKey('name')
37 9
                    ->prototype('scalar')->end()
38 9
                ->end()
39 9
                ->arrayNode('aliasing')
40 9
                    ->beforeNormalization()
41 9
                        ->ifTrue($isBool)
42 9
                        ->then($convertToEnabledKey)
43 9
                    ->end()
44 9
                    ->addDefaultsIfNotSet()
45 9
                    ->children()
46 9
                        ->booleanNode('enabled')->defaultValue(false)->end()
47 9
                        ->booleanNode('enable_params')->defaultValue(false)->end()
48 9
                        ->arrayNode('exclude_patterns')->prototype('scalar')->end()->end()
49 9
                        ->arrayNode('automatic_entities')->prototype('scalar')->end()->end()
50 9
                    ->end()
51 9
                ->end()
52 9
                ->variableNode('logging')->end()
53 9
                ->booleanNode('admin')->defaultValue(false)->end()
54 9
                ->arrayNode('db_static_ref')
55 9
                    ->beforeNormalization()
56 9
                        ->ifTrue($isBool)
57 9
                        ->then($convertToEnabledKey)
58 9
                    ->end()
59 9
                    ->addDefaultsIfNotSet()
60 9
                    ->children()
61 9
                        ->booleanNode('enabled')->defaultValue(false)->end()
62 9
                        ->scalarNode('fallback_locale')->defaultValue(null)->end()
63 9
                    ->end()
64 9
                ->end()
65 9
                ->arrayNode('caching')
66 9
                    ->beforeNormalization()
67 9
                        ->ifTrue($isBool)
68 9
                        ->then($convertToEnabledKey)
69 9
                    ->end()
70 9
                    ->addDefaultsIfNotSet()
71 9
                    ->children()
72 9
                        ->booleanNode('enabled')->defaultValue(false)->end()
73 9
                        ->arrayNode('entities')->prototype('scalar')->end()->end()
74 9
                    ->end()
75 9
                ->end()
76 9
                ->variableNode('html_attributes')
77 9
                    ->treatNullLike(array())
78 9
                    ->defaultValue(
79
                        [
80 9
                            'a' => ['href', 'data-href'],
81
                            'area' => ['href', 'data-href'],
82
                            'iframe' => ['src'],
83
                            'form' => ['action'],
84
                            'meta' => ['content'],
85
                            'link' => ['href']
86
                        ]
87
                    )
88 9
                ->end()
89
                // usage if this setting is deprecated and no longer has any effect.
90 9
                ->variableNode('unalias_subscriber')->end()
91 9
            ->end();
92
93 9
        return $treeBuilder;
94
    }
95
}
96