Completed
Pull Request — master (#244)
by Łukasz
09:35
created

Configuration   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 53 3
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\DependencyInjection;
11
12
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
13
use Symfony\Component\Config\Definition\ConfigurationInterface;
14
15
/**
16
 * @author Norbert Orzechowicz <[email protected]>
17
 */
18
class Configuration implements ConfigurationInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getConfigTreeBuilder()
24
    {
25
        $treeBuilder = new TreeBuilder();
26
        $rootNode = $treeBuilder->root('fsi_admin');
27
28
        $rootNode
29
            ->validate()
30
                ->always(function($v) {
31
                    if (!isset($v['templates']['crud_list'])) {
32
                        $v['templates']['crud_list'] = $v['templates']['list'];
33
                    }
34
                    if (!isset($v['templates']['crud_form'])) {
35
                        $v['templates']['crud_form'] = $v['templates']['form'];
36
                    }
37
                    return $v;
38
                })
39
            ->end()
40
            ->children()
41
                ->scalarNode('default_locale')->defaultValue('%locale%')->end()
42
                ->arrayNode('locales')
43
                    ->prototype('scalar')->end()
44
                    ->defaultValue(array('%locale%'))
45
                ->end()
46
                ->scalarNode('menu_config_path')->defaultValue("%kernel.root_dir%/config/admin_menu.yml")->end()
47
                ->arrayNode('templates')
48
                    ->addDefaultsIfNotSet()
49
                    ->children()
50
                        ->scalarNode('base')->defaultValue('@FSiAdmin/base.html.twig')->end()
51
                        ->scalarNode('index_page')->defaultValue('@FSiAdmin/Admin/index.html.twig')->end()
52
                        ->scalarNode('list')->defaultValue('@FSiAdmin/List/list.html.twig')->end()
53
                        ->scalarNode('form')->defaultValue('@FSiAdmin/Form/form.html.twig')->end()
54
                        ->scalarNode('crud_list')->defaultValue('@FSiAdmin/CRUD/list.html.twig')->end()
55
                        ->scalarNode('crud_form')->defaultNull()->end()
56
                        ->scalarNode('resource')->defaultValue('@FSiAdmin/Resource/resource.html.twig')->end()
57
                        ->scalarNode('display')->defaultValue('@FSiAdmin/Display/display.html.twig')->end()
58
                        ->scalarNode('datagrid_theme')->defaultValue('@FSiAdmin/CRUD/datagrid.html.twig')->end()
59
                        ->scalarNode('datasource_theme')->defaultValue('@FSiAdmin/CRUD/datasource.html.twig')->end()
60
                        ->scalarNode('form_theme')->defaultValue('@FSiAdmin/Form/form_theme.html.twig')->end()
61
                    ->end()
62
                ->end()
63
                ->arrayNode('annotations')
64
                    ->addDefaultsIfNotSet()
65
                    ->children()
66
                        ->arrayNode('dirs')
67
                            ->prototype('scalar')->defaultValue(array())->end()
68
                        ->end()
69
                    ->end()
70
                ->end()
71
            ->end()
72
        ;
73
74
        return $treeBuilder;
75
    }
76
}
77