Configuration::getConfigTreeBuilder()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 37
Code Lines 33

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 34
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 37
ccs 34
cts 34
cp 1
rs 8.8571
cc 1
eloc 33
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[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 ONGR\TranslationsBundle\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 app/config files.
19
 */
20
class Configuration implements ConfigurationInterface
21
{
22
    /**
23
     * {@inheritdoc}
24
     */
25 7
    public function getConfigTreeBuilder()
26
    {
27 7
        $treeBuilder = new TreeBuilder();
28 7
        $rootNode = $treeBuilder->root('ongr_translations');
29
30
        $rootNode
31 7
            ->addDefaultsIfNotSet()
32 7
            ->children()
33 7
                ->arrayNode('repository')
34 7
                    ->info('Repository used for connecting with elasticsearch client.')
35 7
                    ->children()
36 7
                        ->scalarNode('translation')->isRequired()
37 7
                        ->end()
38 7
                        ->scalarNode('history')->isRequired()
39 7
                        ->end()
40 7
                    ->end()
41 7
                ->end()
42 7
                ->scalarNode('list_size')
43 7
                    ->info('Maximum amount of translations displayed in the list')
44 7
                    ->defaultValue(1000)
45 7
                ->end()
46 7
                ->arrayNode('locales')
47 7
                    ->requiresAtleastOneElement()
48 7
                    ->info('Locales to manage (e.g. "en", "de", "en_eur").')
49 7
                    ->prototype('scalar')->end()
50 7
                ->end()
51 7
                ->arrayNode('bundles')
52 7
                    ->info('Bundles to scan for translations.')
53 7
                    ->prototype('scalar')
54 7
                    ->defaultValue([])
55 7
                    ->end()
56 7
                ->end()
57 7
            ->end()
58 7
        ->end();
59 7
60 7
        return $treeBuilder;
61 7
    }
62
}
63