Completed
Push — master ( 0708d4...99f0e4 )
by Rafał
02:36
created

Configuration   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 1
c 4
b 1
f 0
lcom 0
cbo 3
dl 0
loc 56
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigTreeBuilder() 0 50 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Bridge for the Content API.
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
namespace SWP\Bundle\BridgeBundle\DependencyInjection;
15
16
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
17
use Symfony\Component\Config\Definition\ConfigurationInterface;
18
19
/**
20
 * This is the class that validates and merges configuration from your app/config files.
21
 *
22
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
23
 */
24
class Configuration implements ConfigurationInterface
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function getConfigTreeBuilder()
30
    {
31
        $treeBuilder = new TreeBuilder();
32
        $rootNode = $treeBuilder->root('swp_bridge', 'array');
33
34
        $rootNode
35
            ->children()
36
                ->arrayNode('api')
37
                    ->children()
38
                        ->scalarNode('host')
39
                            ->info('Hostname of the Content API.')
40
                            ->isRequired()
41
                            ->cannotBeEmpty()
42
                        ->end()
43
                        ->integerNode('port')
44
                            ->info('Port of the Content API.')
45
                            ->defaultValue(80)
46
                        ->end()
47
                        ->enumNode('protocol')
48
                            ->info('Protocol which will be used for connection to the Content Api.')
49
                            ->values(array('http', 'https'))
50
                            ->defaultValue('https')
51
                        ->end()
52
                    ->end()
53
                ->end()
54
                ->arrayNode('auth')
55
                    ->children()
56
                        ->scalarNode('client_id')
57
                            ->info('Client ID for OAuth2 authentication for the Content Api.')
58
                            ->isRequired()
59
                            ->cannotBeEmpty()
60
                        ->end()
61
                        ->scalarNode('username')
62
                            ->info('Username for OAuth2 authentication for the Content Api.')
63
                            ->isRequired()
64
                            ->cannotBeEmpty()
65
                        ->end()
66
                        ->scalarNode('password')
67
                            ->info('Password for OAuth2 authentication for the Content Api.')
68
                            ->isRequired()
69
                            ->cannotBeEmpty()
70
                        ->end()
71
                    ->end()
72
                ->end()
73
                ->variableNode('options')->end()
74
            ->end()
75
        ;
76
77
        return $treeBuilder;
78
    }
79
}
80