Completed
Pull Request — master (#453)
by Maximilian
03:27 queued 01:50
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 56 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
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 Sonata\DoctrinePHPCRAdminBundle\DependencyInjection;
13
14
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
15
use Symfony\Component\Config\Definition\ConfigurationInterface;
16
17
/**
18
 * This class contains the configuration information for the bundle.
19
 *
20
 * This information is solely responsible for how the different configuration
21
 * sections are normalized, and merged.
22
 *
23
 * @author Michael Williams <[email protected]>
24
 */
25
class Configuration implements ConfigurationInterface
26
{
27
    /**
28
     * Generates the configuration tree.
29
     *
30
     * @return TreeBuilder
31
     */
32
    public function getConfigTreeBuilder()
33
    {
34
        $treeBuilder = new TreeBuilder();
35
        $rootNode = $treeBuilder->root('sonata_doctrine_phpcr_admin', 'array');
36
37
        $rootNode
38
            ->fixXmlConfig('template')
39
            ->children()
40
                ->arrayNode('templates')
41
                    ->addDefaultsIfNotSet()
42
                    ->children()
43
                        ->arrayNode('form')
44
                            ->prototype('scalar')->end()
45
                            ->defaultValue(array('SonataDoctrinePHPCRAdminBundle:Form:form_admin_fields.html.twig'))
46
                        ->end()
47
                        ->arrayNode('filter')
48
                            ->prototype('scalar')->end()
49
                            ->defaultValue(array('SonataDoctrinePHPCRAdminBundle:Form:filter_admin_fields.html.twig'))
50
                        ->end()
51
                        ->arrayNode('types')
52
                            ->children()
53
                                ->arrayNode('list')
54
                                    ->useAttributeAsKey('name')
55
                                    ->prototype('scalar')->end()
56
                                ->end()
57
                                ->arrayNode('show')
58
                                    ->useAttributeAsKey('name')
59
                                    ->prototype('scalar')->end()
60
                                ->end()
61
                            ->end()
62
                        ->end()
63
                        ->scalarNode('pager_results')->defaultValue('SonataDoctrinePHPCRAdminBundle:Pager:simple_pager_results.html.twig')->cannotBeEmpty()->end()
64
                    ->end()
65
                ->end()
66
                ->arrayNode('document_tree')
67
                    ->canBeEnabled()
68
                    ->children()
69
                        ->scalarNode('repository_name')
70
                            ->defaultValue('default')
71
                            ->info('The repository name the resource API connects to.')
72
                        ->end()
73
                        ->arrayNode('routing_defaults')
74
                            ->prototype('scalar')->end()
75
                            ->info('Routing defaults passed to the resources API call.')
76
                        ->end()
77
                        ->scalarNode('sortable_by')
78
                            ->defaultValue('position')
79
                            ->info('Defines by which property to sort sibling documents.')
80
                        ->end()
81
                    ->end()
82
                ->end()
83
            ->end()
84
        ;
85
86
        return $treeBuilder;
87
    }
88
}
89