Configuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 29 1
1
<?php
2
3
/*
4
 * This file is part of the adminbsb-material-design-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
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 WBW\Bundle\AdminBSBBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
use WBW\Bundle\AdminBSBBundle\Theme\SkinsThemeProvider;
17
use WBW\Bundle\CoreBundle\DependencyInjection\ConfigurationHelper;
18
19
/**
20
 * Configuration.
21
 *
22
 * @author webeweb <https://github.com/webeweb/>
23
 * @package WBW\Bundle\AdminBSBBundle\DependencyInjection
24
 */
25
class Configuration implements ConfigurationInterface {
26
27
    /**
28
     * {@inheritDoc}
29
     */
30
    public function getConfigTreeBuilder(): TreeBuilder {
31
32
        $assets  = ConfigurationHelper::loadYamlConfig(__DIR__, "assets");
33
        $plugins = $assets["assets"]["wbw.adminbsb.asset.adminbsb"]["plugins"];
34
        $skins   = SkinsThemeProvider::enumSkins();
35
36
        $treeBuilder = new TreeBuilder(WBWAdminBSBExtension::EXTENSION_ALIAS);
37
38
        $rootNode = ConfigurationHelper::getRootNode($treeBuilder, WBWAdminBSBExtension::EXTENSION_ALIAS);
39
        $rootNode
40
            ->children()
41
                ->booleanNode("twig")->defaultTrue()->info("Load Twig extensions")->end()
42
                ->scalarNode("skin")->defaultValue("red")->info("AdminBSB skin")
43
                    ->validate()
44
                        ->ifNotInArray($skins)
45
                        ->thenInvalid("The AdminBSB skin %s is not supported. Please choose one of " . json_encode($skins))
46
                    ->end()
47
                ->end()
48
                ->arrayNode("plugins")->info("AdminBSB plug-ins")
49
                    ->prototype("scalar")
50
                        ->validate()
51
                            ->ifNotInArray(array_keys($plugins))
52
                            ->thenInvalid("The AdminBSB plug-in %s is not supported. Please choose one of " . json_encode(array_keys($plugins)))
53
                        ->end()
54
                ->end()
55
            ->end();
56
57
        return $treeBuilder;
58
    }
59
}
60