Completed
Pull Request — master (#3)
by
unknown
30:30
created

Configuration::storagesConfig()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 22
ccs 0
cts 0
cp 0
rs 9.2
cc 2
eloc 17
nc 2
nop 0
crap 6
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 1
     */
26
    public function getConfigTreeBuilder()
27 1
    {
28 1
        $storages = ['array', 'custom'];
29 1
30 1
        if (class_exists(ElasticsearchActivityStorage::class)) {
31 1
            $storages[] = 'elastic';
32 1
        }
33 1
34 1
        $treeBuilder = new TreeBuilder();
35
        $treeBuilder->root('sulu_activity_log')
36 1
            ->children()
37
                ->enumNode('storage')
38
                    ->values($storages)->end()
39
                ->append($this->storagesConfig());
40
41
        return $treeBuilder;
42
    }
43
44
    private function storagesConfig()
45
    {
46
        $treeBuilder = new TreeBuilder();
47
        $children = $treeBuilder->root('storages')
48
            ->children()
49
                ->arrayNode('array')
50
                ->end()
51
                ->arrayNode('custom')
52
                    ->children()
53
                        ->scalarNode('id')->end()
54
                    ->end()
55
                ->end();
56
57
        if (class_exists(ElasticsearchActivityStorage::class)) {
58
            $children->arrayNode('elastic')
59
                ->children()
60
                    ->scalarNode('ongr_manager')->end()
61
                ->end();
62
        }
63
64
        return $children->end();
65
    }
66
}
67