Completed
Pull Request — master (#2609)
by
unknown
70:41 queued 64:09
created

Configuration   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 92
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 98.55%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 92
ccs 68
cts 69
cp 0.9855
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 77 2
1
<?php
2
3
namespace Kunstmaan\MediaBundle\DependencyInjection;
4
5
use Kunstmaan\MediaBundle\Utils\SymfonyVersion;
6
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
7
use Symfony\Component\Config\Definition\ConfigurationInterface;
8
9
/**
10
 * This is the class that validates and merges configuration from your app/config files
11
 *
12
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
13
 */
14
class Configuration implements ConfigurationInterface
15
{
16
    private const DEFAULT_CROPPING_VIEWS_CONFIG = [
17
        ['name' => 'desktop', 'width' => 1, 'height' => 1, 'lock_ratio' => true],
18
        ['name' => 'tablet', 'width' => 1, 'height' => 1, 'lock_ratio' => true],
19
        ['name' => 'phone', 'width' => 1, 'height' => 1, 'lock_ratio' => true],
20
    ];
21
    private const DEFAULT_FOCUS_POINT_CLASSES = ['top-left', 'top-center', 'top-right', 'center-left', 'center', 'center-right', 'bottom-left', 'bottom-center', 'bottom-right'];
22
23
    /**
24
     * Generates the configuration tree.
25
     *
26
     * @return TreeBuilder
27
     */
28 6
    public function getConfigTreeBuilder()
29
    {
30 6
        $treeBuilder = new TreeBuilder('kunstmaan_media');
31 6
        if (method_exists($treeBuilder, 'getRootNode')) {
32 6
            $rootNode = $treeBuilder->getRootNode();
33
        } else {
34
            // BC layer for symfony/config 4.1 and older
35
            $rootNode = $treeBuilder->root('kunstmaan_media');
0 ignored issues
show
Deprecated Code introduced by
The method Symfony\Component\Config...der\TreeBuilder::root() has been deprecated with message: since Symfony 4.3, pass the root name to the constructor instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
36
        }
37
38
        $rootNode
39 6
            ->children()
40 6
                ->scalarNode('soundcloud_api_key')->defaultValue('YOUR_CLIENT_ID')->end()
41 6
                ->scalarNode('aviary_api_key')->setDeprecated('The child node "%node%" at path "%path%" is deprecated. Because the aviary service is discontinued.')->defaultNull()->end()
42 6
                ->arrayNode('remote_video')
43 6
                    ->addDefaultsIfNotSet()
44 6
                    ->children()
45 6
                        ->booleanNode('vimeo')->defaultTrue()->end()
46 6
                        ->booleanNode('youtube')->defaultTrue()->end()
47 6
                        ->booleanNode('dailymotion')->defaultTrue()->end()
48 6
                    ->end()
49 6
                ->end()
50 6
                ->booleanNode('enable_pdf_preview')->defaultFalse()->end()
51 6
                ->arrayNode('blacklisted_extensions')
52 6
                    ->defaultValue(['php', 'htaccess'])
53 6
                    ->prototype('scalar')->end()
54 6
                ->end()
55 6
                ->scalarNode('web_root')
56 6
                    ->defaultValue(SymfonyVersion::getRootWebPath())
57 6
                    ->cannotBeEmpty()
58 6
                ->end()
59 6
                ->arrayNode('cropping_views')
60 6
                    ->addDefaultsIfNotSet()
61 6
                    ->children()
62 6
                        ->arrayNode('default')
63 6
                            ->defaultValue(self::DEFAULT_CROPPING_VIEWS_CONFIG)
64 6
                            ->arrayPrototype()
65 6
                                ->addDefaultsIfNotSet()
66 6
                                ->children()
67 6
                                    ->scalarNode('name')->end()
68 6
                                    ->integerNode('width')->end()
69 6
                                    ->integerNode('height')->end()
70 6
                                    ->booleanNode('lock_ratio')->defaultTrue()->end()
71 6
                                ->end()
72 6
                            ->end()
73 6
                        ->end()
74 6
                        ->arrayNode('focus_point_classes')
75 6
                            ->defaultValue(self::DEFAULT_FOCUS_POINT_CLASSES)
76 6
                            ->prototype('array')->end()
77 6
                        ->end()
78 6
                        ->arrayNode('custom_views')
79 6
                            ->useAttributeAsKey('groupName')
80 6
                            ->arrayPrototype()
81 6
                                ->addDefaultsIfNotSet()
82 6
                                ->children()
83 6
                                    ->booleanNode('use_focus_point')->defaultFalse()->end()
84 6
                                    ->booleanNode('use_cropping')->defaultTrue()->end()
85 6
                                    ->arrayNode('views')
86 6
                                        ->arrayPrototype()
87 6
                                            ->addDefaultsIfNotSet()
88 6
                                            ->children()
89 6
                                                ->scalarNode('name')->end()
90 6
                                                ->integerNode('width')->end()
91 6
                                                ->integerNode('height')->end()
92 6
                                                ->booleanNode('lock_ratio')->defaultTrue()->end()
93 6
                                            ->end()
94 6
                                        ->end()
95 6
                                    ->end()
96 6
                                ->end()
97 6
                            ->end()
98 6
                        ->end()
99 6
                    ->end()
100 6
                ->end()
101 6
            ->end();
102
103 6
        return $treeBuilder;
104
    }
105
}
106