1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Copyright 2014 SURFnet bv |
5
|
|
|
* |
6
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
7
|
|
|
* you may not use this file except in compliance with the License. |
8
|
|
|
* You may obtain a copy of the License at |
9
|
|
|
* |
10
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
11
|
|
|
* |
12
|
|
|
* Unless required by applicable law or agreed to in writing, software |
13
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
14
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15
|
|
|
* See the License for the specific language governing permissions and |
16
|
|
|
* limitations under the License. |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
namespace Surfnet\StepupMiddlewareClientBundle\DependencyInjection; |
20
|
|
|
|
21
|
|
|
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
22
|
|
|
use Symfony\Component\Config\Definition\ConfigurationInterface; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @codeCoverageIgnore |
26
|
|
|
*/ |
27
|
|
|
class Configuration implements ConfigurationInterface |
28
|
|
|
{ |
29
|
|
|
public function getConfigTreeBuilder() |
30
|
|
|
{ |
31
|
|
|
$treeBuilder = new TreeBuilder; |
32
|
|
|
|
33
|
|
|
$treeBuilder |
34
|
|
|
->root('surfnet_stepup_middleware_client') |
35
|
|
|
->children() |
36
|
|
|
->arrayNode('authorisation') |
37
|
|
|
->info('Middleware API Credentials') |
38
|
|
|
->children() |
39
|
|
|
->scalarNode('username')->isRequired()->end() |
40
|
|
|
->scalarNode('password')->isRequired()->end() |
41
|
|
|
->end() |
42
|
|
|
->end() |
43
|
|
|
->arrayNode('url') |
44
|
|
|
->children() |
45
|
|
|
->scalarNode('command_api')->isRequired()->end() |
46
|
|
|
->scalarNode('api') |
47
|
|
|
->isRequired() |
48
|
|
|
->validate() |
49
|
|
|
->ifTrue(function ($url) { |
50
|
|
|
return !preg_match('~/$~', $url); |
51
|
|
|
}) |
52
|
|
|
->thenInvalid("API URL must end with a forward slash, got '%s'") |
53
|
|
|
->end() |
54
|
|
|
->end() |
55
|
|
|
->end() |
56
|
|
|
->end() |
57
|
|
|
->end(); |
58
|
|
|
|
59
|
|
|
return $treeBuilder; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|