Configuration::getConfigTreeBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 49
Code Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 9.2258
c 0
b 0
f 0
cc 1
eloc 38
nc 1
nop 0
1
<?php
2
3
namespace Alcalyn\PayplugBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
use Alcalyn\PayplugBundle\Model\IPN;
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
    /**
17
     * {@inheritDoc}
18
     */
19
    public function getConfigTreeBuilder()
20
    {
21
        $treeBuilder = new TreeBuilder();
22
        $rootNode = $treeBuilder->root('alcalyn_payplug');
23
        
24
        $rootNode
25
            ->children()
26
            
27
            // Payplug account parameters
28
            ->arrayNode('account')
29
                ->children()
30
                    ->scalarNode('url')->end()
31
                    ->scalarNode('amount_min')->end()
32
                    ->scalarNode('amount_max')->end()
33
                    ->arrayNode('currencies')
34
                        ->prototype('scalar')->end()
35
                    ->end()
36
                    ->scalarNode('payplugPublicKey')->end()
37
                    ->scalarNode('yourPrivateKey')->end()
38
                ->end()
39
            ->end()
40
            
41
            // Sandbox parameters
42
            ->arrayNode('sandbox')
43
                ->addDefaultsIfNotSet()
44
                ->children()
45
                    ->booleanNode('enabled')
46
                        ->defaultFalse()
47
                    ->end()
48
                    ->arrayNode('account')
49
                        ->children()
50
                            ->scalarNode('url')->defaultNull()->end()
51
                            ->scalarNode('yourPrivateKey')->defaultNull()->end()
52
                        ->end()
53
                    ->end()
54
                ->end()
55
            ->end()
56
            
57
            // Entities classes to use
58
            ->arrayNode('class')
59
                ->addDefaultsIfNotSet()
60
                ->children()
61
                    ->scalarNode('ipn')->defaultValue(IPN::getClassName())->end()
62
                ->end()
63
            ->end()
64
        ;
65
66
        return $treeBuilder;
67
    }
68
}
69