Completed
Push — master ( b45cf9...142c7f )
by Kévin
7s
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 2
Paths 1

Size

Total Lines 37
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 37
rs 8.8571
cc 2
eloc 31
nc 1
nop 0
1
<?php
2
3
/*
4
 * (c) Kévin Dunglas <[email protected]>
5
 *
6
 * This source file is subject to the MIT license that is bundled
7
 * with this source code in the file LICENSE.
8
 */
9
10
namespace Dunglas\ActionBundle\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
use Symfony\Component\Console\Command\Command;
15
16
/**
17
 * {@inheritdoc}
18
 *
19
 * @author Kévin Dunglas <[email protected]>
20
 */
21
class Configuration implements ConfigurationInterface
22
{
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getConfigTreeBuilder()
27
    {
28
        $treeBuilder = new TreeBuilder();
29
        $treeBuilder->root('dunglas_action')
30
            ->children()
31
                ->arrayNode('autodiscover')
32
                    ->info('Autodiscover action classes stored in the configured directory of bundles and register them as service.')
33
                    ->canBeDisabled()
34
                    ->children()
35
                        ->arrayNode('directories')
36
                            ->info('The directory name to autodiscover in bundles.')
37
                            ->prototype('array')
38
                                ->prototype('scalar')->end()
39
                            ->end()
40
                            ->defaultValue(call_user_func(function () {
41
                                $defaultValue = ['action' => ['Action']];
42
                                if (class_exists(Command::class)) {
43
                                    $defaultValue['command'] = ['Command'];
44
                                }
45
46
                                return $defaultValue;
47
                            }))
48
                        ->end()
49
                    ->end()
50
                ->end()
51
                ->arrayNode('directories')
52
                    ->info('List of directories relative to the kernel root directory containing classes.')
53
                    ->prototype('array')
54
                        ->prototype('scalar')->end()
55
                    ->end()
56
                    ->defaultValue([])
57
                ->end()
58
            ->end()
59
        ->end();
60
61
        return $treeBuilder;
62
    }
63
}
64