1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* The MIT License (MIT) |
7
|
|
|
* |
8
|
|
|
* Copyright (c) 2014-2018 Spomky-Labs |
9
|
|
|
* |
10
|
|
|
* This software may be modified and distributed under the terms |
11
|
|
|
* of the MIT license. See the LICENSE file for details. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OAuth2Framework\Bundle\DependencyInjection\Component\Endpoint; |
15
|
|
|
|
16
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Component; |
17
|
|
|
use OAuth2Framework\Bundle\DependencyInjection\Component\Endpoint\Token\TokenEndpointSource; |
18
|
|
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition; |
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
20
|
|
|
|
21
|
|
|
final class EndpointSource implements Component |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var Component[] |
25
|
|
|
*/ |
26
|
|
|
private $subComponents = []; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* EndpointSource constructor. |
30
|
|
|
*/ |
31
|
|
|
public function __construct() |
32
|
|
|
{ |
33
|
|
|
$this->subComponents = [ |
34
|
|
|
new TokenEndpointSource(), |
35
|
|
|
]; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return string |
40
|
|
|
*/ |
41
|
|
|
public function name(): string |
42
|
|
|
{ |
43
|
|
|
return 'endpoint'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* {@inheritdoc} |
48
|
|
|
*/ |
49
|
|
|
public function load(array $configs, ContainerBuilder $container) |
50
|
|
|
{ |
51
|
|
|
foreach ($this->subComponents as $subComponent) { |
52
|
|
|
$subComponent->load($configs, $container); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
|
public function getNodeDefinition(NodeDefinition $node) |
60
|
|
|
{ |
61
|
|
|
$childNode = $node->children() |
62
|
|
|
->arrayNode($this->name()) |
63
|
|
|
->addDefaultsIfNotSet(); |
64
|
|
|
|
65
|
|
|
foreach ($this->subComponents as $subComponent) { |
66
|
|
|
$subComponent->getNodeDefinition($childNode); |
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
public function prepend(ContainerBuilder $container, array $config): array |
74
|
|
|
{ |
75
|
|
|
$updatedConfig = []; |
76
|
|
|
foreach ($this->subComponents as $subComponent) { |
77
|
|
|
$updatedConfig = array_merge( |
78
|
|
|
$updatedConfig, |
79
|
|
|
$subComponent->prepend($container, $config) |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $updatedConfig; |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|