Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 135
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 118
dl 0
loc 135
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 125 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Norsys\SeoBundle\DependencyInjection;
5
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * Class Configuration
11
 */
12
class Configuration implements ConfigurationInterface
13
{
14
    /**
15
     * @var string
16
    **/
17
    const BUNDLE_TREEBUILDER_ROOT = 'norsys_seo';
18
19
    /**
20
     * @return TreeBuilder
21
     */
22
    public function getConfigTreeBuilder() : TreeBuilder
23
    {
24
        $treeBuilder = new TreeBuilder();
25
        $rootNode    = $treeBuilder->root(self::BUNDLE_TREEBUILDER_ROOT);
26
        $rootNode
27
            ->children()
28
                ->arrayNode('rewrite')
29
                    ->info('Optional rewrite configuration')
30
                    ->addDefaultsIfNotSet()
31
                    ->children()
32
                        ->booleanNode('remove_trailing_slash')
33
                            ->info('Enable remove trailing slash in urls')
34
                            ->defaultValue(false)
35
                        ->end()
36
                    ->end()
37
                ->end()
38
                ->arrayNode('translation')
39
                    ->info('Optional translation configuration')
40
                    ->addDefaultsIfNotSet()
41
                    ->children()
42
                        ->booleanNode('enabled')
43
                            ->info('Wether translation should be enabled or not for SEO meta tags')
44
                            ->defaultValue(false)
45
                        ->end()
46
                        ->scalarNode('domain')
47
                            ->info('Domain for translatable meta contents (if "null", use the app default domain)')
48
                            ->defaultValue(null)
49
                        ->end()
50
                    ->end()
51
                ->end()
52
                ->arrayNode('title')
53
                    ->info('Home for the title tag configuration')
54
                    ->children()
55
                        ->scalarNode('default')
56
                            ->info('Fallback value for title when no title defined for the requested route')
57
                            ->isRequired()
58
                        ->end()
59
                        ->arrayNode('pages')
60
                            ->info('Config for titles on a per-route basis')
61
                            ->prototype('scalar')
62
                            ->end()
63
                        ->end()
64
                    ->end()
65
                ->end()
66
                ->arrayNode('metas')
67
                    ->info('Home for the meta tags configuration')
68
                    ->children()
69
                        ->arrayNode('defaults')
70
                            ->info('Fallback values for meta tags when no config found for the requested route')
71
                            ->isRequired()
72
                            ->requiresAtLeastOneElement()
73
                            ->prototype('array')
74
                                ->children()
75
                                    // Here an exhaustive list of all possible attributes for a <meta> tag
76
                                    // Problem, name/charset/http-equiv/itemprop should be an EXCLUSIVE choice
77
                                    ->scalarNode('name')
78
                                    ->end()
79
                                    ->scalarNode('charset')
80
                                    ->end()
81
                                    ->scalarNode('http-equiv')
82
                                    ->end()
83
                                    ->scalarNode('itemprop')
84
                                    ->end()
85
                                    ->scalarNode('content')
86
                                    ->end()
87
                                    ->scalarNode('property')
88
                                    ->end()
89
                                ->end()
90
                            ->end()
91
                        ->end()
92
                        ->arrayNode('pages')
93
                            ->info('Config for meta informations on a per-route basis')
94
                            ->prototype('array')
95
                                ->prototype('array')
96
                                    ->children()
97
                                        ->scalarNode('name')
98
                                        ->end()
99
                                        ->scalarNode('charset')
100
                                        ->end()
101
                                        ->scalarNode('http-equiv')
102
                                        ->end()
103
                                        ->scalarNode('itemprop')
104
                                        ->end()
105
                                        ->scalarNode('content')
106
                                        ->end()
107
                                        ->scalarNode('property')
108
                                        ->end()
109
                                    ->end()
110
                                ->end()
111
                            ->end()
112
                        ->end()
113
                    ->end()
114
115
                ->end()
116
                
117
                ->arrayNode('links')
118
                    ->info('Home for the link tags configuration')
119
                    ->children()
120
                        ->arrayNode('pages')
121
                            ->prototype('array')
122
                                ->prototype('array')
123
                                    ->children()
124
                                        // Here an exhaustive list of all possible attributes for a <link> tag
125
                                        ->scalarNode('rel')
126
                                        ->end()
127
                                        ->scalarNode('href')
128
                                        ->end()
129
                                        ->scalarNode('hreflang')
130
                                        ->end()
131
                                        ->scalarNode('media')
132
                                        ->end()
133
                                        ->scalarNode('title')
134
                                        ->end()
135
                                        ->scalarNode('type')
136
                                        ->end()
137
                                    ->end()
138
                                ->end()
139
                            ->end()
140
                        ->end()
141
                    ->end()
142
                ->end()
143
               
144
            ->end();
145
146
        return $treeBuilder;
147
    }
148
}
149