1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Nexylan packages. |
5
|
|
|
* |
6
|
|
|
* (c) Nexylan SAS <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Nexy\PayboxDirect\Bridge\Symfony\DependencyInjection; |
13
|
|
|
|
14
|
|
|
use Nexy\PayboxDirect\Enum\Activity; |
15
|
|
|
use Nexy\PayboxDirect\Enum\Currency; |
16
|
|
|
use Nexy\PayboxDirect\Enum\Version; |
17
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
18
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @author Sullivan Senechal <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
final class Configuration implements ConfigurationInterface |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* {@inheritdoc} |
27
|
|
|
*/ |
28
|
|
|
public function getConfigTreeBuilder() |
29
|
|
|
{ |
30
|
|
|
$treeBuilder = new TreeBuilder('nexy_paybox_direct'); |
31
|
|
|
$rootNode = $treeBuilder->getRootNode(); |
32
|
|
|
|
33
|
|
|
$rootNode |
34
|
|
|
->children() |
35
|
|
|
->scalarNode('client')->defaultNull()->end() |
36
|
|
|
->arrayNode('options') |
37
|
|
|
->addDefaultsIfNotSet() |
38
|
|
|
->children() |
39
|
|
|
->integerNode('timeout')->end() |
40
|
|
|
->booleanNode('production')->end() |
41
|
|
|
->end() |
42
|
|
|
->end() |
43
|
|
|
->arrayNode('paybox') |
44
|
|
|
->isRequired() |
45
|
|
|
->addDefaultsIfNotSet() |
46
|
|
|
->children() |
47
|
|
|
->scalarNode('version') |
48
|
|
|
->isRequired() |
49
|
|
|
->cannotBeEmpty() |
50
|
|
|
->validate() |
51
|
|
|
->ifNotInArray(Version::getKeys('strtolower')) |
52
|
|
|
->thenInvalid('Invalid Paybox version') |
53
|
|
|
->end() |
54
|
|
|
->end() |
55
|
|
|
->scalarNode('site')->isRequired()->cannotBeEmpty()->end() |
56
|
|
|
->scalarNode('rank')->isRequired()->cannotBeEmpty()->end() |
57
|
|
|
->scalarNode('identifier')->isRequired()->cannotBeEmpty()->end() |
58
|
|
|
->scalarNode('key')->isRequired()->cannotBeEmpty()->end() |
59
|
|
|
->scalarNode('default_currency') |
60
|
|
|
->validate() |
61
|
|
|
->ifNotInArray(Currency::getKeys('strtolower')) |
62
|
|
|
->thenInvalid('Invalid Paybox currency') |
63
|
|
|
->end() |
64
|
|
|
->end() |
65
|
|
|
->scalarNode('default_activity') |
66
|
|
|
->validate() |
67
|
|
|
->ifNotInArray(Activity::getKeys('strtolower')) |
68
|
|
|
->thenInvalid('Invalid Paybox activity') |
69
|
|
|
->end() |
70
|
|
|
->end() |
71
|
|
|
->end() |
72
|
|
|
->end() |
73
|
|
|
->end() |
74
|
|
|
; |
75
|
|
|
|
76
|
|
|
return $treeBuilder; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|