Completed
Push — master ( a682ba...4851b3 )
by Paweł
40:50
created

Configuration::getConfigTreeBuilder()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 120
Code Lines 117

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 117
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 120
ccs 117
cts 117
cp 1
rs 8.2857
c 0
b 0
f 0
cc 1
eloc 117
nc 1
nop 0
crap 1

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 Content Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. 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 2016 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\ContentBundle\DependencyInjection;
16
17
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\Article;
18
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\ArticleRepository;
19
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\Route;
20
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\Site;
21
use SWP\Bundle\ContentBundle\Doctrine\ODM\PHPCR\Media;
22
use SWP\Bundle\ContentBundle\Doctrine\ORM\Article as ORMArticle;
23
use SWP\Bundle\ContentBundle\Doctrine\ORM\ArticleRepository as ORMArticleRepository;
24
use SWP\Bundle\ContentBundle\Doctrine\ORM\Route as ORMRoute;
25
use SWP\Bundle\ContentBundle\Doctrine\ORM\RouteRepository;
26
use SWP\Bundle\ContentBundle\Doctrine\ORM\ArticleMedia as ORMArticleMedia;
27
use SWP\Bundle\ContentBundle\Doctrine\ORM\ArticleMediaRepository as ORMArticleMediaRepository;
28
use SWP\Bundle\ContentBundle\Doctrine\ORM\Image as ORMImage;
29
use SWP\Bundle\ContentBundle\Doctrine\ORM\ImageRepository as ORMImageRepository;
30
use SWP\Bundle\ContentBundle\Factory\ORM\MediaFactory;
31
use SWP\Bundle\ContentBundle\Factory\PHPCR\ArticleFactory;
32
use SWP\Bundle\ContentBundle\Factory\RouteFactory;
33
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
34
use Symfony\Component\Config\Definition\ConfigurationInterface;
35
36
/**
37
 * This is the class that validates and merges configuration from your app/config files.
38
 *
39
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
40
 */
41
class Configuration implements ConfigurationInterface
42
{
43
    /**
44
     * {@inheritdoc}
45
     */
46 2
    public function getConfigTreeBuilder()
47
    {
48 2
        $treeBuilder = new TreeBuilder();
49 2
        $treeBuilder->root('swp_content')
50 2
            ->children()
51 2
                ->arrayNode('persistence')
52 2
                    ->addDefaultsIfNotSet()
53 2
                    ->children()
54 2
                        ->arrayNode('phpcr')
55 2
                            ->addDefaultsIfNotSet()
56 2
                            ->canBeEnabled()
57 2
                            ->children()
58 2
                                ->scalarNode('default_content_path')
59 2
                                    ->defaultValue('articles')
60 2
                                ->end()
61 2
                                ->arrayNode('classes')
62 2
                                    ->addDefaultsIfNotSet()
63 2
                                    ->children()
64 2
                                        ->arrayNode('article')
65 2
                                            ->addDefaultsIfNotSet()
66 2
                                            ->children()
67 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(Article::class)->end()
68 2
                                                ->scalarNode('repository')->defaultValue(ArticleRepository::class)->end()
69 2
                                                ->scalarNode('factory')->defaultValue(ArticleFactory::class)->end()
70 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
71 2
                                            ->end()
72 2
                                        ->end()
73 2
                                        ->arrayNode('site')
74 2
                                            ->addDefaultsIfNotSet()
75 2
                                            ->children()
76 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(Site::class)->end()
77 2
                                                ->scalarNode('repository')->defaultValue(null)->end()
78 2
                                                ->scalarNode('factory')->defaultValue(RouteFactory::class)->end()
79 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
80 2
                                            ->end()
81 2
                                        ->end()
82 2
                                        ->arrayNode('route')
83 2
                                            ->addDefaultsIfNotSet()
84 2
                                            ->children()
85 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(Route::class)->end()
86 2
                                                ->scalarNode('repository')->defaultValue(null)->end()
87 2
                                                ->scalarNode('factory')->defaultValue(RouteFactory::class)->end()
88 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
89 2
                                            ->end()
90 2
                                        ->end()
91 2
                                        ->arrayNode('media')
92 2
                                            ->addDefaultsIfNotSet()
93 2
                                            ->children()
94 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(Media::class)->end()
95 2
                                                ->scalarNode('repository')->defaultValue(null)->end()
96 2
                                                ->scalarNode('factory')->defaultValue(null)->end()
97 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
98 2
                                            ->end()
99 2
                                        ->end()
100 2
                                    ->end()
101 2
                                ->end() // classes
102 2
                            ->end()
103 2
                        ->end() // phpcr
104 2
                        ->arrayNode('orm')
105 2
                            ->addDefaultsIfNotSet()
106 2
                            ->canBeEnabled()
107 2
                            ->children()
108 2
                                ->arrayNode('classes')
109 2
                                    ->addDefaultsIfNotSet()
110 2
                                    ->children()
111 2
                                        ->arrayNode('article')
112 2
                                            ->addDefaultsIfNotSet()
113 2
                                            ->children()
114 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(ORMArticle::class)->end()
115 2
                                                ->scalarNode('repository')->defaultValue(ORMArticleRepository::class)->end()
116 2
                                                ->scalarNode('factory')->defaultValue(\SWP\Bundle\ContentBundle\Factory\ORM\ArticleFactory::class)->end()
117 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
118 2
                                            ->end()
119 2
                                        ->end()
120 2
                                        ->arrayNode('site')
121 2
                                            ->addDefaultsIfNotSet()
122 2
                                            ->children()
123 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(Site::class)->end()
124 2
                                                ->scalarNode('repository')->defaultValue(null)->end()
125 2
                                                ->scalarNode('factory')->defaultValue(RouteFactory::class)->end()
126 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
127 2
                                            ->end()
128 2
                                        ->end()
129 2
                                        ->arrayNode('route')
130 2
                                            ->addDefaultsIfNotSet()
131 2
                                            ->children()
132 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(ORMRoute::class)->end()
133 2
                                                ->scalarNode('repository')->defaultValue(RouteRepository::class)->end()
134 2
                                                ->scalarNode('factory')->defaultValue(RouteFactory::class)->end()
135 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
136 2
                                            ->end()
137 2
                                        ->end()
138 2
                                        ->arrayNode('media')
139 2
                                            ->addDefaultsIfNotSet()
140 2
                                            ->children()
141 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(ORMArticleMedia::class)->end()
142 2
                                                ->scalarNode('repository')->defaultValue(ORMArticleMediaRepository::class)->end()
143 2
                                                ->scalarNode('factory')->defaultValue(MediaFactory::class)->end()
144 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
145 2
                                            ->end()
146 2
                                        ->end()
147 2
                                        ->arrayNode('image')
148 2
                                            ->addDefaultsIfNotSet()
149 2
                                            ->children()
150 2
                                                ->scalarNode('model')->cannotBeEmpty()->defaultValue(ORMImage::class)->end()
151 2
                                                ->scalarNode('repository')->defaultValue(ORMImageRepository::class)->end()
152 2
                                                ->scalarNode('factory')->defaultValue(null)->end()
153 2
                                                ->scalarNode('object_manager_name')->defaultValue(null)->end()
154 2
                                            ->end()
155 2
                                        ->end()
156 2
                                    ->end()
157 2
                                ->end() // classes
158 2
                            ->end()
159 2
                        ->end() // orm
160 2
                    ->end()
161 2
                ->end()
162 2
            ->end();
163
164 2
        return $treeBuilder;
165
    }
166
}
167