Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 23
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.0856
c 0
b 0
f 0
cc 2
eloc 18
nc 2
nop 0
1
<?php
2
3
namespace Psi\Bundle\ContentType\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
8
class Configuration implements ConfigurationInterface
9
{
10
    private $storageLoaders = [];
11
12
    public function __construct(array $storageLoaders)
13
    {
14
        $this->storageLoaders = $storageLoaders;
15
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function getConfigTreeBuilder()
21
    {
22
        $treeBuilder = new TreeBuilder();
23
        $node = $treeBuilder->root('psi_content_type')
24
            ->addDefaultsIfNotSet()
25
            ->children()
26
                ->arrayNode('enabled_storage')
27
                    ->info('Enable these storage backends')
28
                    ->prototype('scalar')->end()
29
                ->end()
30
                ->arrayNode('storage')
31
                    ->addDefaultsIfNotSet()
32
                    ->children();
33
34
        foreach ($this->storageLoaders as $key => $storageLoader) {
35
            $storageNode = $node->arrayNode($key)
36
                ->addDefaultsIfNotSet()
37
                ->children();
38
            $storageLoader->configure($storageNode);
39
        }
40
41
        return $treeBuilder;
42
    }
43
}
44