Configuration::storagesConfig()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 2.052

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
ccs 13
cts 17
cp 0.7647
rs 9.2
cc 2
eloc 17
nc 2
nop 0
crap 2.052
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Bundle\ActivityLogBundle\DependencyInjection;
13
14
use Sulu\Bundle\ElasticsearchActivityLogBundle\Storage\ElasticsearchActivityStorage;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Config\Definition\ConfigurationInterface;
17
18
/**
19
 * Initializes configuration tree for activity-log-bundle.
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26 1
    public function getConfigTreeBuilder()
27
    {
28 1
        $storages = ['array', 'custom'];
29
30 1
        if (class_exists(ElasticsearchActivityStorage::class)) {
31
            $storages[] = 'elastic';
32
        }
33
34 1
        $treeBuilder = new TreeBuilder();
35 1
        $treeBuilder->root('sulu_activity_log')
36 1
            ->children()
37 1
                ->enumNode('storage')
38 1
                    ->values($storages)->end()
39 1
                ->append($this->storagesConfig());
40
41 1
        return $treeBuilder;
42
    }
43
44 1
    private function storagesConfig()
45
    {
46 1
        $treeBuilder = new TreeBuilder();
47 1
        $children = $treeBuilder->root('storages')
48 1
            ->children()
49 1
                ->arrayNode('array')
50 1
                ->end()
51 1
                ->arrayNode('custom')
52 1
                    ->children()
53 1
                        ->scalarNode('id')->end()
54 1
                    ->end()
55 1
                ->end();
56
57 1
        if (class_exists(ElasticsearchActivityStorage::class)) {
58
            $children->arrayNode('elastic')
59
                ->children()
60
                    ->scalarNode('ongr_manager')->end()
61
                ->end();
62
        }
63
64 1
        return $children->end();
65
    }
66
}
67