Completed
Push — master ( 1e6b4e...d692a8 )
by Rafał
14:51
created

Configuration::getConfigTreeBuilder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 63

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 66
rs 9.3191
cc 1
eloc 63
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\MultiTenancyBundle\DependencyInjection;
16
17
use SWP\Component\MultiTenancy\Factory\TenantFactory;
18
use SWP\Component\MultiTenancy\Model\Tenant;
19
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
20
use Symfony\Component\Config\Definition\ConfigurationInterface;
21
22
/**
23
 * This is the class that validates and merges configuration from your app/config files.
24
 *
25
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
26
 */
27
class Configuration implements ConfigurationInterface
28
{
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getConfigTreeBuilder()
33
    {
34
        $treeBuilder = new TreeBuilder();
35
        $treeBuilder->root('swp_multi_tenancy')
36
            ->children()
37
                ->arrayNode('resources')
38
                    ->addDefaultsIfNotSet()
39
                    ->children()
40
                        ->arrayNode('tenant')
41
                            ->addDefaultsIfNotSet()
42
                            ->children()
43
                                ->arrayNode('classes')
44
                                    ->addDefaultsIfNotSet()
45
                                    ->children()
46
                                        ->scalarNode('model')
47
                                            ->defaultValue(Tenant::class)
48
                                            ->cannotBeEmpty()
49
                                            ->info('The FQCN of the Tenant model class.')
50
                                        ->end()
51
                                        ->scalarNode('factory')
52
                                            ->defaultValue(TenantFactory::class)
53
                                            ->info('The FQCN of the Tenant Factory class.')
54
                                        ->end()
55
                                    ->end()
56
                                ->end()
57
                            ->end()
58
                        ->end()
59
                    ->end()
60
                ->end()
61
                ->arrayNode('persistence')
62
                    ->addDefaultsIfNotSet()
63
                    ->children()
64
                        ->arrayNode('phpcr')
65
                            ->addDefaultsIfNotSet()
66
                            ->canBeEnabled()
67
                            ->children()
68
                                ->scalarNode('basepath')->defaultValue('/swp')->end()
69
                                ->arrayNode('route_basepaths')
70
                                    ->prototype('scalar')->end()
71
                                    ->defaultValue(['routes'])
72
                                    ->info('Route base paths names')
73
                                ->end()
74
                                ->scalarNode('content_basepath')
75
                                    ->defaultValue('content')
76
                                    ->info('Content base path name')
77
                                ->end()
78
                                ->scalarNode('site_document_class')
79
                                    ->defaultValue('SWP\Bundle\MultiTenancyBundle\Document\Site')
80
                                    ->info('Site document class, represents current site/tenant in PHPCR tree')
81
                                ->end()
82
                                ->scalarNode('tenant_aware_router_class')
83
                                    ->defaultValue('SWP\Bundle\MultiTenancyBundle\Routing\TenantAwareRouter')
84
                                    ->info('Tenant aware router FQCN')
85
                                ->end()
86
                                ->scalarNode('document_class')
87
                                    ->defaultValue('SWP\Bundle\MultiTenancyBundle\Document\Page')
88
                                    ->info('The class for the pages used by PHPCR initializer')
89
                                ->end()
90
                            ->end()
91
                        ->end()
92
                    ->end()
93
                ->end()
94
            ->end();
95
96
        return $treeBuilder;
97
    }
98
}
99