Configuration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 98
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 4 1
B buildConfigTree() 0 60 1
1
<?php
2
/**
3
 * This file is part of BraincraftedBootstrapBundle.
4
 *
5
 * (c) 2012-2013 by Florian Eckerstorfer
6
 */
7
8
namespace Braincrafted\Bundle\BootstrapBundle\DependencyInjection;
9
10
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
11
use Symfony\Component\Config\Definition\ConfigurationInterface;
12
13
/**
14
 * Configuration
15
 *
16
 * @package    BraincraftedBootstrapBundle
17
 * @subpackage DependencyInjection
18
 * @author     Florian Eckerstorfer <[email protected]>
19
 * @copyright  2012-2013 Florian Eckerstorfer
20
 * @license    http://opensource.org/licenses/MIT The MIT License
21
 * @link       http://bootstrap.braincrafted.com Bootstrap for Symfony2
22
 */
23
class Configuration implements ConfigurationInterface
24
{
25
    /** @var string */
26
    const DEFAULT_ASSETS_DIR = '%kernel.root_dir%/../vendor/twbs/bootstrap';
27
28
    /** @var string */
29
    const DEFAULT_ASSETS_DIR_SASS = '%kernel.root_dir%/../vendor/twbs/bootstrap-sass/assets';
30
31
    /** @var string */
32
    const DEFAULT_FONTAWESOME_DIR = '%kernel.root_dir%/../vendor/fortawesome/font-awesome';
33
34
    /** @var string */
35
    const DEFAULT_BOOTSTRAP_OUTPUT = '%kernel.root_dir%/Resources/less/bootstrap.less';
36
37
    /** @var string */
38
    const DEFAULT_BOOTSTRAP_OUTPUT_SASS = '%kernel.root_dir%/Resources/sass/bootstrap.scss';
39
40
    /** @var string */
41
    const DEFAULT_BOOTSTRAP_TEMPLATE = 'BraincraftedBootstrapBundle:Bootstrap:bootstrap.less.twig';
42
43
    /** @var string */
44
    const DEFAULT_BOOTSTRAP_TEMPLATE_SASS = 'BraincraftedBootstrapBundle:Bootstrap:bootstrap.scss.twig';
45
46
    /** @var string */
47
    const DEFAULT_JQUERY_PATH = '%kernel.root_dir%/../vendor/jquery/jquery/jquery-1.11.1.js';
48
49
    /** @var string */
50
    const DEFAULT_FONTS_DIR = '%kernel.root_dir%/../web/fonts';
51
52
    /**
53
     * {@inheritDoc}
54
     */
55
    public function getConfigTreeBuilder()
56
    {
57
        return $this->buildConfigTree();
58
    }
59
60
    private function buildConfigTree()
61
    {
62
        $treeBuilder = new TreeBuilder();
63
        $rootNode = $treeBuilder->root('braincrafted_bootstrap');
64
65
        $rootNode
66
            ->children()
67
                ->scalarNode('output_dir')->defaultValue('')->end()
68
                ->scalarNode('assets_dir')
69
                    ->defaultValue(self::DEFAULT_ASSETS_DIR)
70
                ->end()
71
                ->scalarNode('fontawesome_dir')
72
                    ->defaultValue(self::DEFAULT_FONTAWESOME_DIR)
73
                ->end()
74
                ->scalarNode('jquery_path')
75
                    ->defaultValue(self::DEFAULT_JQUERY_PATH)
76
                ->end()
77
                ->scalarNode('fonts_dir')
78
                    ->defaultValue(self::DEFAULT_FONTS_DIR)
79
                ->end()
80
81
                // renamed from css_preprocessor to css_preprocessor
82
                ->scalarNode('css_preprocessor')
83
                    ->defaultValue('less')
84
                    ->validate()
85
                        ->ifNotInArray(array('less', 'lessphp', 'sass', 'scssphp', 'none'))
86
                        ->thenInvalid('Invalid less filter "%s"')
87
                    ->end()
88
                ->end()
89
                ->scalarNode('icon_prefix')
90
                    ->defaultValue('glyphicon')
91
                ->end()
92
                ->scalarNode('icon_tag')
93
                    ->defaultValue('span')
94
                ->end()
95
                ->arrayNode('customize')
96
                    ->addDefaultsIfNotSet()
97
                    ->children()
98
                        ->scalarNode('variables_file')->end()
99
                        ->scalarNode('bootstrap_output')
100
                            ->defaultValue(self::DEFAULT_BOOTSTRAP_OUTPUT)
101
                        ->end()
102
                        ->scalarNode('bootstrap_template')
103
                            ->defaultValue(self::DEFAULT_BOOTSTRAP_TEMPLATE)
104
                        ->end()
105
                    ->end()
106
                ->end()
107
                ->arrayNode('auto_configure')
108
                    ->addDefaultsIfNotSet()
109
                    ->children()
110
                        ->booleanNode('assetic')->defaultValue(true)->end()
111
                        ->booleanNode('twig')->defaultValue(true)->end()
112
                        ->booleanNode('knp_menu')->defaultValue(true)->end()
113
                        ->booleanNode('knp_paginator')->defaultValue(true)->end()
114
                    ->end()
115
                ->end()
116
            ->end();
117
118
        return $treeBuilder;
119
    }
120
}
121